加上

-O2 -lm -std=c++14

//工作模拟器1.3
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <ctime>
#include<windows.h>
// 替换Windows特定功能
#ifdef _WIN32
#include <windows.h>
#else
// 提供Linux/macOS的替代实现
#endif
#include <fstream>
using namespace std;

int math_ability = 0;
int language_ability = 0;
int science_ability = 0;
int art_ability = 0;
int programming_ability = 0;  
int economics_ability = 0;    

bool can_teach_math = false;
bool can_teach_language = false;
bool can_teach_science = false;
bool can_teach_art = false;
bool can_teach_programming = false;


struct GameData {
	int money;
	int tired;
	int knowledge;
	int work;
	int bank_savings;   
	int bank_loan;         
	int loan_term;           
	int interest_rate;   
	int loan_rate;        
};



namespace dj {
	bool axj(long long key) {
		return (GetKeyState(key) < 0) ? (true) : (false);
	}
	struct hl {
		long long h,l;
	};
	void de(int x) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);
	}
	bool ax(long long key) {
		return (GetKeyState(key) < 0) ? (true) : (false);
	}
	hl wz(bool x = 1, bool n = 1) {
		HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
		HWND h = GetForegroundWindow();
		CONSOLE_FONT_INFO consoleCurrentFont;
		hl hl;
		POINT p;
		if (x) {
			GetCursorPos(&p);
			ScreenToClient(h, &p);
		} else {
			GetCursorPos(&p);
		}
		if (n) {
			GetCurrentConsoleFont(hOutput, FALSE, &consoleCurrentFont);
			p.x /= consoleCurrentFont.dwFontSize.X;
			p.y /= consoleCurrentFont.dwFontSize.Y;
		}
		hl.h = p.y + 1;
		hl.l = p.x + 1;
		return hl;
	}
	void ycbj() {
		HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
		DWORD mode;
		GetConsoleMode(hStdin, &mode);
		mode &= ~ENABLE_QUICK_EDIT_MODE;
		SetConsoleMode(hStdin, mode);
		return;
	}
	void ycgb() {
		CONSOLE_CURSOR_INFO cursor;
		cursor.bVisible = FALSE;
		cursor.dwSize = sizeof(cursor);
		HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
		SetConsoleCursorInfo(handle, &cursor);
		return;
	}
	inline void ydgb(long long h, long long l) {
		COORD pos = { l - 1,h - 1 };
		HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
		SetConsoleCursorPosition(hOut, pos);
		return;
	}
	bool pdbj(int y,int x,int x1,int x2,int ys,string zt) {
		ycgb();
		ycbj();
		hl z=wz(1,1);
		bool a=0;
		if(z.h==y&&z.l>=x1&&z.l<=x2) {
			ydgb(y,x);
			de(ys*16);
			cout<<zt;
			de(ys);
			if(axj(VK_LBUTTON)) {
				a=1;
			}
		} else {
			ydgb(y,x);
			de(ys);
			cout<<zt;
		}
		de(15);
		return a;
	}
};

using namespace dj;//一定要有

int tired=50,work;
int money=200;
int knowledge = 0;/////////////////////////////////////
int study;
// 初始化银行数据
int bank_savings = 0;
int bank_loan = 0;
int loan_term = 0;
int interest_rate = 0.02; // 初始2%
int loan_rate = 0.07;     // 初始7%

int select_elective_course() {
    system("cls");
    cout << "=== 选修课系统 ===" << endl;
    cout << "请选择您感兴趣的选修课程:" << endl;
    cout << "1. 高等数学 - 提升数学能力" << endl;
    cout << "2. 英语文学 - 提升语言能力" << endl;
    cout << "3. 物理化学 - 提升科学能力" << endl;
    cout << "4. 美术音乐 - 提升艺术能力" << endl;
    cout << "5. 计算机编程 - 提升编程能力" << endl;
    cout << "6. 经济学原理 - 提升经济能力" << endl;
    
    int selected_course = 0;
    while(1) {
        if(pdbj(3,1,1,25,2,"1. 高等数学")) {
            selected_course = 1;
            break;
        }
        if(pdbj(4,1,1,25,3,"2. 英语文学")) {
            selected_course = 2;
            break;
        }
        if(pdbj(5,1,1,25,4,"3. 物理化学")) {
            selected_course = 3;
            break;
        }
        if(pdbj(6,1,1,25,5,"4. 美术音乐")) {
            selected_course = 4;
            break;
        }
        if(pdbj(7,1,1,25,6,"5. 计算机编程")) {
            selected_course = 5;
            break;
        }
        if(pdbj(8,1,1,25,7,"6. 经济学原理")) {
            selected_course = 6;
            break;
        }
    }
    return selected_course;
}



int learn_subject() {
	Sleep(100);
	while(1) {
		if(pdbj(1,1,1,20,3,"图书馆自学:免费")) {
			return 1;
		}
		if(pdbj(2,1,1,20,2,"必修课:20元,专业导师")) {
			return 2;
		}
		if(pdbj(3,1,1,20,1,"选修课:增加更多知识")) {
			return 3;
		}
	}
}

void saveGame() {
	ofstream saveFile("game_save.dat");
	saveFile << money << endl;
	saveFile << tired << endl;
	saveFile << knowledge << endl;
	saveFile << work << endl;
	saveFile << bank_savings << endl;
	saveFile << bank_loan << endl;
	saveFile << loan_term << endl;
	saveFile << interest_rate << endl;
	saveFile << loan_rate << endl;
	saveFile.close();
	cout << "游戏数据已保存!" << endl;
	Sleep(1000);
}

