跳到正文

个人记录

OI教练模拟器[持续更新中]

_auto_约 14 分钟
原文

这是 2026年2月7日 存档的第 2 版,不是当前版本。查看当前版本

文章信息与版本
C++
// Copyright (C) since 2026 _auto_ / hwz007
// All rights reserved

// 编译系统要求 G++17 及以上,Windows 系统
// ( 游戏里有豪玩的彩蛋 )

#include<bits/stdc++.h>
#define endl '\n'
#include<windows.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

struct _OIer{
	string name, happy;	
	int good;
};
vector<_OIer> OIer;
int MONEY;

void mycls(string s = ""){
	system("cls");
}

void NoworkVoid(string s){
	return;
}

int NoworkInt(string s){
	return 0;
}

bool checkJ(string s, string t, void work(string s)){
	cout << s << endl;
	string c; cin >> c;
	work(c);
	return t == "ALL" || c == t;
}

int checkJ(string s, string t, int work(string s)){
	cout << s << endl;
	string c; cin >> c;
	return work(c);
}

void printH(string s, int del){
	for(auto x : s){
		cout << x;
		Sleep(del);
	}	
}

void GameOver(string rea){
	cout << endl;
	if(rea == "student"){
		printH("你没有了学员\n\n游戏结束 !!", 100);
		cout << endl;
	}
	if(rea == "money"){
		printH("你破产了\n\n游戏结束 !!", 100);
		cout << endl;
	}
	if(rea == "colourEgg"){
		printH("[彩蛋]\n\n因为你的刷钱行为,遭到了神秘喵的制裁,你失败了喵~\n\n游戏结束喵~", 100);
		cout << endl; 
	}
	exit(0);
}

void AFO(string name){
	cout << name << " 因为压力过大而退役" << endl << endl;
	vector<_OIer> newOIer;
	for(auto [x, y, z] : OIer){
		if(x != name) newOIer.push_back({x, y, z});
	}
	OIer = newOIer;
	if(OIer.empty()){
		GameOver("student");
	}
}

string nxtHappy(string x, string name){
	if(x == "低") return "中";
	if(x == "中") return "高";
	if(x == "高") return "极高";
	if(x == "极高") return "爆表";
	return "";
}

string nxtLowHappy(string x){
	if(x == "低") return "低";
	if(x == "中") return "低";
	if(x == "高") return "中";
	if(x == "极高") return "高";
	return "";	
}

string changeHappy(string x, int y, string name){
	while(y > 100){
		x = changeHappy(x, 100, name);
		y -= 100;
	}
	int rnd = rand() % 100 + 1;
	if(rnd <= y){
		x = nxtHappy(x, name);
	}
	return x;
}

string changeLowHappy(string x, int y){
	while(y > 100){
		changeLowHappy(x, 100);
		y -= 100;
	} 
	int rnd = rand() % 100 + 1;
	if(rnd <= y){
		x = nxtLowHappy(x); 
	}	
	return x;
}

int changeGood(int x, int y){
	int rnd = rand() % 3 + 1;
	return x + y * rnd;
}

void checkHappy(){
	while(true){
		bool flag = false;
		for(auto [x, y, z] : OIer){
			if(y == "爆表"){
				flag = true, AFO(x);
				Sleep(300);
				break; 
			}
		}
		if(!flag) break;
	}
} 

void checkMoney(){
	if(MONEY < 0){
		GameOver("money");	
	}
}

void checkOver(){
	checkMoney();
	checkHappy();
}

int checkPro(string s){
	if(s == "1") return 1;
	if(s == "2") return 2;
	if(s == "3") return 3;	
	if(s == "4") return 4;
	if(s == "5") return 5;
	if(s == "6") return 6;
	if(s == "7") return 7;
	return 0;
}

int calcProN(int x){
	if(x == 1) return 10;
	if(x == 2) return 30;
	if(x == 3) return 50;
	if(x == 4) return 70;
	if(x == 5) return 90;
	if(x == 6) return 110;
	if(x == 7) return 130;
	return 0;
}

int calcProG(int x){
	if(x == 1) return 5;
	if(x == 2) return 10;
	if(x == 3) return 15;
	if(x == 4) return 20;
	if(x == 5) return 25;
	if(x == 6) return 30;
	if(x == 7) return 35;	
	return 0;
}

void Xun(){
	mycls();
	int cho = checkJ("请选择题目难度 : \n1.入门  2.普及-  3.普及/提高-  4.普及+/提高  5.提高+/省选-  6.省选/NOI-  7.NOI/NOI+/CTSC", "ALL", checkPro);
	int ProN = calcProN(cho), ProG = calcProG(cho);
	mycls();
	for(int i = 1; i <= 6; i++){
		cout << "训练中";
		for(int j = 1; j <= i % 3 + 1; j++){
			cout << ".";
		}
		cout << endl;
		Sleep(300);
		mycls();
	}
	cout << "训练完成 !" << endl << endl;
	cout << "训练结果 :" << endl << endl;
	cout << "经费 : " << MONEY << " -> " << (MONEY -= 1000) << endl << endl;
	Sleep(500); 
	for(int i = 0; i < OIer.size(); i++){
		auto [x, y, z] = OIer[i];
		cout << x << "  压力 : " << OIer[i].happy << " -> " << (OIer[i].happy = changeHappy(y, ProN, x)) << "  能力 : " << OIer[i].good << " -> " << (OIer[i].good = changeGood(z, ProG)) << endl << endl;
		Sleep(200);
	}
	checkOver();
	checkJ("( 输入任意字符以确认 )", "ALL", mycls);
}

