我的养成系睿跟v0.4

· · 个人记录

有存档了

#include <bits/stdc++.h>
#include <windows.h>
#define cls() system("cls")
using namespace std;

string ans;
int ntic = 0, speed, setspeed, mode = 1;
int levs[11] = {0, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000};
int saves[105];
bool jump, skipvel;

struct Player {
    string name;
    int progress;
    int exps, lev;

} player;

void SaveGame(string filename);
void LoadGame(string filename);
void svgame();
void ldgame();

void init();
void saveinit();
void say(string a);
void nti();
void abgame();
void ctngame();
void gameset();
void col();
void vel1();
void neimap();
void daytime1();

int main() {
    cout << "正在加载游戏...";
    init();
    nti();
}
void init() {
    ifstream file("init.rgsave");
    if (file.is_open()) {
        file >> skipvel; //是否跳过剧情 
        file >> setspeed; //文字显示速度 
        speed = setspeed;
        for (int i = 1; i <= 100; i++) file >> saves[i]; //是否保存档位 
        file.close();
        return; 
    }
    else {
        ofstream file("init.rgsave");
        file << "1 ";
        file << "40 ";
        for (int i = 1; i <= 100; i++) file << "0 ";
    }
}
void saveinit() {
    ofstream file("init.rgsave");
    file << skipvel << ' ';
    file << setspeed << ' ';
    if (file.is_open()) {
        for (int i = 1; i <= 100; i++) {
            file << saves[i] << ' ';
        }
        file.close();
        return; 
    }
}
void say(string a) {
    int l = a.size();
    for (int i = 0; i < l; i++) {
        cout << a[i];
        if (a[i]) Sleep(speed);
    }
    Sleep(100);
}
void col(int a) {//0白   1蓝绿   2绿   3紫   4粉红   5亮黄   6青蓝
    if (a == 0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    if (a == 1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE);
    if (a == 2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
    if (a == 3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
    if (a == 4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
    if (a == 5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
    if (a >= 6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
}
void svgame() {
    cout << "保存到第几个存档?" << endl;
    int fn;
    cin >> fn;
    if (saves[fn]) {
        say("该存档已经保存了内容,确定要替换?\n1.保存  2.取消\n"); 
        cin >> ans;
        if (ans == "1") {
            saves[fn] = 1;
            saveinit();
            SaveGame("save" + to_string(fn) + ".rgsave");
        }
    }
    else {
        saves[fn] = 1;
        saveinit();
        SaveGame("save" + to_string(fn) + ".rgsave");
    }
}
void SaveGame(string filename) {
    ofstream file(filename.c_str());
    if (file.is_open()) {
        file << player.name << ' ';
        file << player.progress << ' ';
        file << player.exps << ' ' << player.lev;
        file.close();
    }
    cls();
    return; 
}
void ldgame() {
    cls();
    bool sflag = 0;
    for (int i = 1; i <= 100; i++) 
        if (saves[i] == 1) {
            sflag = 1;
            break;
        }
    if (sflag = 0) {
        say("你还没有任何存档!\n");
        Sleep(500);
        system("pause");
        nti(); 
    }
    else {
        cout << "加载到第几个存档?" << endl;
        int fn;
        cin >> fn;
        if (!saves[fn]) {
            say("该存档没有保存任何内容!!!\n"); 
            Sleep(500);
            ldgame();
        }
        else {
            LoadGame("save" + to_string(fn) + ".rgsave");
        }
    }
    return;
}
void LoadGame(string filename) { 
    ifstream file(filename.c_str());
    if (file.is_open()) {
        file >> player.name;
        file >> player.progress;
        file >> player.exps >> player.lev;
        file.close();
        if (player.progress <= 1) {
            jump = 1;
            vel1();
        }
        return ;
    }
}
void nti() {
    if (!ntic) speed = 10, ntic = 1;
    else speed = 0;
    cls();
    col(1);
    cout << "             我的";
    col(5);
    cout << "养成系";
    col(1);
    cout << "睿跟"; 
    col(0);
    cout << " v0.4a" << endl;
    col(1);
    cout << "            My ";
    col(5);
    cout << "Raising Sim: ";
    col(1);
    cout << "Regan\n"; 
    col(4);
    cout << "             Regan_Love制作组出品" << endl; 
    col(0);
    say("在发布当前版本的反馈帖子下或私信反馈BUG或改进\n");
    say("反馈帖子:暂无\n");
    say("更多版本在我的团队 >>>\n");
    col(1);
    say("团队主页:https://www.luogu.com.cn/team/85929");
    col(0);
    cout << endl << "-----------------------------------------------" << endl;
    say("1.开始游戏        2.继续游戏        3.游戏设置\n4.关于游戏                          5.退出游戏\n");
    speed = 10;
    cin >> ans;
    if (ans == "4") abgame();
    if (ans == "1") {
        vel1();
        return;
    }
    if (ans == "2") ldgame();
    if (ans == "3") gameset();
    else nti();
}
void abgame() {
    cls();
    say("1.游戏介绍     2.玩法说明     3.制作团队    4.返回\n");
    cin >> ans;
    if (ans == "1") {
        cls();
        say("《我的养成系睿跟》是一款由 ");
        col(2);
        say("Regan_Love 制作组 ");
        col(0);
        say("制作发行的一款剧情游戏");
        cout << endl;
        say("游戏主要通过");
        col(4);
        say("剧情选择,购买道具,与可爱的睿跟互动,提升与睿跟的好感度,"); 
        col(0);
        say("使睿跟逐渐变得顺从,阳光,最后与你修得正果~");
        cout << endl;
        system("pause");
        nti();
        return;
    }
    if (ans == "2") {
        cls();
        say("输入选项数字以选择");
        cout << endl;
        say("推进剧情或与睿跟互动可提升好感度");
        cout << endl;
        say("当好感度达到一定数值时将提高好感等级");
        cout << endl;
        say("当好感等级达到10级时将会触发结局");
        cout << endl;
        say("在商店使用好感度购买交互行为或道具与睿跟互动,可触发其他结局");
        cout << endl;
        system("pause");
        nti();
    } 
    if (ans == "3") {
        cls();
        col(0);
        say("由");
        col(2);
        say(" 睿跟头号星怒  Luogu:Jimmy_Cao");
        col(0);
        say(" 原创制作");
        cout << endl << "由";
        col(2);
        say(" 睿 跟 project  Luogu:_Ayato");
        col(0);
        say("   文案编写");
        cout << endl; 
        say("作者主页:https://www.luogu.com.cn/user/1351065");
        cout << endl;
        say("文案组主页:https://www.luogu.com.cn/user/1351021");
        cout << endl;
        say("睿跟后援会(团队主页):https://www.luogu.com.cn/team/85929");
        cout << endl;
        say("快来加入我们吧(^w^)");
        cout << endl; 
        system("pause");
        abgame();
    }
    if (ans == "4") nti();
    else abgame();
}
void gameset() {
    cls();
    saveinit();
    speed = 10;
    say("1.游戏模式  2.文本显示速度  3.剧情跳过  4.返回\n");
    cin >> ans;
    if (ans == "1") {
        cls();
        say("游戏模式:");
        col(4);
        say("1.普通模式  2.R18 模式");
        cout << endl;
        col(0);
        cin >> ans;
        if (ans == "1") {
            mode = 0;
            cout << "设置成功!";
            Sleep(1000);
            system("pause");
            gameset();
        }
        if (ans == "2") {
            MessageBox(NULL, "18+模式中将会有更多色情内容,确定要开启吗", "R18 Mode",MB_ICONASTERISK| MB_OK);
            mode = 1;
            cout << "设置成功!" << endl;
            Sleep(1000);
            system("pause");
            gameset();
        }
    }
    if (ans == "2") {
        cls();
        cout << "请输入文本显示速度(默认速度:40;输入的数字越小,文字显示的速度越快):";
        setspeed = speed;
        int sp;
        cin >> sp;
        speed = sp;
        cout << "设置成功!" << endl;
        Sleep(1000);
        cout << "示例:" << endl;
        Sleep(500);
        say("睿跟睿跟真可爱!\n");
        setspeed = sp;
        system("pause");
        gameset();
    }
    if (ans == "3") {
        tp:
        cls();
        cout << "是否开启跳过剧情提示:1.开启  2.关闭\n";
        cin >> ans;
        if (ans == "1") skipvel = 1;
        if (ans == "2") skipvel = 0;
        else goto tp;
    }
    if (ans == "4") nti();
    else gameset();
}
void vel1() {
    cls(); 
    speed = setspeed;
    if (jump == 1) {
        switch (player.progress) {
            case 1: goto prog1;
        }
        jump = 0;
    }
    col(4); 
    cout << "                  "; 
    say("警告!\n");
    cout << "           ";
    say("本游戏内容纯属虚构\n");
    say("本游戏含有少量的色情以及暧昧的肢体动作情节\n");
    col(0);
    system("pause");
    cls(); 
    col(5);
    say("     §|");
    col(1);
    speed = 100;
    say("第一章  初识睿跟");
    col(5);
    speed = setspeed;
    say("| §");
    col(0);
    cls();
    say("你缓缓地睁开眼...");
    Sleep(500);
    cout << endl;
    say("阳光洒落在房间的地板上,你坐了起来");
    Sleep(500);
    cout << endl;
    say("桌面上的工作简历写着你的名字...");
    cout << endl << ">>>";
    cin >> player.name;
    cls();
    player.progress = 1;
    svgame();
    prog1:
    say("一个男孩的身影浮现在你眼前");
    cout << endl;
    Sleep(1000);
    speed = 500; 
    say("睿...");
    Sleep(300);
    speed = setspeed;
    say("睿跟?");
    cout << endl; 
    Sleep(500);
    system("pause");
    cls(); 
    if (skipvel == 1) {
        say("1.跳过部分剧情  2.继续  3.不再显示此内容\n");
        cin >> ans;
        if (ans == "1") {
            say("真的要这样做吗?小睿跟会伤心的哦...\n1.跳过  2.算了");
            cin >> ans;
            if (ans == "1") {
                cls();
                goto gt1;
            }
        }
        if (ans == "3") {
            say("此后可在游戏设置中更改此设置\n");
            skipvel = 0;
            system("pause"); 
        }
        cls();
    }
    say("你不可置信地眨了眨眼");
    cout << endl;
    Sleep(1000);
    say("你试探性地念着他的名字...");
    cout << endl << ">>>";
    cin >> ans;
    col(5);
    say("睿跟:嗯,叫我吗?");
    Sleep(1000);
    cout << endl;
    col(0);
    say("你捏了捏自己的手臂...");
    Sleep(1000);
    cout << endl;
    say("你没在做梦!");
    cout << endl;
    Sleep(1000);
    system("pause");
    cls();
    col(0);
    say(player.name);
    say(":睿跟,你怎么在我家里?");
    cout << endl;
    Sleep(500);
    col(5);
    say("睿跟:不可告人的秘密(偷笑)");
    cout << endl;
    Sleep(500);
    col(0);
    say("你深吸一口气,试图让自己更加清醒一些");
    cout << endl;
    Sleep(500);
    say(player.name);
    say(":好了,睿跟,现在我要换衣服了,请你出去一下行吗?");
    cout << endl;
    Sleep(500);
    col(5);
    say("睿跟:唔...好吧,我在客厅等你");
    cout << endl;
    col(0);
    Sleep(500); 
    say("睿跟匆匆离开了你的房间...");
    cout << endl;
    Sleep(1000);
    say("你试图冷静思考,可是无论如何也解释不了这一切,什么叫【不可告人的秘密】");
    cout << endl;
    Sleep(500);
    system("pause");
    cls(); 
    say("你转身走回房间,把睿跟关在了卧室外");
    cout << endl;
    system("pause");
    cls();
    say("你透过房间的猫眼望去,只见睿跟呆呆地站在客厅中央,保持着沉默,什么也没做");
    cout << endl;
    say(player.name);
    say(":我换好了,进来吧...");
    Sleep(500);
    cout << endl;
    say("睿跟还是不出声");
    cout << endl;
    Sleep(500);
    say("你只好自己推开房门走出来。实话说,你真的很想知道一件事。所谓【不可告人的秘密】是什么");
    cout << endl;
    Sleep(500);
    say("你走到了客厅,眼前是看上去笨笨的小睿跟");
    cout << endl;
    Sleep(500);
    say("你还在思索,如何让他说出【不可告人的秘密】");
    cout << endl;
    Sleep(500);
    gt1:
    if (mode == 0) {
        cls();
        col(5);
        say("睿跟:我们走吧!");
        Sleep(500);
        cout << endl;
        col(0);
        say("你反应过来,看向睿跟");
        Sleep(500);
        cout << endl;
        say("他穿的好像是某个中学的校服,藏蓝色的长裤,纯白的上衣");
        Sleep(500);
        cout << endl;
        say("配上睿跟那副不谙世事的单纯模样,很像会在操场上自由奔跑的学生");
        Sleep(500);
        cout << endl;
        say("你似乎很喜欢这副模样...");
        Sleep(500);
        cout << endl;
        say("他...真可爱?你不禁为自己的想法感到害羞");
        Sleep(500);
        cout << endl;
        say("你突然猛地一激灵,好像刚才睡着了一般...");
        Sleep(500);
        cout << endl;
        system("pause");
        cls();
    }
    if (mode == 1) {
        say("他的脸,在你不注意的时候...变...红了?");
        Sleep(500);
        cout << endl;
        col(5);
        say("睿跟:欸欸欸欸欸欸欸??!!你平时就穿成这样吗?");
        Sleep(500);
        col(0);
        cout << endl;
        say("你并没有觉得的你的衣着有什么不妥");
        Sleep(500);
        cout << endl;
        say(player.name);
        say(":怎么了吗?");
        Sleep(500);
        cout << endl;
        col(5);
        say("睿跟:...你的裤子,太紧了一点?");
        Sleep(500);
        cout << endl;
        col(0);
        say("你低头一看,好像是太紧了");
        Sleep(500);
        cout << endl;
        say("凸出来了!!!");
        Sleep(500);
        cout << endl;
        say("你尴尬地转过身去,走回房间,想换一条裤子");
        Sleep(500);
        cout << endl;
        say("你身后一阵脚步声传来...");
        Sleep(500);
        cout << endl;
        say("有人扯了扯你袖子,你转头。是睿跟");
        Sleep(500);
        cout << endl;
        system("pause");
        say(player.name);
        Sleep(500);
        say(":睿跟?");
        Sleep(500);
        cout << endl;
        col(5);
        say("睿跟:算了,不要换。我觉得你穿着这件衣服很好看");
        Sleep(500);
        cout << endl;
        col(0);
        say("睿跟笑了,笑得脸通红,眼睛笑成一个弯弯的月牙");
        Sleep(500);
        cout << endl;
        say("你看着睿跟,有话想说,但却感觉被封在了喉咙里");
        Sleep(500);
        cout << endl;
        say("好像?");
        Sleep(500);
        cout << endl;
        say("你察觉到,那个【不可告人的秘密】离你越来越近");
        Sleep(500);
        cout << endl;
        say("你:你好像不需要换衣服?");
        Sleep(500);
        cout << endl;
        say("睿跟低头看看了自己的衣服");
        Sleep(500);
        cout << endl;
        say("他穿的好像是某个中学的校服,藏蓝色的长裤,纯白的上衣");
        Sleep(500);
        cout << endl;
        say("配上睿跟那副不谙世事的单纯模样,很像会在操场上自由奔跑的学生");
        Sleep(500);
        cout << endl;
        say("你似乎很喜欢这副模样...");
        Sleep(500);
        cout << endl;
        say("他...真可爱?你不禁为自己的想法感到害羞");
        Sleep(500);
        cout << endl;
        col(5);
        say("睿跟:我的衣服不脏,我们走吧");
        Sleep(500);
        cout << endl;
        system("pause");
        cls();
    }
    col(5);
    say(player.name);
    say(":去哪?");
    col(5);
    cout << endl;
    Sleep(500);
    say("睿跟:我饿了。你平时不吃早餐吗?");
    col(0);
    Sleep(500);
    cout << endl;
    say("你好像毕业后都是中午才起床...");
    Sleep(500);
    cout << endl;
    say(player.name);
    say(":睡到12点就不用吃了");
    Sleep(500);
    cout << endl;
    say("睿跟沉默了。他拽了拽你的袖子");
    cout << endl;
    Sleep(500);
    say(player.name);
    say(":走吧,去吃早餐");
    cout << endl;
    Sleep(500);
    system("pause");
    cls();
    player.exps += 10;
    col(5);
    say("与睿跟提升了10点好感度!");
    cout << endl;
    if (player.exps >= levs[player.lev]) {
        cout << "[LV.UP] 友好等级提升!";
        player.lev++;
        player.exps -= levs[player.lev];
        say("\n当前好感等级:");
        cout << player.lev << "级" << endl;
        system("pause");
    }
    cls();
    say("完成");
    col(5);
    say("日常剧情");
    col(0);
    say("以提升与睿跟的好感度!\n");
    cin.get();
    say("当好感等级达到 2 时将推进主线剧情!\n");
    system("pause");
    daytime1();
}
void daytime1() {
    col(0);
    cls();
    say("当前好感等级:");
    col(5);
    cout << player.lev;
    col(0);
    say(" 当前好感度:");
    col(5);
    cout << player.exps + levs[player.lev] << endl;
    cls();
    col(0); 
//  neimap();
    say("感谢你的游玩!");
    cout << endl;
    cout << "请在 Luogu 0.4公测版的帖子下反馈BUG或改进" << endl;
    exit(0);
}
void neimap() {
    cout << "当前地图:楼下街区   输入编号前往对应地点>>>" << endl;
    cout << "============================================" << endl;
    cout << "|             |  |          | |            |" << endl;
    cout << "|  1.早餐店   |  |   2.家   | |   3.公园   |" << endl;
    cout << " =====    ===========    ==========    =====" << endl;
    cout << endl;
    cout << " =====    ===========    ==========    =====" << endl;
    cout << "|             |  |          | |            |" << endl;
    cout << "|  4.文具店   |  |  5.超市  | |  6.图书馆  |" << endl;
    cout << "============================================" << endl;
}