void loadGame() {
	ifstream saveFile("game_save.dat");
	if (saveFile.is_open()) {
		saveFile >> money;
		saveFile >> tired;
		saveFile >> knowledge;
		saveFile >> work;
		saveFile >> bank_savings;
		saveFile >> bank_loan;
		saveFile >> loan_term;
		saveFile >> interest_rate;
		saveFile >> loan_rate;
	}
	saveFile.close();
	cout << "游戏数据已加载!" << endl;
	Sleep(1000);
}
//---银行
void cunkuan() {
	system("cls");

	cout << "=== 存款服务 ===" << endl;
	cout << "当前现金:" << money << "元" << endl;
	cout << "银行存款:" << bank_savings << "元" << endl;
	cout << "请输入存款金额(按ESC取消):" << endl;

	int deposit_amount = 0;
	string input_str;

	while(1) {
		ydgb(5,1);
		cout << "存款金额:";
		getline(cin, input_str);

		if(input_str == "") {
			continue;
		}

		if(axj(VK_ESCAPE)) {
			return;
		}

		try {
			deposit_amount = stod(input_str);

			if(deposit_amount <= 0) {
				cout << "存款金额必须大于0!" << endl;
				Sleep(1000);
				system("cls");
				cout << "=== 存款服务 ===" << endl;
				cout << "当前现金:" << money << "元" << endl;
				cout << "请输入存款金额(按ESC取消):" << endl;
				continue;
			}

			if(deposit_amount > money) {
				cout << "现金不足,无法存款!" << endl;
				Sleep(1000);
				system("cls");
				cout << "=== 存款服务 ===" << endl;
				cout << "当前现金:" << money << "元" << endl;
				cout << "请输入存款金额(按ESC取消):" << endl;
				continue;
			}

			break;
		} catch(...) {
			cout << "请输入有效的数字!" << endl;
			Sleep(1000);
			system("cls");
			cout << "=== 存款服务 ===" << endl;
			cout << "当前现金:" << money << "元" << endl;
			cout << "请输入存款金额(按ESC取消):" << endl;
		}
	}

	money -= deposit_amount;
	bank_savings += deposit_amount;

	system("cls");
	cout << "=== 存款成功 ===" << endl;
	cout << "存款金额:" << deposit_amount << "元" << endl;
	cout << "当前现金:" << money << "元" << endl;
	cout << "银行存款:" << bank_savings << "元" << endl;
	cout << "预计年收益:" << (bank_savings * interest_rate) << "元" << endl;

	Sleep(3000);
}

void qukuan() {
	system("cls");

	cout << "=== 取款服务 ===" << endl;
	cout << "当前现金:" << money << "元" << endl;
	cout << "银行存款:" << bank_savings << "元" << endl;
	cout << "请输入取款金额(按ESC取消):" << endl;

	int withdraw_amount = 0;
	string input_str;

	while(1) {
		ydgb(5,1);
		cout << "取款金额:";
		getline(cin, input_str);

		if(input_str == "") {
			continue;
		}

		if(axj(VK_ESCAPE)) {
			return;
		}

		try {
			withdraw_amount = stod(input_str);

			if(withdraw_amount <= 0) {
				cout << "取款金额必须大于0!" << endl;
				Sleep(1000);
				system("cls");
				cout << "=== 取款服务 ===" << endl;
				cout << "当前现金:" << money << "元" << endl;
				cout << "请输入取款金额(按ESC取消):" << endl;
				continue;
			}

			if(withdraw_amount > bank_savings) {
				cout << "存款不足,无法取款!" << endl;
				Sleep(1000);
				system("cls");
				cout << "=== 取款服务 ===" << endl;
				cout << "当前现金:" << money << "元" << endl;
				cout << "请输入取款金额(按ESC取消):" << endl;
				continue;
			}

			break;
		} catch(...) {
			cout << "请输入有效的数字!" << endl;
			Sleep(1000);
			system("cls");
			cout << "=== 取款服务 ===" << endl;
			cout << "当前现金:" << money << "元" << endl;
			cout << "请输入取款金额(按ESC取消):" << endl;
		}
	}

	bank_savings -= withdraw_amount;
	money += withdraw_amount;

	system("cls");
	cout << "=== 取款成功 ===" << endl;
	cout << "取款金额:" << withdraw_amount << "元" << endl;
	cout << "当前现金:" << money << "元" << endl;
	cout << "银行存款:" << bank_savings << "元" << endl;

	Sleep(3000);
}

void shenqingdaikuan() {
	system("cls");

	if(bank_loan > 0) {
		cout << "您已有未还清的贷款,请先还款!" << endl;
		Sleep(2000);
		return;
	}

	cout << "=== 贷款服务 ===" << endl;
	cout << "贷款利率:年化" << (loan_rate * 100) << "%" << endl;
	cout << "最大可贷款额度:" << (money * 5) << "元" << endl;
	cout << "请输入贷款金额(按ESC取消):" << endl;

	int loan_amount = 0;
	string input_str;

	while(1) {
		ydgb(5,1);
		cout << "贷款金额:";
		getline(cin, input_str);

		if(input_str == "") {
			continue;
		}

		if(axj(VK_ESCAPE)) {
			return;
		}

		try {
			loan_amount = stod(input_str);

			if(loan_amount <= 0) {
				cout << "贷款金额必须大于0!" << endl;
				Sleep(1000);
				system("cls");
				cout << "=== 贷款服务 ===" << endl;
				cout << "最大可贷款额度:" << (money * 5) << "元" << endl;
				cout << "请输入贷款金额(按ESC取消):" << endl;
				continue;
			}

			if(loan_amount > (money * 5)) {
				cout << "贷款金额超过最大额度!" << endl;
				Sleep(1000);
				system("cls");
				cout << "=== 贷款服务 ===" << endl;
				cout << "最大可贷款额度:" << (money * 5) << "元" << endl;
				cout << "请输入贷款金额(按ESC取消):" << endl;
				continue;
			}

			// 确认贷款
			system("cls");
			cout << "=== 贷款确认 ===" << endl;
			cout << "贷款金额:" << loan_amount << "元" << endl;
			cout << "年利息:" << (loan_amount * loan_rate) << "元" << endl;
			cout << "是否确认申请贷款?(Y/N)" << endl;

			char confirm;
			cin >> confirm;

			if(confirm == 'Y' || confirm == 'y') {
				bank_loan = loan_amount;
				money += loan_amount;
				loan_term = 365; // 1年期限

				cout << "贷款申请成功!" << endl;
				cout << "请记得按时还款,逾期会产生额外费用!" << endl;
			} else {
				cout << "贷款申请已取消" << endl;
			}

			break;
		} catch(...) {
			cout << "请输入有效的数字!" << endl;
			Sleep(1000);
			system("cls");
			cout << "=== 贷款服务 ===" << endl;
			cout << "请输入贷款金额(按ESC取消):" << endl;
		}
	}

	Sleep(3000);
}