void Ji(){
	mycls();
	int newMoney = MONEY;
	vector<_OIer> bx; 
	for(auto [x, y, z] : OIer){
		cout << "请选择参加集训的人员 : " << endl << endl;
		cout << "你希望 " << x << " 参加集训吗 ( 希望请输入 'Y' [区分大小写])  预计剩余经费 : " << MONEY << " -> " << newMoney - 10000 << endl;
		if(checkJ("", "Y", NoworkVoid)){
			newMoney -= 10000;
			bx.push_back({x, y, z});
		} 
	}
	mycls();
	for(int i = 1; i <= 6; i++){
		cout << "集训中";
		for(int j = 1; j <= i % 3 + 1; j++){
			cout << ".";
		}
		cout << endl;
		Sleep(300);
		mycls();
	}
	cout << "集训完成 !" << endl << endl;
	cout << "集训结果 :" << endl << endl;
	cout << "经费 : " << MONEY << " -> " << (MONEY = newMoney) << endl << endl;
	Sleep(500);
	for(auto [x, y, z] : bx){
		for(int i = 0; i < OIer.size(); i++){
			if(OIer[i].name != x) continue;
			if(OIer[i].happy != "极高"){
				cout << x << "  压力 : " << y << " -> " << (OIer[i].happy = "极高") << "  能力 : " << z << " -> " << (OIer[i].good = changeGood(z, 50)) << endl << endl;
			}else{
				cout << x << "  压力 : " << y << " -> " << (OIer[i].happy = "爆表") << "  能力 : " << z << " -> " << (OIer[i].good = changeGood(z, 50)) << endl << endl;
			}
			Sleep(200);
			break; 
		}
	}
	checkOver();
	checkJ("( 输入任意字符以确认 )", "ALL", mycls);
}

void Bi(){
	mycls();
	//---------------
	GameOver("colourEgg");
	//---------------
	cout << "功能仍在开发中哟~" << endl << endl;
	checkJ("( 输入任意字符以确认 )", "ALL", mycls);
}

void Yu(){
	mycls();
	for(int i = 1; i <= 6; i++){
		cout << "娱乐中";
		for(int j = 1; j <= i % 3 + 1; j++){
			cout << ".";
		}
		cout << endl;
		Sleep(300);
		mycls();
	}
	cout << "娱乐完成 !" << endl << endl;
	cout << "娱乐结果 :" << endl;
	for(int i = 0; i < OIer.size(); i++){
		auto [x, y, z] = OIer[i];
		cout << x << "  压力 : " << OIer[i].happy << " -> " << (OIer[i].happy = changeLowHappy(y, 120)) << endl << endl; 
		Sleep(200);
	}
	checkJ("( 输入任意字符以确认 )", "ALL", mycls);
}

void checkit(string s){
	if(s == "1") Xun();
	if(s == "2") Ji();
	if(s == "3") Bi();
	if(s == "4") Yu();
}

void PrintTime(int week){
	cout << "第 " << week << " 周" << endl << endl;
}

void PrintMoney(){
	cout << "                  经费 : " << MONEY << " $" << endl << endl;	
}

void PrintOIer(){
	for(auto [x, y, z] : OIer){
		cout << x << "  压力 : " << y << "  能力 : " << z << endl << endl;
	} 
}

void InitMoney(){
	MONEY = 50000;
}

void InitOIer(){
	OIer.push_back({"周康阳", "低", 100});
	OIer.push_back({"许琪文", "低", 100});
	OIer.push_back({"蒋凌宇", "低", 100});
	OIer.push_back({"邓明扬", "低", 100});
}

void Init(){
	InitMoney();
	InitOIer();
}

void Print(int WEEK){
	mycls();
	PrintTime(WEEK);
	PrintMoney();
	PrintOIer();
}

void GetMoney(int x){
	MONEY += x;	
}

void GameLoop(int WEEK){
	Print(WEEK);
	if(MONEY > 10000){
		checkJ("请选择:\n1.训练 (-1000 $)  2.集训 (-10000 ~ " + to_string(MONEY) + " $)  3.比赛(开发中)  4.娱乐", "ALL", checkit);
	}else{
		checkJ("请选择:\n1.训练 (-1000 $)  2.集训 (-10000 $)  3.比赛(开发中)  4.娱乐", "ALL", checkit);
	}
	GetMoney(1000);
}

void Story(){
	printH("[背景故事]  你是一名 OI 教练...", 100);
	cout << endl << endl;
	checkJ("( 输入任意字符以确认 )", "ALL", mycls);
}

int main(){
	srand(time(0));
	cout << "Welcome to OI 教 练 模 拟 器" << endl;
	cout << endl;
	checkJ("输入任意字符以开始游戏", "ALL", mycls);
	Story();
	Init();
	int WEEK = 0;
	while(++WEEK) GameLoop(WEEK); 
    return 0;
}