#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cstdio> // 用于清屏函数
using namespace std;
// 清屏函数,根据不同操作系统执行相应命令
void clearScreen() {
#ifdef _WIN32
system("cls"); // Windows系统清屏命令
#else
system("clear"); // Linux/Mac系统清屏命令
#endif
}
// OIer角色类
class OIer {
private:
string name;
int day;
int programming; // 编程能力
int algorithm; // 算法能力
int math; // 数学基础
int stamina; // 体力
int happiness; // 幸福感
int homework; // 作业量
int popularity; // 人气值
int discipline; // 纪律分
int teacherFavor; // 老师好感度
int dormManagerFavor; // 宿管大妈好感度
bool isSick; // 是否生病
int contestCount; // 参加比赛次数
int winCount; // 获奖次数
int codeWriting; // 手写代码熟练度
int dataStructures;// 数据结构能力
int dpSkill; // 动态规划技巧
int friendship; // 与陈熹的友谊值
int seniorFavor; // 与学长的关系(可能为负,表示敌对)
public:
// 构造函数
OIer(string n) : name(n), day(1),
programming(30), algorithm(20), math(40),
stamina(100), happiness(70), homework(30),
popularity(50), discipline(80), teacherFavor(50),
dormManagerFavor(50), // 宿管大妈初始好感度
isSick(false), contestCount(0), winCount(0),
codeWriting(20), dataStructures(30), dpSkill(25),
friendship(0), seniorFavor(0) {}
// 从存档加载的构造函数
OIer(string n, int d, int p, int a, int m, int s, int h, int hw, int pop,
int disc, int tf, int dm, bool sick, int cc, int wc, int cw, int ds, int dps, int fr, int sf)
: name(n), day(d), programming(p), algorithm(a), math(m),
stamina(s), happiness(h), homework(hw), popularity(pop),
discipline(disc), teacherFavor(tf), dormManagerFavor(dm), // 宿管大妈好感度
isSick(sick), contestCount(cc), winCount(wc),
codeWriting(cw), dataStructures(ds), dpSkill(dps),
friendship(fr), seniorFavor(sf) {}
// 获取属性值(新增宿管大妈好感度的getter)
int getDay() const { return day; }
string getName() const { return name; }
int getProgramming() const { return programming; }
int getAlgorithm() const { return algorithm; }
int getMath() const { return math; }
int getStamina() const { return stamina; }
int getHappiness() const { return happiness; }
int getHomework() const { return homework; }
int getPopularity() const { return popularity; }
int getDiscipline() const { return discipline; }
int getTeacherFavor() const { return teacherFavor; }
int getDormManagerFavor() const { return dormManagerFavor; } // 新增
bool getIsSick() const { return isSick; }
int getContestCount() const { return contestCount; }
int getWinCount() const { return winCount; }
int getCodeWriting() const { return codeWriting; }
int getDataStructures() const { return dataStructures; }
int getDpSkill() const { return dpSkill; }
int getFriendship() const { return friendship; }
int getSeniorFavor() const { return seniorFavor; }
// 更新属性值,确保在合理范围内
void updateStat(int &stat, int value) {
stat += value;
if (stat < 0) stat = 0;
if (stat > 100) stat = 100;
}
// 更新可以为负的属性值
void updateSignedStat(int &stat, int value) {
stat += value;
}
// 新的一天
void nextDay() {
day++;
homework += rand() % 15 + 5; // 每天增加作业
if (homework > 100) homework = 100;
// 陈熹的恋情状态可能影响玩家
if (friendship > 50) {
// 和陈熹关系好时,可能会受到他恋情的影响
if (rand() % 10 == 0) {
cout << "[友情影响] 陈熹跟你分享了他和女友的甜蜜日常,让你也感到很开心!" << endl;
updateStat(happiness, 3);
} else if (rand() % 15 == 0) {
cout << "[友情影响] 陈熹因为异地恋的问题有些沮丧,让你也受到了点影响。" << endl;
updateStat(happiness, -2);
}
}
// 学长的暗中影响
if (seniorFavor < -30) {
// 关系极差时,学长可能暗中使绊子
if (rand() % 8 == 0) {
cout << "[暗中作梗] 你发现自己的代码草稿被人动过手脚,一些关键思路似乎不见了!" << endl;
updateStat(algorithm, -5);
updateStat(happiness, -8);
}
} else if (seniorFavor > 50) {
// 关系很好时,学长可能暗中提供帮助
if (rand() % 12 == 0) {
cout << "[暗中帮助] 你发现桌上多了一份算法笔记,上面有学长标注的重点,很有帮助!" << endl;
updateStat(algorithm, 5);
updateStat(happiness, 3);
}
}
// 宿管大妈的日常检查
if (rand() % 10 == 0) { // 10%概率触发宿管检查
handleDormManagerCheck();
}
// 随机事件判定
checkRandomEvent();
// 检查是否生病
if (stamina < 20 && rand() % 5 == 0) {
isSick = true;
cout << "糟糕!" << name << "因为过度劳累生病了,今天状态会很差。" << endl;
} else if (isSick && stamina > 60) {
isSick = false;
cout << name << "的病好了,感觉充满活力!" << endl;
}
// 每天纪律分和老师好感度小幅恢复
if (discipline < 100) {
updateStat(discipline, 1);
}
if (teacherFavor < 100) {
updateStat(teacherFavor, 1);
}
// 宿管大妈好感度小幅恢复
if (dormManagerFavor < 100) {
updateStat(dormManagerFavor, 1);
}
}
// 宿管大妈检查宿舍
void handleDormManagerCheck() {
cout << endl << "[宿管检查] 爱管闲事的宿管大妈突然来检查宿舍:";
// 根据当前宿舍状态和宿管好感度触发不同事件
if (rand() % 4 == 0) { // 检查卫生
cout << "\"你们宿舍卫生怎么回事?这垃圾都没倒!\"";
// 随机判定宿舍卫生状况
bool clean = (rand() % 100) < 60; // 60%概率卫生状况良好
if (clean) {
cout << "还好你的区域很干净,大妈表扬了你。" << endl;
updateStat(dormManagerFavor, 5);
updateStat(discipline, 3);
} else {
if (dormManagerFavor > 70) {
cout << "大妈看在平时你表现不错的份上,只是让你赶紧打扫。" << endl;
updateStat(dormManagerFavor, -2);
} else {
cout << "大妈把你的名字记在了违纪本上,还要告诉你的班主任!" << endl;
updateStat(dormManagerFavor, -10);
updateStat(discipline, -8);
updateStat(teacherFavor, -5); // 影响老师好感度
}
}
}
else if (rand() % 4 == 1) { // 检查违规电器
cout << "\"有没有人用违规电器?我可闻到泡面味了!\"";
// 如果你和刘志远关系好,可能被牵连
bool hasDevice = (friendship > 50 && rand() % 3 == 0) || (rand() % 10 == 0);
if (hasDevice) {
if (dormManagerFavor > 60) {
cout << "大妈看了你一眼,低声说:\"下次注意点,赶紧收起来。\"" << endl;
updateStat(dormManagerFavor, -5);
updateStat(happiness, -3);
} else {
cout << "大妈在你桌上发现了违规的小煮锅,当场没收并上报学校!" << endl;
updateStat(dormManagerFavor, -15);
updateStat(discipline, -15);
updateStat(teacherFavor, -10);
updateStat(happiness, -10);
}
} else {
cout << "你的桌上很干净,大妈满意地点点头离开了。" << endl;
updateStat(dormManagerFavor, 3);
updateStat(happiness, 2);
}
}
else if (rand() % 4 == 2) { // 检查晚归
cout << "\"昨晚谁又晚归了?我可是记了名字的!\"";
// 如果你昨晚玩游戏了,可能被抓
bool late = (homework > 70 && rand() % 3 == 0) || (rand() % 10 == 0);
if (late) {
cout << "大妈认出了你,批评你不按时归宿影响休息。" << endl;
updateStat(dormManagerFavor, -8);
updateStat(discipline, -5);
updateStat(stamina, -5); // 影响第二天体力
} else {
cout << "还好你一直按时作息,大妈没说什么就走了。" << endl;
updateStat(dormManagerFavor, 2);
}
}
else { // 闲聊和关心
cout << "\"同学啊,最近看你经常熬夜,要注意身体啊,学习再忙也要休息好。\"";
if (isSick) {
cout << "她还从口袋里拿出了感冒药给你。" << endl;
updateStat(dormManagerFavor, 8);
updateStat(stamina, 15);
updateStat(happiness, 5);
isSick = false; // 吃了药病好了
} else if (stamina < 30) {
cout << "她建议你今天早点休息,别太累了。" << endl;
updateStat(dormManagerFavor, 5);
updateStat(stamina, 10);
} else {
cout << endl;
updateStat(dormManagerFavor, 2);
}
}
}
// 与宿管大妈互动(帮忙或被刁难)
void interactWithDormManager() {
cout << endl << "[宿管互动] 你主动和宿管大妈打了招呼。";
if (dormManagerFavor < 30) {
cout << "但她对你态度冷淡,显然对你印象不好。" << endl;
updateStat(dormManagerFavor, -2);
updateStat(happiness, -3);
return;
}
int event = rand() % 3;
if (event == 0) { // 大妈需要帮忙
cout << "她正提着一大袋东西,看起来很沉。" << endl;
cout << "是否愿意帮忙?(1-帮忙 0-拒绝): ";
int choice;
cin >> choice;
if (choice == 1) {
cout << "你帮大妈把东西送到了办公室,她很感激,还跟你聊了几句家常。" << endl;
updateStat(dormManagerFavor, 10);
updateStat(popularity, 3); // 被其他同学看到
updateStat(stamina, -10);
updateStat(happiness, 5);
// 有几率获得特殊信息
if (rand() % 5 == 0) {
cout << "大妈悄悄告诉你:\"下周要检查宿舍卫生,提前准备一下。\"" << endl;
updateStat(discipline, 5);
}
} else {
cout << "你找借口溜走了,大妈有点不高兴。" << endl;
updateStat(dormManagerFavor, -8);
updateStat(happiness, -2);
}
}
else if (event == 1) { // 大妈抱怨其他学生
cout << "她开始抱怨有些学生不遵守宿舍规定,晚上吵闹影响别人休息。" << endl;
if (discipline > 70) {
cout << "她表扬你是个遵守纪律的好学生,还说要向老师夸奖你。" << endl;
updateStat(dormManagerFavor, 8);
updateStat(teacherFavor, 5);
updateStat(happiness, 5);
} else {
cout << "她意有所指地看了你几眼,让你有点不自在。" << endl;
updateStat(dormManagerFavor, 2);
updateStat(discipline, 3); // 提醒你要守纪律
}
}
else { // 大妈分享零食或故事
cout << "她心情很好,从口袋里拿出一些零食给你,还跟你讲了她孩子的学习故事。" << endl;
cout << "她的孩子也曾参加过信息学竞赛,给了你一些宝贵的建议。" << endl;
updateStat(dormManagerFavor, 5);
updateStat(happiness, 8);
updateStat(algorithm, 3); // 获得一些竞赛建议
updateStat(stamina, 5); // 吃了点零食恢复体力
// 有几率获得关于学长的信息
if (seniorFavor != 0 && rand() % 4 == 0) {
cout << "大妈还提到:\"那个高年级的同学以前也住这个宿舍,他啊..." << endl;
if (seniorFavor > 0) {
cout << "学习很刻苦,就是不太爱说话。\"" << endl;
updateSignedStat(seniorFavor, 3);
} else {
cout << "以前经常违反宿舍规定,被我批评过好几次。\"" << endl;
updateStat(happiness, 3);
}
}
}
}
// 林老师互动事件
void handleTeacherInteraction() {
cout << endl << "[林老师互动] ";
int randEvent = rand() % 6;
// 如果和学长关系差,可能被学长告状
if (seniorFavor < -40 && rand() % 5 == 0) {
cout << "林老师严肃地说:\"有学长反映你最近态度不端正,作业也是抄的,是真的吗?\"" << endl;
updateStat(teacherFavor, -10);
updateStat(discipline, -8);
return;
}
// 如果和陈熹关系好,可能会被老师一起说教
if (friendship > 60 && rand() % 4 == 0) {
cout << "林老师对你说:\"你最近和陈熹走得很近,他上课总玩手机聊天,你可别学他!\"" << endl;
updateStat(teacherFavor, -5);
updateStat(discipline, -3);
return;
}
// 宿管大妈告状
if (dormManagerFavor < 20 && rand() % 6 == 0) {
cout << "林老师找你谈话:\"宿管大妈反映你不遵守宿舍规定,这影响很不好!\"" << endl;
updateStat(teacherFavor, -8);
updateStat(discipline, -6);
return;
}
// 根据老师好感度和玩家状态触发不同事件
if (randEvent == 0) { // 检查作业
cout << "林老师走到你身边,检查了你的作业。";
if (homework < 30) {
cout << "他满意地点点头:\"作业完成得很及时,继续保持!\"" << endl;
updateStat(teacherFavor, 5);
updateStat(algorithm, 3);
updateStat(happiness, 5);
} else if (homework < 70) {
cout << "他皱了皱眉:\"还有不少作业没完成,要抓紧时间了。\"" << endl;
updateStat(teacherFavor, -2);
updateStat(happiness, -3);
} else {
cout << "他严肃地批评道:\"作业堆积太多了!这样可不行,今天必须补完!\"" << endl;
updateStat(teacherFavor, -8);
updateStat(discipline, -5);
updateStat(happiness, -10);
updateStat(homework, -30); // 强制完成部分作业
}
}
else if (randEvent == 1) { // 讲解题目
cout << "林老师看到你在做题,过来给你讲解了一种更优的解法。";
if (teacherFavor > 70) {
cout << "他还分享了一些竞赛技巧,让你受益匪浅!" << endl;
updateStat(algorithm, 10);
updateStat(math, 7);
updateStat(teacherFavor, 3);
} else if (teacherFavor > 30) {
cout << "清晰的讲解让你茅塞顿开。" << endl;
updateStat(algorithm, 6);
updateStat(math, 4);
} else {
cout << "虽然讲解很专业,但你感觉有些距离感。" << endl;
updateStat(algorithm, 3);
}
updateStat(stamina, -5); // 认真听讲消耗少量体力
}
else if (randEvent == 2) { // 纪律检查
cout << "林老师巡视时发现了你";
if (discipline < 50) {
cout << ",严厉地警告你:\"最近纪律不太好,再这样就要通知家长了!\"" << endl;
updateStat(discipline, -10);
updateStat(teacherFavor, -15);
updateStat(happiness, -10);
} else if (discipline > 80) {
cout << ",赞许地说:\"不错,纪律性很强,值得大家学习。\"" << endl;
updateStat(discipline, 5);
updateStat(teacherFavor, 8);
updateStat(popularity, 3); // 被表扬提升人气
} else {
cout << ",提醒道:\"上课要更专注一些,不要做与学习无关的事。\"" << endl;
updateStat(discipline, 2);
}
}
else if (randEvent == 3) { // 关心健康
cout << "林老师注意到你";
if (isSick) {
cout << "脸色不好,关切地说:\"身体不舒服就先休息,健康比什么都重要。\"" << endl;
updateStat(stamina, 20);
updateStat(teacherFavor, 5);
updateStat(happiness, 8);
isSick = false; // 老师关心后病好了
} else if (stamina < 30) {
cout << "看起来很疲惫:\"不要熬夜太晚,合理安排时间才能提高效率。\"" << endl;
updateStat(stamina, 10);
updateStat(teacherFavor, 3);
} else {
cout << "精神状态很好:\"保持这种状态,继续努力,我很看好你。\"" << endl;
updateStat(happiness, 5);
updateStat(teacherFavor, 2);
}
}
else if (randEvent == 4) { // 关于上课使用手机
cout << "林老师在班会上强调:\"有些同学上课还在玩手机聊天,这是严重影响学习的行为!\"";
if (friendship > 70) {
cout << "你感觉老师意有所指地看了陈熹一眼,也扫了你一下。" << endl;
updateStat(discipline, -2);
} else {
cout << "大家都知道老师说的是谁,纷纷看向陈熹。" << endl;
}
updateStat(teacherFavor, -1);
}
else if (randEvent == 5) { // 关于学长的评价
cout << "林老师提到:\"高年级的学长经验丰富,你们有问题可以请教,但也要有自己的判断。\"";
if (seniorFavor > 30) {
cout << "你想起了帮助过你的学长,很认同老师的话。" << endl;
updateSignedStat(seniorFavor, 2);
} else if (seniorFavor < -30) {
cout << "你想起了那位总找你麻烦的学长,默默点了点头。" << endl;
updateStat(happiness, -2);
} else {
cout << endl;
}
}
}
// 阴险狡诈的学长互动
void handleSeniorInteraction() {
cout << endl << "[学长互动] ";
int randEvent = rand() % 5;
// 根据当前关系状态,互动方式会有不同
if (seniorFavor < -50) {
// 关系极差时,学长会直接敌对
cout << "学长看到你,故意撞了你一下,把你的书本撞掉在地:\"走路不长眼睛吗?\"" << endl;
updateSignedStat(seniorFavor, -5);
updateStat(happiness, -10);
updateStat(popularity, -3);
return;
}
// 学长的五种互动方式,体现其阴险狡诈的特点
if (randEvent == 0) { // 假意帮助,实则误导
cout << "学长假惺惺地走过来说:\"我看你在做这道题,我知道一个简便解法,不过有点复杂...\"";
bool isMislead = (rand() % 100) < 70; // 70%概率被误导
if (isMislead) {
cout << "他给你讲了一个看似巧妙实则错误的解法,让你走了不少弯路。" << endl;
updateSignedStat(seniorFavor, 2); // 表面上关系略有提升
updateStat(algorithm, -4);
updateStat(math, -3);
updateStat(homework, 10); // 浪费了时间
updateStat(stamina, -10);
} else {
cout << "你发现他的解法有问题,指出后他脸色一变,匆匆离开了。" << endl;
updateSignedStat(seniorFavor, -8);
updateStat(algorithm, 3); // 自己找出了问题,有所收获
updateStat(happiness, -5);
}
}
else if (randEvent == 1) { // 炫耀并打压
cout << "学长拿着他的竞赛证书在你面前炫耀:\"这点小奖不算什么,不像某些人连参赛资格都没有。\"";
if (contestCount == 0) {
cout << "这话深深刺痛了你。" << endl;
updateSignedStat(seniorFavor, -5);
updateStat(happiness, -10);
} else if (winCount > 0) {
cout << "你拿出自己的获奖证书,他脸色很难看地走了。" << endl;
updateSignedStat(seniorFavor, -3);
updateStat(happiness, 5);
updateStat(popularity, 3); // 周围同学看到了这一幕
} else {
cout << "你没有回应,他觉得无趣就离开了。" << endl;
updateSignedStat(seniorFavor, -1);
updateStat(happiness, -3);
}
}
else if (randEvent == 2) { // 假意示好,实则试探
cout << "学长突然对你很热情:\"同学,我这里有份往年竞赛的内部资料,不过...\"";
int choice;
cout << "是否接受学长的'好意'?(1-接受 0-拒绝): ";
cin >> choice;
if (choice == 1) {
bool isTrap = (rand() % 100) < 60; // 60%概率是陷阱
if (isTrap) {
cout << "你接过资料,发现里面大部分是错误的,还被学长举报说你向他索要资料。" << endl;
updateSignedStat(seniorFavor, -10);
updateStat(teacherFavor, -15);
updateStat(discipline, -10);
updateStat(happiness, -15);
} else {
cout << "资料确实有些价值,但学长总向你打听老师的动向,让你很不舒服。" << endl;
updateSignedStat(seniorFavor, 5);
updateStat(algorithm, 5);
updateStat(happiness, -2);
}
} else {
cout << "你礼貌地拒绝了,学长的笑容僵在脸上,转身就走。" << endl;
updateSignedStat(seniorFavor, -3);
updateStat(happiness, 2);
}
}
else if (randEvent == 3) { // 竞争与破坏
cout << "你和学长都报名参加了同一个竞赛,他找到你说:\"这次竞赛名额有限,不如你退出吧?\"";
int choice;
cout << "是否同意退出?(1-同意 0-拒绝): ";
cin >> choice;
if (choice == 1) {
cout << "你同意退出,学长假惺惺地感谢你,但背后却说你实力不足不敢参赛。" << endl;
updateSignedStat(seniorFavor, 8);
updateStat(popularity, -8);
updateStat(happiness, -10);
updateStat(algorithm, -5);
} else {
cout << "你拒绝退出,学长冷笑一声:\"走着瞧。\"之后你发现自己的备赛资料不见了。" << endl;
updateSignedStat(seniorFavor, -15);
updateStat(algorithm, -3);
updateStat(happiness, -8);
updateStat(stamina, 5); // 被激怒,反而更有动力
}
}
else if (randEvent == 4) { // 见风使舵(当玩家表现好时)
if (winCount >= 3 || programming >= 70) {
cout << "学长突然对你态度大变:\"哎呀,没想到你这么厉害!以前是我不对,多包涵。\"";
bool accept = (rand() % 100) < 50; // 50%概率接受道歉
if (accept) {
cout << "你接受了他的道歉,他似乎真的想改善关系。" << endl;
updateSignedStat(seniorFavor, 20);
updateStat(happiness, 5);
updateStat(popularity, 3);
} else {
cout << "你冷淡地回应,他讨了个没趣,悻悻离开。" << endl;
updateSignedStat(seniorFavor, -5);
updateStat(happiness, -2);
}
} else {
// 玩家表现一般时,继续嘲讽
cout << "学长看到你在刷题,嘲讽道:\"这种基础题还要练这么久?真是浪费时间。\"" << endl;
updateSignedStat(seniorFavor, -5);
updateStat(happiness, -5);
if (algorithm > 50) {
updateStat(algorithm, 2); // 有实力的玩家会被激发出斗志
}
}
}
}
// 同学求助事件处理
void handleClassmateHelp(int classmate) {
cout << endl << "[同学互动] ";
bool helped = (rand() % 100) < 70; // 70%概率选择帮忙
if (classmate == 0) { // 丢三落四的黄俊杰
cout << "黄俊杰急急忙忙地跑来:\"我的U盘不见了!你能帮我找找吗?\"" << endl;
if (helped) {
cout << "你帮黄俊杰在机房角落找到了U盘,他非常感激!" << endl;
updateStat(popularity, 5);
updateStat(happiness, 3);
updateStat(stamina, -8);
} else {
cout << "你今天太忙了,没能帮黄俊杰找U盘,他有点失望。" << endl;
updateStat(popularity, -3);
}
}
else if (classmate == 1) { // 神犇钟品荣
cout << "钟品荣拿着一道难题问你:\"这道题的最优解思路我有点想法,你要不要一起讨论?\"" << endl;
if (helped) {
cout << "和钟品荣讨论后你豁然开朗,算法能力有所提升!" << endl;
updateStat(algorithm, 7);
updateStat(popularity, 3);
updateStat(stamina, -12);
} else {
cout << "你婉拒了钟品荣的讨论邀请,错过了一次学习机会。" << endl;
updateStat(algorithm, -2);
}
}
else if (classmate == 2) { // 猫娘钟思睿
cout << "钟思睿带着猫咪玩偶问你:\"你看我的新玩偶可爱吗?对了,能教我这个语法吗?\"" << endl;
if (helped) {
cout << "你耐心教了钟思睿语法知识,自己也加深了理解,编程能力提升了!" << endl;
updateStat(programming, 6);
updateStat(happiness, 8);
updateStat(stamina, -5);
} else {
cout << "你没时间教钟思睿,她看起来有点难过。" << endl;
updateStat(happiness, -5);
updateStat(popularity, -2);
}
}
else if (classmate == 3) { // 音游人张柏鑫
cout << "张柏鑫戴着耳机对你说:\"我发现一首超带感的音乐!不过这道题的循环写不对,帮我看看?\"" << endl;
if (helped) {
cout << "你帮张柏鑫解决了循环问题,他分享了好听的音乐给你,幸福感大增!" << endl;
updateStat(codeWriting, 5);
updateStat(happiness, 10);
updateStat(stamina, -6);
} else {
cout << "你没帮张柏鑫看代码,他只好自己琢磨了。" << endl;
updateStat(popularity, -1);
}
}
else if (classmate == 4) { // 豌豆黄(并查集仙人,喜欢florr)
cout << "豌豆黄拿着笔记本电脑走过来说:\"我用并查集优化了florr的游戏逻辑,你要不要看看?顺便帮我测试下?\"" << endl;
if (helped) {
cout << "你帮豌豆黄测试了游戏,还学会了并查集的高级用法,数据结构能力大幅提升!" << endl;
updateStat(dataStructures, 10);
updateStat(algorithm, 5);
updateStat(happiness, 7);
updateStat(stamina, -10);
} else {
cout << "你没时间帮豌豆黄测试,错过了学习并查集技巧的机会。" << endl;
updateStat(dataStructures, -3);
updateStat(happiness, -2);
}
}
else if (classmate == 5) { // 刘志远(喜欢玩游戏,容易被抓)
cout << "刘志远偷偷摸摸地对你说:\"快!来我宿舍,我找到个超好玩的新游戏,就玩10分钟!\"" << endl;
if (helped) {
// 帮忙有风险,可能被抓
bool caught = (rand() % 100) < 40; // 40%概率被抓
// 宿管好感度低时更容易被抓
if (dormManagerFavor < 40) {
caught = (rand() % 100) < 60; // 60%概率被抓
}
if (caught) {
cout << "突然宿管大妈进来了!你们被抓了个正着,被严厉批评了一顿!" << endl;
updateStat(discipline, -30);
updateStat(teacherFavor, -25);
updateStat(dormManagerFavor, -20); // 大幅降低宿管好感度
updateStat(happiness, -15);
updateStat(popularity, 5);
} else {
cout << "太刺激了!你们玩得很开心,没被发现!" << endl;
updateStat(happiness, 25);
updateStat(stamina, -15);
updateStat(popularity, 8);
updateStat(homework, 10);
}
} else {
cout << "你拒绝了刘志远的邀请,他只好找别人了。" << endl;
updateStat(popularity, -5);
updateStat(happiness, -3);
}
}
else if (classmate == 6) { // 神犇梁意驰(杠精)
cout << "梁意驰看到你在学习,走过来说:\"你这方法也太落后了吧?这种效率的算法也值得学?\"" << endl;
if (helped) {
// 与杠精争论有两种可能结果
bool winArgue = (rand() % 100) < 40; // 40%概率在争论中占上风
if (winArgue) {
cout << "你据理力争,指出了他观点中的漏洞,梁意驰虽然嘴上不服但也没话说了。你对算法的理解更深刻了!" << endl;
updateStat(algorithm, 12);
updateStat(math, 8);
updateStat(happiness, 5);
updateStat(stamina, -18);
} else {
cout << "梁意驰滔滔不绝地指出你的各种不足,虽然很刺耳,但确实说到了点子上。" << endl;
updateStat(algorithm, 6);
updateStat(happiness, -10);
updateStat(stamina, -15);
}
} else {
cout << "你懒得跟他争辩,转身继续学习。梁意驰嘟囔了几句\"果然理解不了\"就走了。" << endl;
updateStat(happiness, -3);
updateStat(algorithm, -1);
}
}
else if (classmate == 7) { // dp魔怔了的李丰亦
cout << "李丰亦双眼通红地抓住你:\"我终于想通了!这道题可以用三维DP优化到O(n2)!你看这个状态转移方程...\"";
if (helped) {
// 李丰亦的互动有三种可能结果,体现他"魔怔"的特点
int interactionType = rand() % 3;
if (interactionType == 0) { // 有价值的讨论
cout << "经过深入讨论,你理解了这个DP优化的精髓,动态规划能力大幅提升!" << endl;
updateStat(dpSkill, 15);
updateStat(algorithm, 8);
updateStat(math, 6);
updateStat(happiness, 5);
updateStat(stamina, -20); // 消耗大量体力
} else if (interactionType == 1) { // 陷入误区
cout << "讨论到一半你发现他的思路有严重错误,但花了很久才理清,有点浪费时间。" << endl;
updateStat(dpSkill, 3);
updateStat(algorithm, 2);
updateStat(happiness, -5);
updateStat(homework, 10); // 耽误了写作业
updateStat(stamina, -15);
} else { // 魔怔状态
cout << "他越说越激动,从DP讲到哲学,最后你完全听不懂了,感觉精神受到了污染。" << endl;
updateStat(dpSkill, 5); // 还是学到一点东西
updateStat(happiness, -10);
updateStat(discipline, -3); // 上课时间讨论被老师看到
updateStat(teacherFavor, -2);
updateStat(stamina, -12);
}
} else {
cout << "你借口要去洗手间溜走了,回头看到他还在对着空气比划状态转移方程。" << endl;
updateStat(popularity, -4);
updateStat(dpSkill, -2); // 错过学习DP的机会
}
}
else if (classmate == 8) { // 坠入爱河的陈熹(男,有异地恋女友)
// 陈熹经常在聊天,互动场景与手机相关
int chatStatus = rand() % 3; // 三种聊天状态
if (chatStatus == 0) { // 刚聊完很开心
cout << "陈熹笑着合上手机,对你说:\"我女朋友刚才说想我了,还给我发了她做的菜的照片,看起来超好吃!\"" << endl;
if (helped) {
cout << "你由衷地为他感到高兴,和他聊了几句异地恋的趣事。" << endl;
updateStat(friendship, 7);
updateStat(happiness, 5);
updateStat(popularity, 2);
updateStat(stamina, -5);
} else {
cout << "你只是敷衍地笑了笑,觉得他太沉迷恋爱了。" << endl;
updateStat(friendship, -3);
updateStat(happiness, -1);
}
}
else if (chatStatus == 1) { // 聊天遇到问题
cout << "陈熹皱着眉看着手机,对你说:\"唉,和女朋友有点小矛盾,她觉得我最近回复消息太慢了...你说我该怎么解释?\"" << endl;
if (helped) {
cout << "你耐心帮他分析情况,给他提了些建议。陈熹看起来安心多了。" << endl;
updateStat(friendship, 10);
updateStat(happiness, 3);
updateStat(stamina, -8);
// 帮人解决情感问题也能提升情商,间接提升人气
updateStat(popularity, 3);
} else {
cout << "你觉得这是他的私事,没好意思多管,就走开了。" << endl;
updateStat(friendship, -5);
updateStat(happiness, -2);
}
}
else { // 正在聊天被老师发现
cout << "陈熹上课偷偷玩手机聊天,突然被老师发现!他慌忙把手机塞给你:\"快帮我藏一下!千万别被没收了!\"" << endl;
if (helped) {
// 帮忙有风险
bool caught = (rand() % 100) < 35; // 35%概率被发现
if (caught) {
cout << "老师看到你手里的手机,严肃批评了你,还把手机没收了。陈熹很过意不去。" << endl;
updateStat(discipline, -15);
updateStat(teacherFavor, -20);
updateStat(friendship, 8); // 虽然被抓但帮了忙,友谊仍会增加
updateStat(happiness, -10);
} else {
cout << "你成功把手机藏了起来,躲过了老师的检查。陈熹对你感激不尽!" << endl;
updateStat(friendship, 15);
updateStat(happiness, 5);
updateStat(discipline, -5); // 做了违纪的事
}
} else {
cout << "你拒绝了陈熹的请求,他只好自己把手机藏起来,结果被老师发现没收了。他有点生气。" << endl;
updateStat(friendship, -12);
updateStat(popularity, -3);
updateStat(happiness, -3);
}
}
}
}
// 随机事件(添加宿管相关事件)
void checkRandomEvent() {
int eventProb = rand() % 65; // 增加事件总数
if (eventProb == 0) {
cout << "[随机事件] 发现了一本很棒的算法书,算法能力提升了!" << endl;
updateStat(algorithm, 8);
} else if (eventProb == 1) {
cout << "[随机事件] 电脑突然蓝屏,丢失了部分代码,心情变差了。" << endl;
updateStat(happiness, -15);
} else if (eventProb == 2) {
cout << "[随机事件] 老师表扬了你的代码,感觉很开心!" << endl;
updateStat(happiness, 10);
updateStat(programming, 3);
updateStat(teacherFavor, 3);
} else if (eventProb == 3) {
cout << "[随机事件] 参加了一次校际交流,开阔了眼界。" << endl;
updateStat(algorithm, 5);
updateStat(happiness, 5);
updateStat(stamina, -8);
} else if (eventProb == 4) {
cout << "[随机事件] 解出了一道困扰已久的难题,数学能力提升了!" << endl;
updateStat(math, 10);
updateStat(happiness, 15);
} else if (eventProb == 5) {
cout << "[随机事件] 熬夜写代码,体力大幅下降。" << endl;
updateStat(stamina, -20);
updateStat(programming, 5);
} else if (eventProb == 6) {
cout << "[随机事件] 参加了代码书写比赛,手写代码能力提升了!" << endl;
updateStat(codeWriting, 12);
updateStat(programming, 4);
} else if (eventProb == 7) {
cout << "[随机事件] 研究了数据结构教程,对并查集有了新理解!" << endl;
updateStat(dataStructures, 8);
updateStat(math, 3);
} else if (eventProb == 8) {
cout << "[随机事件] 上课认真听讲,纪律分提高了!" << endl;
updateStat(discipline, 10);
updateStat(algorithm, 2);
updateStat(teacherFavor, 5);
} else if (eventProb == 9) {
cout << "[随机事件] 参加了动态规划专项训练,对状态转移有了新的理解!" << endl;
updateStat(dpSkill, 10);
updateStat(algorithm, 5);
updateStat(math, 4);
} else if (eventProb == 10) { // 与陈熹相关的随机事件
if (friendship > 30) {
cout << "[随机事件] 陈熹兴高采烈地告诉你,他女朋友放假要来看他了,还给了你一袋喜糖。" << endl;
updateStat(happiness, 8);
updateStat(friendship, 5);
} else if (friendship < 20 && rand() % 2 == 0) {
cout << "[随机事件] 你看到陈熹上课又在偷偷和女朋友视频聊天,被老师点名批评了。" << endl;
if (rand() % 3 == 0) {
cout << "老师还问你:\"你怎么不提醒他?\"让你有点尴尬。" << endl;
updateStat(teacherFavor, -3);
}
}
} else if (eventProb == 11) { // 与学长相关的随机事件
if (seniorFavor > 40) {
cout << "[随机事件] 学长主动分享了一些竞赛经验,虽然有点保留,但还是很有用的。" << endl;
updateStat(algorithm, 5);
updateSignedStat(seniorFavor, 3);
} else if (seniorFavor < -40) {
cout << "[随机事件] 你发现学长在背后说你坏话,说你能力不行还总想着参加竞赛。" << endl;
updateStat(happiness, -8);
updateStat(popularity, -5);
updateSignedStat(seniorFavor, -5);
} else if (rand() % 2 == 0) {
cout << "[随机事件] 你看到学长在指导其他同学,方法确实很巧妙,但他对你视而不见。" << endl;
updateStat(algorithm, 2);
updateStat(happiness, -2);
}
} else if (eventProb == 12) { // 与宿管大妈相关的随机事件
if (dormManagerFavor > 70) {
cout << "[随机事件] 宿管大妈看到你学习到很晚,给你端来一杯热牛奶,让你注意休息。" << endl;
updateStat(stamina, 10);
updateStat(happiness, 8);
updateStat(dormManagerFavor, 3);
} else if (dormManagerFavor < 30) {
cout << "[随机事件] 宿管大妈在楼道里大声批评某些学生不遵守规定,你感觉是在说你。" << endl;
updateStat(happiness, -5);
updateStat(dormManagerFavor, -2);
}
}
// 同学互动事件(13-21对应九位同学)
else if (eventProb >= 13 && eventProb <= 21) {
handleClassmateHelp(eventProb - 13); // 0-8对应九位同学
}
// 学长互动事件(22-25)
else if (eventProb >= 22 && eventProb <= 25) {
handleSeniorInteraction();
}
// 林老师互动事件(26-29)
else if (eventProb >= 26 && eventProb <= 29) {
handleTeacherInteraction();
}
// 宿管大妈互动事件(30-32)
else if (eventProb >= 30 && eventProb <= 32) {
handleDormManagerCheck();
}
}
// 参加比赛
void participateContest() {
contestCount++;
cout << endl << "=== 参加了一场算法竞赛 ===" << endl;
// 纪律分过低会影响比赛资格
if (discipline < 40) {
cout << "由于纪律分太低,林老师不让你参加比赛,只能在场边观看。" << endl;
updateStat(happiness, -10);
updateStat(teacherFavor, -5);
return;
}
// 学长可能会在比赛中使绊子
bool seniorSabotage = false;
if (seniorFavor < -30 && rand() % 5 == 0) {
cout << "比赛前,学长'不小心'撞了你一下,你的准备笔记散落一地,有些混乱。" << endl;
seniorSabotage = true;
updateStat(happiness, -5);
}
// 陈熹的鼓励
int friendBonus = 0;
if (friendship > 60) {
cout << "比赛前陈熹给你发了消息:\"加油啊!等你好消息,赢了我请你吃饭!\"" << endl;
friendBonus = 5; // 好朋友的鼓励带来加成
}
// 老师好感度高会给予额外指导
int bonus = (teacherFavor > 70) ? 10 : 0;
// 学长的恶意影响
int seniorPenalty = seniorSabotage ? 15 : 0;
// 综合能力计算,加入各项能力影响
int totalAbility = programming + algorithm + math + codeWriting / 2 +
popularity / 5 + dataStructures / 3 + discipline / 10 +
dpSkill / 2 + bonus + friendBonus - seniorPenalty;
int successRate = totalAbility / 3;
if (rand() % 100 < successRate) {
winCount++;
cout << "恭喜!" << name << "在比赛中获奖了!" << endl;
cout << "林老师为你感到骄傲:\"我就知道你能行!\"" << endl;
// 获奖后陈熹的反应
if (friendship > 40) {
cout << "陈熹第一时间发来祝贺:\"太厉害了!早就知道你可以的,记得请客啊!\"" << endl;
updateStat(friendship, 8);
updateStat(happiness, 5);
}
// 获奖后学长的反应
if (seniorFavor < 0) {
cout << "学长脸色难看地走过,假装没看见你的奖状。" << endl;
updateSignedStat(seniorFavor, -5);
} else if (seniorFavor > 0) {
cout << "学长过来恭喜你,虽然有点勉强,但看起来还算真诚。" << endl;
updateSignedStat(seniorFavor, 3);
}
// 获奖后宿管大妈的反应
if (dormManagerFavor > 30) {
cout << "宿管大妈听说你获奖了,特意过来恭喜你,还说要告诉其他同学向你学习。" << endl;
updateStat(dormManagerFavor, 5);
updateStat(popularity, 3);
}
updateStat(programming, 10);
updateStat(algorithm, 10);
updateStat(happiness, 20);
updateStat(popularity, 8);
updateStat(discipline, 5);
updateStat(teacherFavor, 15);
updateStat(dpSkill, 5);
} else {
cout << "很遗憾,这次比赛没有获奖,但积累了宝贵经验。" << endl;
// 失利后陈熹的反应
if (friendship > 30) {
cout << "陈熹安慰你:\"没事的,下次再努力!晚上一起打场球放松下吧?\"" << endl;
updateStat(happiness, 5);
updateStat(friendship, 3);
}
// 失利后学长的反应
if (seniorFavor < 0 && rand() % 3 == 0) {
cout << "学长走过来说:\"早告诉你了,你还不够格参加这种比赛。\"" << endl;
updateStat(happiness, -5);
updateSignedStat(seniorFavor, -3);
}
if (teacherFavor > 50) {
cout << "林老师鼓励你:\"不要灰心,找出问题下次努力!\"" << endl;
updateStat(happiness, 5);
}
// 失利后宿管大妈的安慰
if (dormManagerFavor > 50) {
cout << "宿管大妈看到你情绪低落,安慰你说:\"一次失利不算什么,继续努力总会成功的。\"" << endl;
updateStat(happiness, 3);
}
updateStat(programming, 3);
updateStat(algorithm, 3);
updateStat(dpSkill, 2);
updateStat(happiness, -5);
}
updateStat(stamina, -30);
}
// 日常活动
void studyProgramming() {
int effect = isSick ? 3 : 8;
cout << name << "在专心学习编程。" << endl;
updateStat(programming, effect);
updateStat(stamina, -15);
updateStat(homework, 5);
}
void studyAlgorithm() {
int effect = isSick ? 2 : 7;
cout << name << "在钻研算法难题。" << endl;
updateStat(algorithm, effect);
updateStat(math, effect / 2);
updateStat(dataStructures, effect / 3);
updateStat(dpSkill, effect / 2);
updateStat(stamina, -18);
updateStat(homework, 8);
}
void practiceWritingCode() {
int effect = isSick ? 5 : 12;
cout << name << "在认真手写代码,提高代码熟练度。" << endl;
updateStat(codeWriting, effect);
updateStat(programming, effect / 3);
updateStat(stamina, -20);
updateStat(homework, 3);
}
void studyDataStructures() {
int effect = isSick ? 4 : 9;
cout << name << "在学习数据结构,重点研究了并查集。" << endl;
updateStat(dataStructures, effect);
updateStat(algorithm, effect / 2);
updateStat(stamina, -16);
updateStat(homework, 6);
}
// 钻研动态规划
void studyDynamicProgramming() {
int effect = isSick ? 6 : 14;
cout << name << "在专心钻研动态规划,尝试优化状态转移方程。" << endl;
updateStat(dpSkill, effect);
updateStat(algorithm, effect / 3);
updateStat(math, effect / 2);
updateStat(stamina, -22); // 消耗较多体力
updateStat(homework, 7);
}
// 和陈熹一起讨论
void discussWithChenxi() {
if (friendship < 20) {
cout << "你想找陈熹讨论问题,但你们还不太熟,他可能在忙着和女朋友聊天。" << endl;
updateStat(happiness, -2);
return;
}
cout << name << "和陈熹一起讨论问题,他偶尔会看一下手机回复女朋友的消息。" << endl;
int studyEffect = (friendship > 50) ? 8 : 5; // 关系越好学习效果越平衡
updateStat(algorithm, studyEffect);
updateStat(programming, studyEffect / 2);
updateStat(friendship, 6);
updateStat(happiness, 7);
updateStat(stamina, -15);
updateStat(homework, -10);
// 有几率讨论到恋爱话题
if (rand() % 3 == 0) {
cout << "你们聊到了异地恋的话题,陈熹分享了很多他的经验,让你对人际关系有了新认识。" << endl;
updateStat(popularity, 4);
}
}
// 与学长交涉
void negotiateWithSenior() {
cout << name << "主动与学长交涉。" << endl;
if (seniorFavor < -50) {
cout << "学长对你很反感,根本不愿意理你,转身就走了。" << endl;
updateSignedStat(seniorFavor, -3);
updateStat(happiness, -5);
return;
}
int approach = rand() % 3; // 三种交涉方式,随机选择
if (approach == 0) { // 请教问题
cout << "你向学长请教了一个编程问题,希望能改善关系。";
bool helpful = (rand() % 100) < (seniorFavor + 50); // 关系越好越可能得到帮助
if (helpful) {
cout << "他虽然态度一般,但还是解答了你的问题。" << endl;
updateSignedStat(seniorFavor, 5);
updateStat(algorithm, 4);
updateStat(stamina, -8);
} else {
cout << "他敷衍地说不知道,还嘲讽你基础太差。" << endl;
updateSignedStat(seniorFavor, -5);
updateStat(happiness, -5);
}
} else if (approach == 1) { // 赠送小礼物
cout << "你带了点小零食送给学长,想缓和关系。";
bool accept = (rand() % 100) < (seniorFavor + 60); // 关系越好越可能接受
if (accept) {
cout << "他接受了礼物,虽然没说什么,但态度明显缓和了。" << endl;
updateSignedStat(seniorFavor, 8);
updateStat(happiness, 3);
updateStat(stamina, -3);
} else {
cout << "他不屑地说:\"这种东西就想收买我?\"让你很难堪。" << endl;
updateSignedStat(seniorFavor, -8);
updateStat(happiness, -8);
updateStat(popularity, -3); // 被其他同学看到
}
} else { // 直接沟通
cout << "你直接和学长谈了谈,希望能和平相处。";
bool positive = (rand() % 100) < (seniorFavor + 50); // 关系越好越可能有积极结果
if (positive) {
cout << "他虽然没道歉,但承认了之前有些做法不对,愿意和解。" << endl;
updateSignedStat(seniorFavor, 12);
updateStat(happiness, 5);
updateStat(stamina, -5);
} else {
cout << "他认为你在指责他,反而更生气了,说以后不会让你好过。" << endl;
updateSignedStat(seniorFavor, -12);
updateStat(happiness, -10);
}
}
}
void doHomework() {
int effect = isSick ? 10 : 25;
cout << name << "在认真完成作业。" << endl;
updateStat(homework, -effect);
updateStat(stamina, -10);
updateStat(happiness, 5);
updateStat(discipline, 3);
updateStat(teacherFavor, 2);
}
void rest() {
int effect = isSick ? 40 : 25;
cout << name << "在好好休息恢复体力。" << endl;
updateStat(stamina, effect);
updateStat(happiness, 10);
updateStat(homework, 5);
}
void playGames() {
if (homework > 70) {
cout << "作业太多了,不能尽情玩耍!" << endl;
updateStat(happiness, -5);
return;
}
cout << name << "在玩游戏放松心情。" << endl;
updateStat(happiness, 20);
updateStat(stamina, -10);
updateStat(homework, 10);
updateStat(discipline, -5);
updateStat(teacherFavor, -3);
updateStat(dormManagerFavor, -5); // 玩游戏可能被宿管发现,降低好感度
}
// 向老师请教
void askTeacher() {
cout << name << "向林老师请教问题。" << endl;
if (teacherFavor < 30) {
cout << "林老师看起来有些不耐烦,简单解答后就离开了。" << endl;
updateStat(algorithm, 3);
updateStat(stamina, -10);
} else if (teacherFavor < 70) {
cout << "林老师耐心解答了你的问题,让你收获不少。" << endl;
updateStat(algorithm, 8);
updateStat(math, 5);
updateStat(teacherFavor, 2);
updateStat(stamina, -15);
} else {
cout << "林老师不仅解答了问题,还拓展了许多相关知识,让你豁然开朗!" << endl;
updateStat(algorithm, 15);
updateStat(math, 10);
updateStat(teacherFavor, 5);
updateStat(stamina, -20);
updateStat(happiness, 8);
}
updateStat(homework, 3);
}
// 显示状态(新增宿管大妈好感度的显示)
void showStatus() const {
cout << endl << "=== " << name << "的状态 (第" << day << "天) ===" << endl;
cout << "编程能力: " << programming << "/100 ";
printBar(programming);
cout << "算法能力: " << algorithm << "/100 ";
printBar(algorithm);
cout << "动态规划: " << dpSkill << "/100 ";
printBar(dpSkill);
cout << "数学基础: " << math << "/100 ";
printBar(math);
cout << "数据结构: " << dataStructures << "/100 ";
printBar(dataStructures);
cout << "手写代码: " << codeWriting << "/100 ";
printBar(codeWriting);
cout << "体力: " << stamina << "/100 ";
printBar(stamina);
cout << "幸福感: " << happiness << "/100 ";
printBar(happiness);
cout << "作业量: " << homework << "/100 ";
printBar(homework);
cout << "人气值: " << popularity << "/100 ";
printBar(popularity);
cout << "纪律分: " << discipline << "/100 ";
printBar(discipline);
cout << "老师好感度: " << teacherFavor << "/100 ";
printBar(teacherFavor);
cout << "宿管好感度: ";
if (dormManagerFavor < 20) {
cout << "敌视 ";
} else if (dormManagerFavor < 40) {
cout << "冷淡 ";
} else if (dormManagerFavor < 60) {
cout << "一般 ";
} else if (dormManagerFavor < 80) {
cout << "友善 ";
} else {
cout << "亲近 ";
}
cout << dormManagerFavor << "/100 ";
printBar(dormManagerFavor);
cout << "与陈熹的友谊: ";
if (friendship < 20) {
cout << "陌生 ";
} else if (friendship < 40) {
cout << "普通同学 ";
} else if (friendship < 60) {
cout << "朋友 ";
} else if (friendship < 80) {
cout << "好朋友 ";
} else {
cout << "铁哥们 ";
}
cout << friendship << "/100 ";
printBar(friendship);
cout << "与学长的关系: ";
if (seniorFavor < -50) {
cout << "仇敌 ";
} else if (seniorFavor < -20) {
cout << "敌对 ";
} else if (seniorFavor < 20) {
cout << "中立 ";
} else if (seniorFavor < 50) {
cout << "友好 ";
} else {
cout << "融洽 ";
}
cout << seniorFavor << "/100 ";
printBar(seniorFavor < 0 ? 0 : seniorFavor); // 负数时显示为0
cout << "比赛记录: " << winCount << "/" << contestCount << " (获奖/参赛)" << endl;
if (isSick) cout << "?? 正在生病中 ??" << endl;
if (discipline < 40) cout << "?? 纪律分过低,可能被限制参加比赛 ??" << endl;
if (teacherFavor < 30) cout << "?? 老师对你印象不好,可能会影响发展 ??" << endl;
if (dormManagerFavor < 20) cout << "?? 宿管大妈对你印象很差,可能会经常找你麻烦 ??" << endl;
if (friendship > 70) cout << "?? 和陈熹是好朋友,他的恋情偶尔会影响你的心情 ??" << endl;
if (seniorFavor < -30) cout << "?? 学长对你有敌意,可能会暗中使绊子 ??" << endl;
cout << "=====================================" << endl;
}
// 打印进度条
void printBar(int value) const {
cout << "[";
int bars = value / 5;
for (int i = 0; i < 20; i++) {
if (i < bars) cout << "■";
else cout << "□";
}
cout << "]" << endl;
}
// 检查游戏是否结束
bool isGameOver() const {
return (happiness <= 0) || (day > 365) || (discipline <= 0) || (teacherFavor <= 0) || (dormManagerFavor <= 0);
}
// 显示游戏结果(包含与宿管大妈关系的评价)
void showResult() const {
cout << endl << "=== 游戏结束 ===" << endl;
// 纪律分过低导致的结束
if (discipline <= 0) {
cout << name << "因为纪律分过低被劝退了,OI之路暂时中断..." << endl;
cout << "吸取教训,下次一定要遵守纪律!" << endl;
return;
}
// 老师好感度过低导致的结束
if (teacherFavor <= 0) {
cout << name << "因为和老师关系恶化,被调到普通班,无法继续OI学习了..." << endl;
cout << "和老师保持良好关系也是学习生活的一部分。" << endl;
return;
}
// 宿管好感度过低导致的结束
if (dormManagerFavor <= 0) {
cout << name << "因为多次违反宿舍规定,被宿管大妈上报学校,取消了住宿资格,不得不搬离学校..." << endl;
cout << "和宿舍管理人员保持良好关系也很重要。" << endl;
return;
}
cout << name << "在铁一OI的" << day << "天学习结束了!" << endl;
cout << "最终能力值:" << endl;
cout << "编程能力: " << programming << "/100" << endl;
cout << "算法能力: " << algorithm << "/100" << endl;
cout << "动态规划: " << dpSkill << "/100" << endl;
cout << "数学基础: " << math << "/100" << endl;
cout << "数据结构: " << dataStructures << "/100" << endl;
cout << "手写代码: " << codeWriting << "/100" << endl;
cout << "纪律分: " << discipline << "/100" << endl;
cout << "老师好感度: " << teacherFavor << "/100" << endl;
cout << "宿管好感度: " << dormManagerFavor << "/100" << endl;
cout << "人气值: " << popularity << "/100" << endl;
cout << "比赛成绩: " << winCount << "次获奖 (" << contestCount << "次参赛)" << endl;
// 与陈熹的友谊结局
cout << endl << "友谊结局:";
if (friendship > 80) {
cout << "你和陈熹成为了铁哥们,经常一起讨论编程问题,也分享彼此的生活。他女朋友来看他时,还请你一起吃了饭。" << endl;
} else if (friendship > 60) {
cout << "你和陈熹是好朋友,他经常跟你分享他和异地恋女友的故事,你也从他那里学到了不少处理感情问题的方法。" << endl;
} else if (friendship > 40) {
cout << "你和陈熹关系不错,偶尔会一起讨论学习,他会跟你聊一些他和女朋友的趣事。" << endl;
} else if (friendship > 0) {
cout << "你和陈熹是普通同学关系,知道他有一个异地恋的女朋友,偶尔会看到他在聊天。" << endl;
} else {
cout << "你和陈熹几乎没什么交集,只知道他是那个经常上课玩手机聊天的同学。" << endl;
}
// 与学长的关系结局
cout << endl << "学长关系结局:";
if (seniorFavor < -50) {
cout << "你和学长成为了仇敌,他处处针对你,甚至在重要比赛中故意干扰你,给你的OI之路带来了很多麻烦。" << endl;
} else if (seniorFavor < -20) {
cout << "你和学长关系紧张,他经常对你冷嘲热讽,偶尔还会暗中使绊子,但没有造成太大影响。" << endl;
} else if (seniorFavor < 20) {
cout << "你和学长关系一般,没有太多交集,他对你既没有特别的帮助,也没有明显的敌意。" << endl;
} else if (seniorFavor < 50) {
cout << "你和学长关系不错,他偶尔会给你一些学习上的建议,虽然算不上真心,但也有些帮助。" << endl;
} else {
cout << "你成功改善了与学长的关系,他不仅不再针对你,还分享了很多宝贵的竞赛经验和学习资源,对你帮助很大。" << endl;
}
// 与宿管大妈的关系结局
cout << endl << "宿管关系结局:";
if (dormManagerFavor < 20) {
cout << "你和宿管大妈关系很差,她经常找你麻烦,甚至会因为一点小事就向老师告状,给你的学习生活带来了很多困扰。" << endl;
} else if (dormManagerFavor < 40) {
cout << "你和宿管大妈关系一般,她对你态度冷淡,偶尔会因为宿舍问题批评你,但不会刻意针对你。" << endl;
} else if (dormManagerFavor < 60) {
cout << "你和宿管大妈关系还不错,她对你印象一般,会正常检查宿舍但不会过多干涉你的生活。" << endl;
} else if (dormManagerFavor < 80) {
cout << "你和宿管大妈关系很好,她对你很友善,偶尔会关心你的学习和生活,还会提醒你一些宿舍规定。" << endl;
} else {
cout << "你和宿管大妈关系非常好,她像关心自己孩子一样关心你,经常给你留一些好吃的,还会帮你留意各种通知和机会。" << endl;
}
// 林老师的评语
cout << endl << "林老师评语:";
if (winCount >= 5 && programming >= 80 && algorithm >= 80 && dataStructures >= 70 && discipline >= 60) {
cout << "\"" << name << "同学极具天赋且勤奋刻苦,是我见过最有潜力的OIer之一,前途无量!\"" << endl;
cout << "恭喜!你成为了一名优秀的OIer,获得了名牌大学的保送资格!" << endl;
} else if (winCount >= 2 && programming >= 60 && algorithm >= 60 && discipline >= 50) {
cout << "\"" << name << "同学表现不错,有上进心,继续努力有望取得更好成绩。\"" << endl;
cout << "做得不错!你在OI竞赛中取得了不错的成绩,可以通过自主招生进入理想的大学。" << endl;
} else {
cout << "\"" << name << "同学还有很大提升空间,希望今后能更加努力,端正学习态度。\"" << endl;
cout << "继续努力!OI之路还很长,坚持下去才能取得更好的成绩。" << endl;
}
// 李丰亦的评语
if (dpSkill >= 80) {
cout << endl << "李丰亦对你竖起大拇指:\"你的DP造诣已经超过我了!这道三维DP题...(以下省略5000字)\"" << endl;
} else if (dpSkill >= 50) {
cout << endl << "李丰亦:\"你的DP还有提升空间,来看我最新优化的状态转移方程!\"" << endl;
} else {
cout << endl << "李丰亦摇摇头:\"你的DP太弱了,需要多刷题...(开始碎碎念)\"" << endl;
}
// 陈熹的结局评语
if (friendship > 30) {
cout << endl << "陈熹对你说:";
if (friendship > 70) {
cout << "\"兄弟,这段时间谢谢你听我唠叨那么多感情事!以后有机会介绍我女朋友给你认识,我们一起刷题!\"" << endl;
} else if (friendship > 50) {
cout << "\"这段时间谢谢你的陪伴,和你讨论问题很开心。我和女朋友感情很稳定,有空一起打球啊!\"" << endl;
} else {
cout << "\"祝你以后在OI路上越走越远,取得更好的成绩!\"" << endl;
}
}
// 学长的结局评语
if (seniorFavor != 0) {
cout << endl << "学长评价:";
if (seniorFavor < -30) {
cout << "\"哼,这次算你运气好,下次比赛我不会让你这么轻松的。\"" << endl;
} else if (seniorFavor < 0) {
cout << "\"没想到你还挺有毅力的,不过想超过我还早着呢。\"" << endl;
} else if (seniorFavor < 50) {
cout << "\"你还算有点潜力,以后继续努力吧,有问题可以来问我。\"" << endl;
} else {
cout << "\"你很有天赋,也很努力,将来一定能在OI领域取得好成绩,加油!\"" << endl;
}
}
// 宿管大妈的结局评语
if (dormManagerFavor > 30) {
cout << endl << "宿管大妈说:";
if (dormManagerFavor > 70) {
cout << "\"" << name << "这孩子真不错,又懂事又努力,将来肯定有大出息!我经常跟其他同学夸你呢。\"" << endl;
} else if (dormManagerFavor > 50) {
cout << "\"" << name << "同学挺听话的,宿舍卫生也搞得好,希望以后继续保持。\"" << endl;
} else {
cout << "\"" << name << "同学嘛,还算守规矩,就是有时候睡得太晚了,要注意身体啊。\"" << endl;
}
}
}
// 保存游戏进度(包含宿管大妈好感度)
bool saveGame() const {
ofstream file(name + "_save.dat");
if (!file.is_open()) {
cout << "保存失败!无法创建存档文件。" << endl;
return false;
}
file << name << endl;
file << day << endl;
file << programming << endl;
file << algorithm << endl;
file << math << endl;
file << stamina << endl;
file << happiness << endl;
file << homework << endl;
file << popularity << endl;
file << discipline << endl;
file << teacherFavor << endl;
file << dormManagerFavor << endl; // 保存宿管好感度
file << isSick << endl;
file << contestCount << endl;
file << winCount << endl;
file << codeWriting << endl;
file << dataStructures << endl;
file << dpSkill << endl;
file << friendship << endl;
file << seniorFavor << endl;
file.close();
cout << "游戏已成功保存!" << endl;
return true;
}
// 加载游戏进度(包含宿管大妈好感度)
static OIer* loadGame(const string& name) {
ifstream file(name + "_save.dat");
if (!file.is_open()) {
cout << "加载失败!找不到存档文件。" << endl;
return NULL;
}
string loadedName;
int day, programming, algorithm, math, stamina;
int happiness, homework, contestCount, winCount, codeWriting, popularity;
int dataStructures, discipline, teacherFavor, dpSkill, friendship, seniorFavor, dormManagerFavor; // 宿管好感度
bool isSick;
file >> loadedName;
file >> day;
file >> programming;
file >> algorithm;
file >> math;
file >> stamina;
file >> happiness;
file >> homework;
file >> popularity;
file >> discipline;
file >> teacherFavor;
file >> dormManagerFavor; // 读取宿管好感度
file >> isSick;
file >> contestCount;
file >> winCount;
file >> codeWriting;
file >> dataStructures;
file >> dpSkill;
file >> friendship;
file >> seniorFavor;
file.close();
return new OIer(loadedName, day, programming, algorithm, math, stamina,
happiness, homework, popularity, discipline, teacherFavor,
dormManagerFavor, isSick, contestCount, winCount, codeWriting, dataStructures, dpSkill, friendship, seniorFavor);
}
};
// 显示帮助信息(新增与宿管大妈互动的操作说明)
void showHelp() {
cout << endl << "===== 操作说明 =====" << endl;
cout << "1. 学习编程 - 提升编程能力,消耗体力" << endl;
cout << "2. 钻研算法 - 提升算法和数学能力,消耗较多体力" << endl;
cout << "3. 完成作业 - 减少作业量,提升幸福感、纪律分和老师好感度" << endl;
cout << "4. 休息 - 恢复体力,提升幸福感" << endl;
cout << "5. 玩游戏 - 大幅提升幸福感,降低纪律分和老师好感度" << endl;
cout << "6. 参加比赛 - 检验学习成果,有机会获奖(纪律分过低不可参加)" << endl;
cout << "7. 查看帮助" << endl;
cout << "8. 保存游戏" << endl;
cout << "9. 手写代码 - 提升手写代码熟练度,消耗较多体力" << endl;
cout << "10.清屏 - 清空当前屏幕显示" << endl;
cout << "11.学习数据结构 - 提升数据结构能力,特别是并查集" << endl;
cout << "12.向林老师请教 - 提升算法和数学能力,受老师好感度影响" << endl;
cout << "13.钻研动态规划 - 重点提升动态规划能力,消耗大量体力" << endl;
cout << "14.和陈熹一起讨论 - 提升算法能力,增加友谊值,需一定好感度" << endl;
cout << "15.与学长交涉 - 可能改善或恶化与学长的关系,有风险" << endl;
cout << "16.与宿管大妈互动 - 可能提升宿管好感度,获得特殊信息" << endl; // 新增操作
cout << "0. 退出游戏" << endl;
cout << "====================" << endl;
}
// 显示主菜单
int showMainMenu() {
int choice;
cout << endl << "===== 铁一OIer模拟器 =====" << endl;
cout << "1. 开始新游戏" << endl;
cout << "2. 加载存档" << endl;
cout << "0. 退出游戏" << endl;
cout << "请选择: ";
cin >> choice;
return choice;
}
int main() {
srand(time(0)); // 初始化随机数种子
OIer* player = NULL;
bool running = true;
// 主菜单循环
while (running) {
int mainChoice = showMainMenu();
if (mainChoice == 1) {
// 开始新游戏
string name;
cout << "请输入你的名字: ";
cin >> name;
player = new OIer(name);
break;
}
else if (mainChoice == 2) {
// 加载存档
string name;
cout << "请输入存档的名字: ";
cin >> name;
player = OIer::loadGame(name);
if (player != NULL) {
cout << "成功加载 " << player->getName() << " 的存档!" << endl;
break;
}
}
else if (mainChoice == 0) {
// 退出游戏
running = false;
cout << "感谢关注铁一OIer模拟器!" << endl;
}
else {
cout << "无效的选择,请重新输入。" << endl;
}
}
// 游戏主循环(添加与宿管大妈互动的操作)
if (player != NULL && running) {
showHelp();
int choice;
while (running && !player->isGameOver()) {
player->showStatus();
cout << endl << "请选择今天的活动: ";
cin >> choice;
switch (choice) {
case 1:
player->studyProgramming();
break;
case 2:
player->studyAlgorithm();
break;
case 3:
player->doHomework();
break;
case 4:
player->rest();
break;
case 5:
player->playGames();
break;
case 6:
player->participateContest();
break;
case 7:
showHelp();
continue;
case 8:
player->saveGame();
continue;
case 9:
player->practiceWritingCode();
break;
case 10:
clearScreen();
cout << "屏幕已清空" << endl;
continue;
case 11:
player->studyDataStructures();
break;
case 12:
player->askTeacher();
break;
case 13:
player->studyDynamicProgramming();
break;
case 14:
player->discussWithChenxi();
break;
case 15:
player->negotiateWithSenior();
break;
case 16: // 新增:与宿管大妈互动
player->interactWithDormManager();
break;
case 0:
running = false;
cout << "游戏已结束。" << endl;
continue;
default:
cout << "无效的选择,请重新输入。" << endl;
continue;
}
player->nextDay();
}
if (player->isGameOver()) {
player->showResult();
}
delete player;
}
cout << "感谢游玩铁一OIer模拟器!" << endl;
return 0;
}