void huankuan() {
	system("cls");

	if(bank_loan <= 0) {
		cout << "您当前没有需要还款的贷款!" << endl;
		Sleep(2000);
		return;
	}

	cout << "=== 还款服务 ===" << endl;
	cout << "当前贷款:" << bank_loan << "元" << endl;
	cout << "请输入还款金额(按ESC取消):" << endl;

	int repay_amount = 0;
	string input_str;

	while(1) {
		ydgb(5,1);
		cout << "还款金额:";
		getline(cin, input_str);

		if(input_str == "") {
			continue;
		}

		if(axj(VK_ESCAPE)) {
			return;
		}

		try {
			repay_amount = stod(input_str);

			if(repay_amount <= 0) {
				cout << "还款金额必须大于0!" << endl;
				Sleep(1000);
				system("cls");
				cout << "=== 还款服务 ===" << endl;
				cout << "请输入还款金额(按ESC取消):" << endl;
				continue;
			}

			if(repay_amount > money) {
				cout << "现金不足,无法还款!" << endl;
				Sleep(1000);
				system("cls");
				cout << "=== 还款服务 ===" << endl;
				cout << "请输入还款金额(按ESC取消):" << endl;
				continue;
			}

			if(repay_amount > bank_loan) {
				cout << "还款金额超过贷款总额!" << endl;
				Sleep(1000);
				system("cls");
				cout << "=== 还款服务 ===" << endl;
				cout << "请输入还款金额(按ESC取消):" << endl;
				continue;
			}

			money -= repay_amount;
			bank_loan -= repay_amount;

			system("cls");
			cout << "=== 还款成功 ===" << endl;
			cout << "还款金额:" << repay_amount << "元" << endl;
			cout << "剩余贷款:" << bank_loan << "元" << endl;
			cout << "当前现金:" << money << "元" << endl;

			if(bank_loan == 0) {
				cout << "恭喜您已还清所有贷款!" << endl;
			}

			break;
		} catch(...) {
			cout << "请输入有效的数字!" << endl;
			Sleep(1000);
			system("cls");
			cout << "=== 还款服务 ===" << endl;
			cout << "请输入还款金额(按ESC取消):" << endl;
		}
	}

	Sleep(3000);
}

void zhanghuxiangqing() {
	system("cls");

	cout << "=== 银行账户详情 ===" << endl;
	cout << "现金余额:" << money << "元" << endl;
	cout << "银行存款:" << bank_savings << "元" << endl;
	cout << "银行贷款:" << bank_loan << "元" << endl;
	cout << "存款利率:年化" << (interest_rate * 100) << "%" << endl;
	cout << "贷款利率:年化" << (loan_rate * 100) << "%" << endl;
	cout << endl;

// 计算预计收益
	int yearly_interest = bank_savings * interest_rate;
	int loan_interest = bank_loan * loan_rate;

	cout << "存款年收益:" << yearly_interest << "元" << endl;
	cout << "贷款年利息:" << loan_interest << "元" << endl;
	cout << endl;

	if(bank_savings > 0) {
		cout << "每日存款收益:" << (yearly_interest / 365) << "元" << endl;
	}
	Sleep(5000);
}

void calculate_daily_interest() {
	// 每日存款利息
	if(bank_savings > 0) {
		int daily_interest = bank_savings * interest_rate / 365;
		bank_savings += daily_interest;

		cout << "今日存款利息:" << daily_interest << "元" << endl;
	}

	// 每日贷款利息
	if(bank_loan > 0) {
		int daily_loan_interest = bank_loan * loan_rate / 365;
		bank_loan += daily_loan_interest;

		cout << "今日贷款利息:" << daily_loan_interest << "元" << endl;
	}
}

void update_bank_rates() {
	// 根据存款金额调整利率
	if(bank_savings < 1000) {
		interest_rate = 0.015; // 1.5%
	} else if(bank_savings < 10000) {
		interest_rate = 0.02;  // 2.0%
	} else if(bank_savings < 50000) {
		interest_rate = 0.025; // 2.5%
	} else {
		interest_rate = 0.03;  // 3.0%
	}

	// 贷款利率固定比存款利率高
	loan_rate = interest_rate + 0.05; // 贷款利率比存款利率高5%
}



void bank() {
	system("cls");
	Sleep(1000);
	cout << "=== 莫尔德帝国银行 ===" << endl;
	cout << "当前现金:" << money << "元" << endl;
	cout << "银行存款:" << bank_savings << "元" << endl;
	if(bank_loan > 0) {
		cout << "银行贷款:" << bank_loan << "元" << endl;
	}
	cout << "存款利率:年化" << (interest_rate * 100) << "%" << endl;
	if(bank_loan > 0) {
		cout << "贷款利率:年化" << (loan_rate * 100) << "%" << endl;
	}
	cout << "请选择银行服务:" << endl;
	cout << "1. 存款" << endl;
	cout << "2. 取款" << endl;
	cout << "3. 申请贷款" << endl;
	cout << "4. 还款" << endl;
	cout << "5. 账户详情" << endl;
	cout << "按ESC返回" << endl;
	int selected_option = 0;
	while(1) {
		// 显示选项按钮
		if(pdbj(6,1,1,15,2,"1. 存款")) {
			selected_option = 1;
			break;
		}
		if(pdbj(7,1,1,15,3,"2. 取款")) {
			selected_option = 2;
			break;
		}
		if(pdbj(8,1,1,15,4,"3. 申请贷款")) {
			selected_option = 3;
			break;
		}
		if(pdbj(9,1,1,15,5,"4. 还款")) {
			selected_option = 4;
			break;
		}
		if(pdbj(10,1,1,15,6,"5. 账户详情")) {
			selected_option = 5;
			break;
		}
		if(axj(VK_ESCAPE)) {
			return;
		}
	}

	// 处理选择的银行服务
	switch(selected_option) {
		case 1: // 存款
			cunkuan();
			break;

		case 2: // 取款
			qukuan();
			break;

		case 3: // 申请贷款
			shenqingdaikuan();
			break;

		case 4: // 还款
			huankuan();
			break;

		case 5: // 查看账户详情
			zhanghuxiangqing();
			break;
	}

}
// ---
int job() {
    Sleep(100);
    while(1) {
        if(pdbj(1,1,1,33,6,"工地基础材料搬运工,多劳多得,无限制")) {
            return 1;
        }
        if(pdbj(2,1,1,33,1,"保鲜膜生产制作工人,多劳多得,无限制")) {
            return 2;
        }
        if(pdbj(3,1,1,33,7,"家教,要求专项能力,收益更高")) {
            // 检查是否有可用的专项家教资格
            if(can_teach_math || can_teach_language || can_teach_science || can_teach_art || can_teach_programming) {
                return 3;
            } else {
                cout << "需要先学习专项能力才能从事家教!";
                Sleep(1000);
                return 0;
            }
        }
        if(pdbj(4,1,1,33,8,"房地产开发商,需要100万启动资金")) {
            if(money >= 1000000) {
                return 4;
            } else {
                cout << "资金不足,无法进入房地产市场!";
                Sleep(1000);
                return 0;
            }
        }
    }
}


//学习 
void check_unlocked_teaching_types() {
    // 解锁数学家教
    if(math_ability >= 10 && !can_teach_math) {
        can_teach_math = true;
        cout << "恭喜!您已解锁高等数学家教资格!" << endl;
    }
    
    // 解锁语言家教
    if(language_ability >= 10 && !can_teach_language) {
        can_teach_language = true;
        cout << "恭喜!您已解锁英语文学家教资格!" << endl;
    }
    
    // 解锁科学家教
    if(science_ability >= 10 && !can_teach_science) {
        can_teach_science = true;
        cout << "恭喜!您已解锁物理化学家教资格!" << endl;
    }
    
    // 解锁艺术家教
    if(art_ability >= 10 && !can_teach_art) {
        can_teach_art = true;
        cout << "恭喜!您已解锁美术音乐家教资格!" << endl;
    }
    
    // 解锁编程家教
    if(programming_ability >= 7 && !can_teach_programming) {
        can_teach_programming = true;
        cout << "恭喜!您已解锁计算机编程家教资格!" << endl;
    }
}

void study_process(int subject) {
    system("cls");
    int study_points = 0;
    bool completed = false;
    
    // 选修课变量
    int elective_course = 0;
    string subject_name, study_content;
    int cost_per_hour, points_per_hour;
    int energy_cost;
    int ability_type = 0; // 1:数学, 2:语言, 3:科学, 4:艺术, 5:编程, 6:经济

    switch(subject) {
        case 1: // 自学模式
            subject_name = "自学";
            study_content = "《论语》,《离骚》,《相对论》";
            cost_per_hour = 0.0;
            points_per_hour = 1.0;
            energy_cost = 5;
            ability_type = 0;
            break;
            
        case 2: // 必修课模式
            subject_name = "必修课";
            study_content = "∫x2dx = x3/3 + C   lim(x→∞)(1+1/x)? = e";
            cost_per_hour = 20.0;
            points_per_hour = 3.0;
            energy_cost = 2;
            ability_type = 0;
            break;
            
        case 3: // 选修课模式
        	Sleep(1000);
            elective_course = select_elective_course();
            
            switch(elective_course) {
                case 1: // 高等数学
                    subject_name = "高等数学";
                    study_content = "微积分、线性代数、概率统计";
                    cost_per_hour = 15.0;
                    points_per_hour = 2.5;
                    energy_cost = 3;
                    ability_type = 1;
                    break;
                    
                case 2: // 英语文学
                    subject_name = "英语文学";
                    study_content = "莎士比亚作品、英语语法、写作技巧";
                    cost_per_hour = 18.0;
                    points_per_hour = 2.8;
                    energy_cost = 3;
                    ability_type = 2;
                    break;
                    
                case 3: // 物理化学
                    subject_name = "物理化学";
                    study_content = "牛顿定律、化学反应、实验操作";
                    cost_per_hour = 20.0;
                    points_per_hour = 3.0;
                    energy_cost = 4;
                    ability_type = 3;
                    break;
                    
                case 4: // 美术音乐
                    subject_name = "美术音乐";
                    study_content = "绘画技巧、音乐理论、艺术鉴赏";
                    cost_per_hour = 25.0;
                    points_per_hour = 2.0;
                    energy_cost = 2;
                    ability_type = 4;
                    break;
                    
                case 5: // 计算机编程
                    subject_name = "计算机编程";
                    study_content = "C++语法、算法设计、项目开发";
                    cost_per_hour = 30.0;
                    points_per_hour = 3.5;
                    energy_cost = 4;
                    ability_type = 5;
                    break;
                    
                case 6: // 经济学原理
                    subject_name = "经济学原理";
                    study_content = "供需关系、市场分析、投资策略";
                    cost_per_hour = 22.0;
                    points_per_hour = 2.2;
                    energy_cost = 3;
                    ability_type = 6;
                    break;
                    
                default:
                    return;
            }
            break;
            
        default:
            return;
    }
	system("cls");
    cout << "正在学习:" << subject_name << endl;
    cout << "学习内容:" << study_content << endl;
    if(cost_per_hour > 0) {
        cout << "每小时费用:" << cost_per_hour << "元" << endl;
    } else {
        cout << "免费学习" << endl;
    }
    cout << "按空格键学习,ESC键结束" << endl;

    while(1) {
        if(axj(VK_SPACE)) {
            if(money >= cost_per_hour) {
                if(cost_per_hour > 0) {
                    money -= cost_per_hour;
                }
                study_points += points_per_hour;
                tired -= energy_cost;
                
                cout << "学习进度:" << study_points << " 知识+" << points_per_hour;
                
                // 根据选修课类型增加专项能力
                if(ability_type > 0 && study_points % 2 == 0) {
                    switch(ability_type) {
                        case 1: // 数学能力
                            math_ability++;
                            cout << " 数学能力+" << 1;
                            break;
                                
                        case 2: // 语言能力
                            language_ability++;
                            cout << " 语言能力+" << 1;
                            break;
                                
                        case 3: // 科学能力
                            science_ability++;
                            cout << " 科学能力+" << 1;
                            break;
                                
                        case 4: // 艺术能力
                            art_ability++;
                            cout << " 艺术能力+" << 1;
                            break;
                                
                        case 5: // 编程能力
                            programming_ability++;
                            cout << " 编程能力+" << 1;
                            break;
                                
                        case 6: // 经济能力
                            economics_ability++;
                            cout << " 经济能力+" << 1;
                            break;
                    }
                }
                cout << endl;
                Sleep(500);
            } else {
                cout << "资金不足,无法继续学习!" << endl;
                Sleep(1000);
                break;
            }
        }

        if(axj(VK_ESCAPE)) {
            break;
        }

        if(tired <= 0) {
            cout << "太累了,需要休息!" << endl;
            Sleep(1000);
            break;
        }

        if(study_points >= 10) {
            completed = true;
            break;
        }
    }

    if(completed) {
        knowledge += study_points;
        cout << "恭喜完成本次学习!知识水平+" << study_points << endl;
        check_unlocked_teaching_types();
    } else {
        knowledge += study_points * 0.5;
        cout << "学习结束,获得知识:" << study_points * 0.5 << endl;
    }
    Sleep(2000);
}


void knowledge_level(int knowledge) {
	if(knowledge < 10) {
		cout << "初中";
	} else if(knowledge < 30) {
		cout << "高中";
	} else if(knowledge < 100) {
		cout << "大学";
	} else if(knowledge < 150) {
		cout << "研究生";
	} else {
		cout << "硕士";
	}
}



// 

void gongchang() {
	int zs=0;
	while(1) {
		ydgb(1,1);
		cout<<"=====把传送带上的东西做完!"<<endl;
		if(pdbj(1,1,1,1,1,"=")) {
			while(1) {
				system("cls");
				ydgb(1,1);
				cout<<"=====";
				system("cls");
				if(pdbj(1,2,2,2,1,"=")) {
					while(1) {
						system("cls");
						ydgb(1,1);
						cout<<"=====";
						if(pdbj(1,3,3,3,1,"=")) {
							while(1) {
								system("cls");
								ydgb(1,1);
								cout<<"=====";
								if(pdbj(1,4,4,4,1,"=")) {
									while(1) {
										system("cls");
										ydgb(1,1);
										cout<<"=====";
										if(pdbj(1,5,5,5,1,"=")) {
											break;
										}
									}
									break;
								}
							}
							break;
						}
					}
					break;
				}
			}
			zs++;
			tired--;
		}
		cout<<endl;
		cout<<"已制作保鲜膜:"<<zs;
		if(pdbj(3,1,1,4,15,"下工")) {
			break;
		}
		if(tired<=0) {
			cout<<"饿倒了";
			Sleep(1000);
			break;
		}
	}
	system("cls");
	cout<<"本次工资:"<<zs;
	money+=zs;
	Sleep(1000);
	return ;
}

void banzhuan() {
	cout<<"这不就是搬砖吗?";
	Sleep(1000);
	system("cls");
	bool fl=1;
	int zs=0;
	int h,l;
	while(1) {
		ydgb(1,1);
		cout<<"___________________________________________________"<<endl;
		cout<<"|                                                 |"<<endl;
		cout<<"|                                                 |"<<endl;
		cout<<"|                                                 |"<<endl;
		cout<<"|                                                 |"<<endl;
		cout<<"|                                                 |"<<endl;
		cout<<"|                                                 |"<<endl;
		cout<<"|                                                 |"<<endl;
		cout<<"|                                                 |"<<endl;
		cout<<"|                                                 |"<<endl;
		cout<<"|                                                 |"<<endl;
		cout<<"|_________________________________________________|"<<endl;
		cout<<"       高高兴兴上班,平平安安回家     已搬砖数:"<<zs;
		if(fl) {
			h=rand()%30+2;
			l=rand()%10+2;
			fl=0;
		}
		const int h1=h;
		const int l1=l;
		if(pdbj(l1,h1,h1,h1+2,6,"砖")) {
			zs++;
			fl=1;
			tired--;
			system("cls");
			continue;
		}
		if(pdbj(16,1,1,4,15,"下工")) {
			break;
		}
		if(tired==0) {
			system("cls");
			cout<<"你快饿扁了!"<<endl;
			break;
		}
	}
	Sleep(500);
	system("cls");
	cout<<"本次工资:"<<zs;
	money+=zs;
	Sleep(500);
	return ;
}

void jiajiao() {
    system("cls");

    if(tired < 20) {
        cout << "太累了,无法进行家教工作!" << endl;
        Sleep(1000);
        return;
    }

    // 显示可用的家教类型
    cout << "=== 家教工作系统 ===" << endl;
    cout << "请选择您要从事的家教类型:" << endl;
    
    vector<string> available_courses;
    vector<int> course_types;
    
    // 基础数学家教(原有)
    available_courses.push_back("初中数学家教");
    course_types.push_back(0);
    
    // 新增专项家教类型
    if(can_teach_math) {
        available_courses.push_back("高等数学家教");
        course_types.push_back(1);
    }
    
    if(can_teach_language) {
        available_courses.push_back("英语文学家教");
        course_types.push_back(2);
    }
    
    if(can_teach_science) {
        available_courses.push_back("物理化学家教");
        course_types.push_back(3);
    }
    
    if(can_teach_art) {
        available_courses.push_back("美术音乐家教");
        course_types.push_back(4);
    }
    
    if(can_teach_programming) {
        available_courses.push_back("计算机编程家教");
        course_types.push_back(5);
    }
    
    // 显示可用选项
    for(int i = 0; i < available_courses.size(); i++) {
        cout << (i+1) << ". " << available_courses[i] << endl;
    }
    
    cout << "按ESC返回" << endl;
    int selected_course = 0;
    int y_pos = 6;
    
    while(1) {
        for(int i = 0; i < available_courses.size(); i++) {
            if(pdbj(y_pos+i,1,1,20,2+i, (to_string(i+1) + ". " + available_courses[i]))) {
                selected_course = course_types[i];
                break;
            }
        }
        
        if(axj(VK_ESCAPE)) {
            return;
        }
        
        if(selected_course > 0) {
            break;
        }
    }
	system("cls");
    // 根据选择的家教类型执行不同的教学流程
    switch(selected_course) {
        case 0: // 初中数学家教(原有)
            // 原有的家教逻辑
            break;
            
        case 1: // 高等数学家教
            // 新的教学逻辑,收益更高
            break;
            
        case 2: // 英语文学家教
            // 语言类家教逻辑
            break;
            
        case 3: // 物理化学家教
            // 科学类家教逻辑
            break;
            
        case 4: // 美术音乐家教
            // 艺术类家教逻辑
            break;
            
        case 5: // 计算机编程家教
            // 编程类家教逻辑
            break;
    }

    // 具体的家教工作流程
    cout << "=== 家教工作开始 ===" << endl;
    cout << "学生:小明(初中数学)" << endl;
    cout << "课时:2小时" << endl;
    cout << "按空格键进行教学,ESC键结束" << endl;

    int teaching_progress = 0;
    int teaching_quality = 0;
    bool completed = false;

    // 根据知识水平决定教学质量
    if(knowledge >= 100) {
        teaching_quality = 3; // 教授水平
    } else if(knowledge >= 50) {
        teaching_quality = 2; // 研究生水平
    } else if(knowledge >= 30) {
        teaching_quality = 1; // 大学水平
    } else {
        teaching_quality = 0; // 基础水平
    }

    while(1) {
        if(axj(VK_SPACE)) {
            teaching_progress++;
            tired -= 2; // 每次教学消耗2点体力

            cout << "教学进度:" << teaching_progress;

            // 根据教学质量显示不同反馈
            switch(teaching_quality) {
                case 3:
                    cout << " 学生:老师讲得太好了!";
                    break;
                case 2:
                    cout << " 学生:这个知识点我懂了!";
                    break;
                case 1:
                    cout << " 学生:谢谢老师指导~";
                    break;
                default:
                    cout << " 学生:有点难理解...";
                    break;
            }
            cout << endl;
            Sleep(300);
        }

        if(axj(VK_ESCAPE)) {
            break;
        }

        if(tired <= 0) {
            cout << "体力耗尽,无法继续教学!" << endl;
            Sleep(1000);
            break;
        }

        if(teaching_progress >= 15) {
            completed = true;
            break;
        }
    }

    // 计算报酬
    int base_salary = 200.0;
    int quality_bonus = teaching_quality * 50.0; // 教学质量奖励
    int completion_bonus = completed ? 100.0 : 0.0; // 完成奖励

    int total_income = base_salary + quality_bonus + completion_bonus;

    money += total_income;

    system("cls");
    cout << "=== 家教工作结束 ===" << endl;
    cout << "基础工资:" << base_salary << "元" << endl;
    if(quality_bonus > 0) {
        cout << "教学质量奖励:" << quality_bonus << "元" << endl;
    }
    if(completion_bonus > 0) {
        cout << "完成课时奖励:" << completion_bonus << "元" << endl;
    }
    cout << "总收入:" << total_income << "元" << endl;
    cout << "当前余额:" << money << "元" << endl;

    // 知识水平也有小幅提升
    if(completed) {
        knowledge += 2;
        cout << "教学相长,知识水平+2" << endl;
    }

    Sleep(3000);
}


void fangdichan() {
    system("cls");
    Sleep(100);
    // 经济限制检查
    if(money < 1000000) {
        cout << "=== 资金不足 ===" << endl;
        cout << "当前现金:" << money << "元" << endl;
        cout << "房地产开发商需要100万启动资金!" << endl;
        Sleep(3000);
        return;
    }
    
    cout << "=== 房地产开发商工作 ===" << endl;
    cout << "启动资金:100万元" << endl;
    cout << "当前现金:" << money << "元" << endl;
    cout << "请选择开发项目:" << endl;
    cout << "1. 住宅小区开发(投资50万,收益80万)" << endl;
    cout << "2. 商业中心建设(投资80万,收益120万)" << endl;
    cout << "3. 豪华别墅项目(投资150万,收益200万)" << endl;
    cout << "按ESC返回" << endl;
    
    int selected_project = 0;
    
    while(1) {
        if(pdbj(5,1,1,25,2,"1. 住宅小区开发")) {
            selected_project = 1;
            break;
        }
        if(pdbj(6,1,1,25,3,"2. 商业中心建设")) {
            selected_project = 2;
            break;
        }
        if(pdbj(7,1,1,25,4,"3. 豪华别墅项目")) {
            selected_project = 3;
            break;
        }
        if(axj(VK_ESCAPE)) {
            return;
        }
    }
    
    // 处理选择的开发项目
    int investment = 0;
    int  profit = 0;
    string project_name;
    
    switch(selected_project) {
        case 1: // 住宅小区
            investment = 500000;
            profit = 800000;
            project_name = "住宅小区开发";
            break;
            
        case 2: // 商业中心
            investment = 800000;
            profit = 1200000;
            project_name = "商业中心建设";
            break;
            
        case 3: // 豪华别墅
            investment = 1500000;
            project_name = "豪华别墅项目";
            break;
    }
    
    // 二次资金检查
    if(money < investment) {
        cout << "资金不足,无法启动该项目!" << endl;
        Sleep(2000);
        return;
    }
    
    // 项目执行过程
    system("cls");
    cout << "=== " << project_name << " ===" << endl;
    cout << "项目投资:" << investment << "元" << endl;
    cout << "预计收益:" << profit << "元" << endl;
    cout << "按空格键推进项目进度" << endl;
    
    int progress = 0;
    bool project_success = true;
    
    while(1) {
        if(axj(VK_SPACE)) {
            progress += 10;
            tired -= 5;
            
            cout << "项目进度:" << progress << "%" << endl;
            
            // 随机事件:可能影响项目收益
            int random_event = rand() % 100;
            if(random_event < 10) { // 10%概率遇到问题
                cout << "??  遇到施工问题,需要额外处理!" << endl;
            }
            
            Sleep(500);
        }
        
        if(axj(VK_ESCAPE)) {
            project_success = false;
            break;
        }
        
        if(tired <= 20) {
            cout << "体力不足,无法继续推进项目!" << endl;
            project_success = false;
            Sleep(1000);
            break;
        }
        
        if(progress >= 100) {
            break;
        }
    }
    
    // 结算收益
    if(project_success) {
        money -= investment; // 扣除投资
        money += profit;     // 获得收益
        knowledge += 5;      // 经验积累
        
        system("cls");
        cout << "=== 项目完成 ===" << endl;
        cout << "项目名称:" << project_name << endl;
        cout << "投资金额:" << investment << "元" << endl;
        cout << "收益金额:" << profit << "元" << endl;
        cout << "净利润:" << (profit - investment) << "元" << endl;
        cout << "知识水平+5" << endl;
    } else {
        cout << "项目中断,投资损失!" << endl;
        money -= investment * 0.3; // 损失30%投资
    }
    
    Sleep(3000);
}

//民以食为天 

void bdje(int tired) {
	if(tired < 10) {
		cout << "极度饥饿,急需进食!";
	} else if(tired < 30) {
		cout << "非常饥饿,需要吃饭";
	} else if(tired < 50) {
		cout << "比较饥饿";
	} else if(tired == 50) {
		cout << "肚子不算饿";
	} else if(tired < 80) {
		cout << "饱了";
	} else if(tired < 90) {
		cout << "很饱";
	} else {
		cout << "太撑了,不能再吃了!";
	}
}

void chifan() {
	system("cls");
	Sleep(1000);
	cout << "=== 餐饮系统 ===" << endl;
	cout << "当前饥饿状态:";
	bdje(tired);
	cout<<endl;
	cout << "请选择餐饮方式:" << endl;
	cout << "1. 快餐 (10元,恢复20体力)" << endl;
	cout << "2. 自助餐 (30元,恢复50体力)" << endl;
	cout << "3. 高级餐厅 (80元,恢复80体力)" << endl;
	cout << "4. 豪华大餐 (150元,恢复100体力)" << endl;
	cout << "5. 自己做饭 (5元,恢复15体力)" << endl;
	cout << "按ESC返回" << endl;

	int selected_option = 0;

	while(1) {
		// 显示选项按钮
		if(pdbj(4,1,1,15,2,"1. 快餐 (10元")) {
			selected_option = 1;
			break;
		}
		if(pdbj(5,1,1,15,3,"2. 自助餐 (30元")) {
			selected_option = 2;
			break;
		}
		if(pdbj(6,1,1,15,4,"3. 高级餐厅 (80元")) {
			selected_option = 3;
			break;
		}
		if(pdbj(7,1,1,15,5,"4. 豪华大餐 (150元")) {
			selected_option = 4;
			break;
		}
		if(pdbj(8,1,1,15,6,"5. 自己做饭 (5元")) {
			selected_option = 5;
			break;
		}
		if(axj(VK_ESCAPE)) {
			return;
		}
	}
	Sleep(100);
	system("cls");
	// 处理选择的餐饮方式
	switch(selected_option) {
		case 1: // 快餐
			if(money < 10) {
				cout << "余额不足,无法享用快餐!" << endl;
				Sleep(1000);
				return;
			}
			if(tired > 90) {
				cout << "已经太饱了,吃不下了!" << endl;
				Sleep(1000);
				return;
			}
			money -= 10;
			tired += 20;
			cout << "享用快餐,体力恢复20点!" << endl;
			break;

		case 2: // 自助餐
			if(money < 30) {
				cout << "余额不足,无法享用自助餐!" << endl;
				Sleep(1000);
				return;
			}
			if(tired > 80) {
				cout << "已经比较饱了,建议选择更便宜的餐饮!" << endl;
				Sleep(1000);
				return;
			}
			money -= 30;
			tired += 50;
			cout << "享用自助餐,体力恢复50点!" << endl;
			break;

		case 3: // 高级餐厅
			if(money < 80) {
				cout << "余额不足,无法享用高级餐厅!" << endl;
				Sleep(1000);
				return;
			}
			if(tired > 50) {
				cout << "当前体力充足,建议选择更经济的餐饮!" << endl;
				Sleep(1000);
				return;
			}
			money -= 80;
			tired += 80;
			cout << "享用高级餐厅美食,体力恢复80点!" << endl;
			break;

		case 4: // 豪华大餐
			if(money < 150) {
				cout << "余额不足,无法享用豪华大餐!" << endl;
				Sleep(1000);
				return;
			}
			if(tired > 20) {
				cout << "当前体力尚可,豪华大餐有些浪费!" << endl;
				Sleep(1000);
				return;
			}
			money -= 150;
			tired = 100; // 直接恢复满体力
			cout << "享用豪华大餐,体力完全恢复!" << endl;
			break;

		case 5: // 自己做饭
			if(money < 5) {
				cout << "余额不足,无法购买食材!" << endl;
				Sleep(1000);
				return;
			}
			money -= 5;
			tired += 15;
			cout << "自己动手做饭,体力恢复15点!" << endl;
			break;
	}

	// 确保体力不超过上限
	if(tired > 100) {
		tired = 100;
	}

	// 显示用餐效果
	cout << endl;
	cout << "用餐后状态:" << endl;
	cout << "余额:" << money << "元" << endl;
	cout << "体力:" << tired << "/100" << endl;

	Sleep(2000);
}

// 

void shangban(int wk) {
    if(tired <= 0) {
        cout << "先吃饭吧";
        Sleep(1000);
        return;
    }
    
    if(wk == 1) {
        banzhuan();
    } else if(wk == 2) {
        gongchang();
    } else if(wk == 3) {
        jiajiao();
    } else if(wk == 4) { // 新增房地产开发商
        fangdichan();
    } else {
        cout << "你都没有应聘好吗?";
    }
    Sleep(1000);
    return;
}



void ctjb(int work) {
	if(work==1) {
		cout<<"工地基础材料搬运工";
	} else if(work==2) {
		cout<<"钟点工人";
	} else if(work==3) {
		cout<<"私人家教";
	}else if(work==4){
		cout<<"房地产开发商"; 
	} else {
		cout<<"无业游民";
	}
}

int main() {
	ifstream testFile("game_save.dat");
	cout << "是否加载存档文件?(Y/N)//之前没玩过的建议不要加载,否则会遇见0元的尴尬情况" << endl;
	char choice;
	cin >> choice;
	if (choice == 'Y' || choice == 'y') {
		loadGame();
	}
	testFile.close();
	system("mode con cols=150 lines=50");
	srand(time(0));
	cout<<"======================================================================================================================================================"<<endl;
	cout<<"                                                 欢迎来到莫尔德帝国,你要在这里生活下去了"<<endl;
	Sleep(1000);
	cout<<"                                                   我先给你200,等你钱够多了我再来找你哦~"<<endl;
	Sleep(5000);
	system("cls");
	cout<<"那人是谁?算了不管了,这个地方——算了不管了,先解决温饱吧";
	Sleep(5000);
	system("cls");
	while(money>=0) {
		// 在工作、学习、吃饭函数结束时调用

		if(money>=100000000) {
			system("cls");
			cout<<"你成为了全帝国数一数二的富翁,却再也没见过那人了~";
			return 0;
		}
		if(knowledge>=500) {
			system("cls");
			cout<<"你通过努力学习,成为了一名教授,事迹感人,教授不是你的终点,而是你的起点,加油!";
			return 0;
		}
		ydgb(1,1);
		cout<<"余额:"<<money<<"    ";
		bdje(tired);
		cout<<endl;
		cout<<"当前职业:";
		ctjb(work);
		cout<<"    学历:";
		knowledge_level(knowledge);


		if(pdbj(3,1,1,8,15,"选择职业")) {
			system("cls");
			work=job();
			system("cls");
			Sleep(100);
		}
		if(pdbj(4,1,1,4,15,"工作")) {
			system("cls");
			shangban(work);
			system("cls");
			Sleep(100);
		}
		if(pdbj(5,1,1,4,15,"吃饭")) {
			system("cls");
			chifan();
			system("cls");
			Sleep(100);
		}

		if(pdbj(6,1,1,4,15,"学习")) {
			system("cls");
			study = learn_subject();
			system("cls");
			study_process(study);
			system("cls");
			Sleep(100);
		}
		// 在主循环的按钮部分添加
		if(pdbj(7,1,1,8,15,"银行服务")) {
			system("cls");
			bank();
			system("cls");
			Sleep(100);
		}

		// 在主循环的按钮部分添加
		if(pdbj(8,1,1,8,15,"保存游戏")) {
			saveGame();
			Sleep(1000);
			system("cls");
		}

	}
	system("cls");
	cout<<"你破产了,流浪街头……";
	return 0;
}