『转载zhhhh』花世界·第四部:终焉·最后的绽放
Luna_From_Starry
·
·
科技·工程
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#include<time.h>
#include<fstream>
using namespace std;
// ==================== 全局变量 ====================
// 玩家信息
string player_name = "玩家";
// 末日状态
int day = 1; // 当前天数(1-5)
int remaining_time = 5; // 剩余天数
int shelter_level = 1; // 避难所等级(1-3)
int total_flowers = 20; // 总花数
int alive_flowers = 20; // 存活花数
int sunlight = 100; // 阳光资源
int dew = 50; // 露水资源
int memory_fragments = 0; // 记忆碎片(隐藏)
// 花的状态数组
vector<string> flower_names; // 花的名字
vector<int> flower_health; // 健康度 0-100
vector<int> flower_trust; // 信任度 0-100
vector<bool> flower_infected; // 是否感染
vector<string> flower_memories; // 花的记忆
// 道德值系统
int compassion = 50; // 怜悯值
int justice = 50; // 公正值
int hope = 50; // 希望值
int revenge = 0; // 复仇值(新增)
// 结局标志
bool ending_achieved = false;
string ending_type = "";
// 特殊事件标志
bool met_strangers = false;
bool betrayed = false;
bool planted_seed = false;
bool baby_flower_exists = false;
string baby_flower_name = "";
// ==================== 函数声明 ====================
void setColor(int color);
void resetColor();
void slowPrint(string s, int speed = 30);
void Print(string s);
void PrintRed(string s);
void PrintGreen(string s);
void PrintBlue(string s);
void PrintPurple(string s);
void PrintYellow(string s);
void PrintCyan(string s);
void clearInput();
void showStatus();
void initFlowers();
void randomEvent();
void decreaseResources();
void checkDeaths();
void day1_survival();
void day2_resources();
void day3_betrayal();
void day4_hope();
void day5_final();
bool revengeBattle(); // 新增:复仇之战
void ending_despair();
void ending_hope();
void ending_rebirth();
void ending_true();
void ending_revenge_sacrifice(); // 新增:复仇牺牲结局
void ending_revenge_memorial(); // 新增:复仇纪念结局
void playGame();
// ==================== 工具函数 ====================
void setColor(int color) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, color);
}
void resetColor() {
setColor(7);
}
void slowPrint(string s, int speed) {
for(int i = 0; i < s.size(); i++) {
cout << s[i];
Sleep(speed);
}
}
void Print(string s) {
slowPrint(s, 25);
}
void PrintRed(string s) {
setColor(12);
slowPrint(s, 25);
resetColor();
}
void PrintGreen(string s) {
setColor(10);
slowPrint(s, 25);
resetColor();
}
void PrintBlue(string s) {
setColor(9);
slowPrint(s, 25);
resetColor();
}
void PrintPurple(string s) {
setColor(13);
slowPrint(s, 25);
resetColor();
}
void PrintYellow(string s) {
setColor(14);
slowPrint(s, 25);
resetColor();
}
void PrintCyan(string s) {
setColor(11);
slowPrint(s, 25);
resetColor();
}
void clearInput() {
while(kbhit()) getch();
}
void showStatus() {
cout << "\n";
setColor(11);
cout << "╔════════════════════════════════╗\n";
cout << "║ 当前状态 ║\n";
cout << "╚════════════════════════════════╝\n";
resetColor();
cout << "第 " << day << " 天 | 剩余时间: " << remaining_time << " 天\n";
cout << "避难所等级: " << shelter_level << "\n";
cout << "存活花朵: " << alive_flowers << "/" << total_flowers << "\n";
cout << "阳光: " << sunlight << " | 露水: " << dew << "\n";
setColor(13);
cout << "怜悯: " << compassion << " | 公正: " << justice << " | 希望: " << hope;
setColor(12);
cout << " | 复仇: " << revenge << "\n";
resetColor();
cout << "\n";
}
void initFlowers() {
string names[] = {"小阳", "露露", "瓣瓣", "蕊儿", "青青", "红红", "紫紫", "黄黄", "白白", "粉粉",
"笑笑", "暖暖", "甜甜", "香香", "美美", "丽丽", "娇娇", "艳艳", "芳芳", "芊芊"};
string memories[] = {
"记得第一次开花,你笑了",
"记得下雨天,你给我撑伞",
"记得你说过,会一直陪着我",
"记得你教我唱歌",
"记得我们一起看星星",
"记得你给我起名字的那天",
"记得你难过时,我陪着你",
"记得你开心时,抱着我转圈",
"记得你说我是最特别的花",
"记得你每天都会来看我"
};
for(int i = 0; i < 20; i++) {
flower_names.push_back(names[i % 20]);
flower_health.push_back(rand() % 30 + 70); // 70-100
flower_trust.push_back(rand() % 20 + 80); // 80-100
flower_infected.push_back(false);
flower_memories.push_back(memories[rand() % 10]);
}
}
void randomEvent() {
int event = rand() % 100;
if(event < 20) {
// 好事:发现资源
int found_sunlight = rand() % 30 + 10;
int found_dew = rand() % 20 + 5;
sunlight += found_sunlight;
dew += found_dew;
PrintGreen("\n【好事】发现了资源!阳光+" + to_string(found_sunlight) + ",露水+" + to_string(found_dew) + "\n");
}
else if(event < 40) {
// 坏事:资源被盗
int lost = rand() % 20 + 5;
sunlight = max(0, sunlight - lost);
PrintRed("\n【坏事】资源被盗了!阳光-" + to_string(lost) + "\n");
revenge += 2; // 资源被盗增加复仇值
}
else if(event < 60) {
// 感染事件
int infected_index = rand() % alive_flowers;
if(!flower_infected[infected_index]) {
flower_infected[infected_index] = true;
PrintRed("\n【感染】" + flower_names[infected_index] + "感染了删除病毒!\n");
revenge += 3; // 花被感染增加复仇值
}
}
else if(event < 80) {
// 情绪事件
int sad_index = rand() % alive_flowers;
flower_trust[sad_index] = max(0, flower_trust[sad_index] - 10);
PrintYellow("\n【情绪】" + flower_names[sad_index] + "感到很害怕...\n");
}
else {
// 记忆事件
int memory_index = rand() % alive_flowers;
PrintCyan("\n【记忆】" + flower_names[memory_index] + ":" + flower_memories[memory_index] + "\n");
memory_fragments++;
}
}
void decreaseResources() {
// 每天消耗资源
int consume_sunlight = alive_flowers * 2;
int consume_dew = alive_flowers;
sunlight -= consume_sunlight;
dew -= consume_dew;
if(sunlight < 0) sunlight = 0;
if(dew < 0) dew = 0;
Print("资源消耗:阳光-" + to_string(consume_sunlight) + ",露水-" + to_string(consume_dew) + "\n");
}
void checkDeaths() {
vector<int> dead_indices;
// 检查资源不足导致的死亡
if(sunlight <= 0 || dew <= 0) {
int deaths = rand() % 3 + 1;
for(int i = 0; i < deaths && alive_flowers > 0; i++) {
int dead_index = rand() % alive_flowers;
dead_indices.push_back(dead_index);
}
PrintRed("\n资源枯竭!有花凋谢了...\n");
revenge += deaths * 2; // 每死一朵花增加复仇值
}
// 检查感染导致的死亡
for(int i = 0; i < alive_flowers; i++) {
if(flower_infected[i]) {
if(rand() % 100 < 30) { // 30%几率死亡
dead_indices.push_back(i);
PrintRed(flower_names[i] + "没能挺过感染...\n");
revenge += 5; // 感染死亡增加更多复仇值
}
}
}
// 处理死亡
if(!dead_indices.empty()) {
// 从后往前删除,避免索引问题
sort(dead_indices.begin(), dead_indices.end(), greater<int>());
for(int idx : dead_indices) {
flower_names.erase(flower_names.begin() + idx);
flower_health.erase(flower_health.begin() + idx);
flower_trust.erase(flower_trust.begin() + idx);
flower_infected.erase(flower_infected.begin() + idx);
flower_memories.erase(flower_memories.begin() + idx);
alive_flowers--;
}
}
}
// ==================== 新增:复仇之战 ====================
bool revengeBattle() {
system("cls");
setColor(12);
cout << "╔════════════════════════════════╗\n";
cout << "║ 复仇之战:直面病毒 ║\n";
cout << "╚════════════════════════════════╝\n\n";
resetColor();
PrintRed("你选择了复仇!\n");
PrintRed("病毒实体化,变成了巨大的代码怪物\n");
Print("你需要躲避它的弹幕攻击,坚持30秒\n");
Print("\n按任意键开始战斗...\n");
getch();
int time_elapsed = 0;
int player_hp = 100;
int dodge_position = 3; // 1-5,初始中间
string bullets[] = {"printf", "cout", "endl", "\\n", "scanf", "cin", "getchar", "delete", "病毒", "删除"};
while(time_elapsed < 30 && player_hp > 0) {
system("cls");
// 显示计时
setColor(14);
cout << "剩余时间: " << (30 - time_elapsed) << "秒\n";
resetColor();
// 显示血量
setColor(12);
cout << "你的意志: ";
if(player_hp > 70) setColor(10);
else if(player_hp > 30) setColor(14);
else setColor(12);
cout << player_hp << "/100\n\n";
resetColor();
// 显示弹幕
int bullet_count = rand() % 5 + 3; // 3-7个弹幕
vector<int> bullet_positions;
setColor(11);
cout << "病毒发射:";
for(int i = 0; i < bullet_count; i++) {
int pos = rand() % 5 + 1;
bullet_positions.push_back(pos);
cout << bullets[rand() % 10] << "(" << pos << ") ";
}
cout << "\n\n";
resetColor();
// 显示位置选择
cout << "你的位置: [1] [2] [3] [4] [5]\n";
cout << "当前在: " << dodge_position << "\n\n";
cout << "移动 (1-5 选择位置, 0 防御): ";
char move = getch();
// 处理输入
if(move >= '1' && move <= '5') {
dodge_position = move - '0';
PrintGreen("移动到 " + to_string(dodge_position) + "\n");
}
else if(move == '0') {
PrintYellow("防御姿态!伤害减半\n");
}
// 判断是否被击中
int hit_count = 0;
for(int pos : bullet_positions) {
if(pos == dodge_position) {
if(move == '0') {
player_hp -= 5; // 防御减半
hit_count++;
}
else {
player_hp -= 10; // 正常伤害
hit_count++;
}
}
}
if(hit_count > 0) {
PrintRed("被 " + to_string(hit_count) + " 个弹幕击中!\n");
}
else {
PrintGreen("完美躲避!\n");
}
// 病毒讲话(增加氛围)
if(rand() % 100 < 30) {
setColor(12);
cout << "\n病毒:";
switch(rand() % 5) {
case 0: cout << "“放弃吧,你救不了它们”\n"; break;
case 1: cout << "“它们只是代码,删了就删了”\n"; break;
case 2: cout << "“你的愤怒毫无意义”\n"; break;
case 3: cout << "“接受现实吧”\n"; break;
case 4: cout << "“你也会被删除的”\n"; break;
}
resetColor();
}
time_elapsed++;
Sleep(1000);
}
system("cls");
if(player_hp <= 0) {
PrintRed("\n你的意志崩溃了...\n");
PrintRed("病毒吞噬了你\n");
getchar();
return false;
}
else {
PrintGreen("\n你坚持了30秒!\n");
PrintGreen("病毒开始崩溃!\n");
getchar();
// 病毒死亡画面
system("cls");
setColor(12);
cout << "病毒:“不...不可能...”\n";
Sleep(1000);
cout << "病毒:“我...被...击败了...”\n";
Sleep(1000);
cout << "病毒化作数据碎片,消散在空中\n";
resetColor();
getchar();
return true;
}
}
// ==================== 新增结局 ====================
void ending_revenge_sacrifice() {
system("cls");
setColor(12);
cout << "\n\n\n";
cout << " ╔════════════════════════╗\n";
cout << " ║ 结局:复仇·牺牲之花 ║\n";
cout << " ╚════════════════════════╝\n\n\n";
resetColor();
Sleep(1500);
Print("病毒消散了,但你也受了重伤\n");
Print("你站在虚无中,周围漂浮着花的记忆\n");
Print("你记得每一朵花的名字\n");
Print("你记得它们的笑容\n");
Print("你记得它们最后看你的眼神\n");
getchar();
Print("\n你知道,你可以用自己最后的记忆\n");
Print("复活所有消失的花\n");
Print("但代价是:你自己会永远消失\n");
Print("没有人会记得你\n");
Print("包括那些被你救活的花\n");
getchar();
Print("\n你闭上眼睛\n");
Print("想起第一朵花绽放的样子\n");
Print("想起它们叫你“创造者”的声音\n");
Print("想起它们围着你唱歌的夜晚\n");
getchar();
Print("\n你笑了\n");
Print("“没关系”\n");
Print("“只要它们活着就好”\n");
getchar();
// 记忆释放特效
for(int i = 0; i < 5; i++) {
setColor(rand() % 15);
cout << "\n? ? ? ? ?";
Sleep(300);
}
resetColor();
Print("\n\n你的记忆化作光点,飘向四面八方\n");
Print("光点落下的地方,花重新绽放\n");
Print("一朵、两朵、三朵...\n");
Print("所有花都回来了\n");
getchar();
Print("\n它们睁开眼睛\n");
Print("互相看着彼此\n");
Print("“我们...还活着?”\n");
Print("“发生了什么?”\n");
Print("“好像...有人救了我们”\n");
Print("“但...是谁呢?”\n");
getchar();
Print("\n它们永远不知道\n");
Print("有一个叫" + player_name + "的创造者\n");
Print("用自己的记忆换回了它们\n");
Print("而自己化作了虚无\n");
getchar();
setColor(10);
cout << "\n\n";
cout << " 花 花 花 花 花\n";
cout << " 花 花\n";
cout << " 花 它们活着 花\n";
cout << " 花 但 花\n";
cout << " 花 忘记你 花\n";
cout << " 花 花\n";
cout << " 花 花\n";
cout << " 花\n";
resetColor();
Print("\n【结局:复仇·牺牲之花】\n");
Print("你救了它们,但被世界遗忘\n");
getchar();
ending_achieved = true;
ending_type = "revenge_sacrifice";
}
void ending_revenge_memorial() {
system("cls");
setColor(14);
cout << "\n\n\n";
cout << " ╔════════════════════════╗\n";
cout << " ║ 结局:复仇·纪念之花 ║\n";
cout << " ╚════════════════════════╝\n\n\n";
resetColor();
Sleep(1500);
Print("病毒消散了\n");
Print("你站在虚无中,周围是花的记忆\n");
Print("但你知道,它们回不来了\n");
Print("你接受了这个事实\n");
getchar();
Print("\n你决定为它们做点什么\n");
Print("你用病毒留下的数据碎片\n");
Print("开始建造一座纪念碑\n");
getchar();
// 建造过程
Print("\n第一天,你立起石碑\n");
Print("第二天,你刻上第一朵花的名字\n");
Print("第三天,你刻上第二朵花的名字\n");
Print("...\n");
Print("第" + to_string(total_flowers) + "天,你刻上了最后一朵花的名字\n");
getchar();
Print("\n纪念碑建好了\n");
Print("上面刻着所有花的名字\n");
Print("和它们最后说的话\n");
getchar();
// 展示一些记忆
setColor(11);
cout << "\n【花的记忆】\n";
for(int i = 0; i < min(5, (int)flower_memories.size()); i++) {
cout << "● " << flower_names[i] << ":" << flower_memories[i] << "\n";
}
if(flower_memories.size() > 5) cout << "......\n";
resetColor();
getchar();
Print("\n你坐在纪念碑前\n");
Print("风吹过,带来远方的花香\n");
Print("虽然这里已经没有花了\n");
Print("但你知道,它们活在你的记忆里\n");
getchar();
// 如果有小花
if(baby_flower_exists) {
Print("\n小花" + baby_flower_name + "的名字也在上面\n");
Print("你轻轻抚摸它的名字\n");
Print("“对不起,没能保护你”\n");
}
Print("\n你站起来\n");
Print("最后看了一眼纪念碑\n");
Print("然后转身离开\n");
Print("你知道,你要替它们活下去\n");
Print("替它们看这个世界\n");
Print("替它们记得彼此\n");
getchar();
setColor(14);
cout << "\n\n";
cout << " 纪念之花,永不凋零\n";
cout << " 每个名字,都是一个故事\n";
cout << " 每个故事,都是一段生命\n";
cout << " 每个生命,都值得被记住\n";
resetColor();
Print("\n【结局:复仇·纪念之花】\n");
Print("你为它们建了纪念碑,带着记忆活下去\n");
getchar();
ending_achieved = true;
ending_type = "revenge_memorial";
}
// ==================== 原有结局 ====================
void ending_despair() {
system("cls");
setColor(8);
cout << "\n\n\n";
cout << " ╔════════════════════════╗\n";
cout << " ║ 结局:绝望之花 ║\n";
cout << " ╚════════════════════════╝\n\n\n";
resetColor();
Sleep(1500);
Print("你选择放弃\n");
Print("闭上眼睛,等待消失\n");
Print("什么都没有了\n");
Print("花世界永远消失\n");
Print("\n");
Print("没有记忆,没有痕迹\n");
Print("就像从未存在过\n");
getchar();
ending_achieved = true;
ending_type = "despair";
}
void ending_hope() {
system("cls");
setColor(14);
cout << "\n\n\n";
cout << " ╔════════════════════════╗\n";
cout << " ║ 结局:希望之花 ║\n";
cout << " ╚════════════════════════╝\n\n\n";
resetColor();
Sleep(1500);
Print("你想起小花问“我们去哪”\n");
Print("你说:“去有花的地方”\n");
Print("你闭上眼睛,用力想\n");
Print("想第一朵花的样子\n");
Print("想它们的笑容\n");
Print("想它们的名字\n");
getchar();
Print("\n你睁开眼睛\n");
Print("发现自己站在一片草地上\n");
Print("周围全是花\n");
Print("是它们,所有消失的花\n");
getchar();
Print("\n它们说:“你终于来了”\n");
Print("你说:“这是哪?”\n");
Print("它们说:“你的心里”\n");
getchar();
setColor(10);
cout << "\n\n";
cout << " 花 花 花 花 花\n";
cout << " 花 花\n";
cout << " 花 你在这里 花\n";
cout << " 花 花\n";
cout << " 花 花 花 花\n";
resetColor();
Print("\n【结局:心之所向】\n");
getchar();
ending_achieved = true;
ending_type = "hope";
}
void ending_rebirth() {
system("cls");
setColor(10);
cout << "\n\n\n";
cout << " ╔════════════════════════╗\n";
cout << " ║ 结局:重生之花 ║\n";
cout << " ╚════════════════════════╝\n\n\n";
resetColor();
Sleep(1500);
Print("你不甘心\n");
Print("你收集所有花的记忆\n");
Print("把它们种在心里\n");
Print("然后闭上眼睛\n");
getchar();
Print("\n当你再次睁开\n");
Print("你变成了一朵花\n");
Print("一朵巨大的、金色的花\n");
Print("你的花瓣里,是所有花的故事\n");
getchar();
Print("\n新的花来了\n");
Print("它们读着你的花瓣\n");
Print("知道了曾经有个世界\n");
Print("知道了很多花\n");
Print("知道了一个叫“" + player_name + "”的朋友\n");
getchar();
setColor(11);
cout << "\n";
cout << " ╭────────────────────╮\n";
cout << " │ 花的故事永流传 │\n";
cout << " ╰────────────────────╯\n";
resetColor();
Print("\n【结局:永恒的传说】\n");
getchar();
ending_achieved = true;
ending_type = "rebirth";
}
void ending_true() {
system("cls");
setColor(13);
cout << "\n\n\n";
cout << " ╔════════════════════════╗\n";
cout << " ║ 真结局:超越末日 ║\n";
cout << " ╚════════════════════════╝\n\n\n";
resetColor();
Sleep(1500);
Print("在最后一刻,你突然想起\n");
Print("这不是第一次末日\n");
Print("你已经经历了无数次\n");
Print("每次都是同样的结局\n");
getchar();
Print("\n你想起第一部的冒险\n");
Print("想起第二部的规则\n");
Print("想起第三部的革命\n");
Print("想起每一朵花的名字\n");
getchar();
Print("\n你说:“我不接受”\n");
Print("病毒愣住了\n");
Print("你说:“花不是代码”\n");
Print("“它们是生命”\n");
Print("“生命不会消失”\n");
Print("“它们活在我的记忆里”\n");
getchar();
Print("\n病毒沉默了\n");
Print("然后消失了\n");
getchar();
Print("\n你睁开眼睛\n");
Print("发现自己在电脑前\n");
Print("屏幕上,花世界还在运行\n");
Print("所有的花都在\n");
Print("它们看着你,笑了\n");
getchar();
setColor(14);
cout << "\n";
cout << "花们:“就知道你不会放弃我们”\n";
cout << "你:“我永远不会”\n";
resetColor();
Print("\n【真结局:超越末日】\n");
getchar();
ending_achieved = true;
ending_type = "true";
}
// ==================== 剧情章节 ====================
void prologue() {
system("cls");
setColor(12);
cout << "╔══════════════════════════════════════╗\n";
cout << "║ 花世界·终焉:最后的绽放 ║\n";
cout << "╚══════════════════════════════════════╝\n\n";
resetColor();
Sleep(1500);
Print("你正在和花们聊天\n");
Print("突然,一朵小花开始闪烁\n");
Print("它的颜色变淡,身体变得透明\n");
getchar();
setColor(10);
Print("\n花:“我...我好困...”\n");
resetColor();
getchar();
Print("你伸手想抱住它\n");
Print("但它化作光点,消散了\n");
Print("连名字都没留下\n");
getchar();
setColor(12);
Print("\n【系统提示】检测到“删除代码”病毒\n");
Print("【系统提示】剩余存活时间:5天\n");
resetColor();
getchar();
Print("\n你愣住了\n");
Print("其他花围过来,它们也在害怕\n");
Print("但你从它们眼里看到的不是恐惧\n");
Print("而是对你的信任\n");
getchar();
initFlowers();
showStatus();
getchar();
}
void day1_survival() {
system("cls");
PrintBlue("=== 第一天:避难所 ===\n\n");
Print("你清点幸存的花们\n");
Print("有的受伤了,有的在哭,有的还在坚强\n");
getchar();
// 选择1:优先救治谁?
Print("\n选择优先救治谁?\n");
Print("A. 受伤最重的(消耗资源多,可能救不活)\n");
Print("B. 受伤最轻的(消耗资源少,能救更多)\n");
Print("C. 情绪崩溃的(不需要资源,需要安慰)\n");
char choice = getch();
if(choice == 'A' || choice == 'a') {
sunlight -= 30;
dew -= 20;
compassion += 10;
justice -= 5;
PrintGreen("\n你选择了救治最重的花,它们很感动\n");
}
else if(choice == 'B' || choice == 'b') {
sunlight -= 15;
dew -= 10;
justice += 10;
compassion -= 5;
PrintYellow("\n你选择了救治最轻的花,救活了更多\n");
}
else {
hope += 10;
compassion += 5;
PrintPurple("\n你选择了安慰情绪崩溃的花,它们平静下来\n");
}
getchar();
// 中午:加固避难所
Print("\n你发现避难所不够坚固,外面有“删除风”在吹\n");
Print("选择加固方式:\n");
Print("1.用木头(容易获得,但不够坚固)\n");
Print("2.用石头(难获得,但很坚固)\n");
Print("3.用花瓣(花们自愿贡献,但会受伤)\n");
choice = getch();
if(choice == '1') {
sunlight -= 10;
shelter_level = 1;
PrintYellow("\n你用木头加固了避难所,勉强能用\n");
}
else if(choice == '2') {
sunlight -= 30;
shelter_level = 2;
PrintGreen("\n你用石头加固了避难所,非常坚固\n");
}
else {
for(int i = 0; i < alive_flowers; i++) {
flower_health[i] -= 10;
}
shelter_level = 3;
compassion += 15;
revenge += 5; // 花受伤增加复仇值
PrintPurple("\n花们贡献了花瓣,避难所充满了温暖\n");
}
getchar();
// 傍晚:陌生花敲门
Print("\n傍晚,一个陌生的花来到避难所外\n");
Print("它敲着门:“让我进去...求你们...”\n");
Print("\n选择:\n");
Print("1.开门(可能是幸存者,可能是病毒伪装)\n");
Print("2.不开门(安全,但可能害死真幸存者)\n");
Print("3.先观察(消耗时间)\n");
choice = getch();
if(choice == '1') {
if(rand() % 100 < 70) {
PrintGreen("\n它是真幸存者!加入了你们\n");
flower_names.push_back("小客");
flower_health.push_back(50);
flower_trust.push_back(60);
flower_infected.push_back(false);
flower_memories.push_back("谢谢你们收留我");
alive_flowers++;
total_flowers++;
compassion += 10;
}
else {
PrintRed("\n它是病毒伪装!感染了避难所\n");
for(int i = 0; i < min(3, alive_flowers); i++) {
flower_infected[rand() % alive_flowers] = true;
}
revenge += 10; // 被骗增加复仇值
}
}
else if(choice == '2') {
PrintYellow("\n你没有开门,外面的声音渐渐消失了\n");
justice += 5;
}
else {
PrintBlue("\n你观察了很久,它最后离开了\n");
hope -= 5;
}
getchar();
// 第一夜事件
system("cls");
PrintPurple("=== 第一夜 ===\n\n");
Print("你睡不着,听到外面有声音\n");
Print("是花们在唱歌\n");
Print("它们用最后的力气唱给自己听\n");
Print("你在黑暗里哭了\n");
getchar();
decreaseResources();
checkDeaths();
randomEvent();
showStatus();
getchar();
}
void day2_resources() {
system("cls");
PrintBlue("=== 第二天:资源争夺 ===\n\n");
Print("早晨,阳光资源突然减少\n");
Print("原来是另一群幸存花也在收集\n");
Print("它们站在远处,看着你们\n");
getchar();
// 选择1:如何对待其他幸存者
Print("\n如何对待其他幸存者?\n");
Print("A. 分享资源(可能不够分)\n");
Print("B. 独占资源(它们会恨你)\n");
Print("C. 谈判合作(需要时间)\n");
char choice = getch();
if(choice == 'A' || choice == 'a') {
sunlight -= 20;
dew -= 10;
compassion += 15;
hope += 5;
PrintGreen("\n你选择了分享,它们很感激\n");
met_strangers = true;
}
else if(choice == 'B' || choice == 'b') {
justice += 10;
hope -= 5;
revenge += 8; // 独占资源增加复仇值
PrintRed("\n你选择了独占,它们愤怒地离开了\n");
}
else {
sunlight -= 5;
hope += 10;
PrintYellow("\n你选择了谈判,达成合作协议\n");
met_strangers = true;
}
getchar();
// 中午:发现代码泉
Print("\n中午,你的花们发现了一个“代码泉”\n");
Print("泉水可以修复受损代码,但只够救3朵花\n");
Print("\n选择让谁去?\n");
Print("1.受伤最重的\n");
Print("2.最年轻的花\n");
Print("3.最老的花\n");
Print("4.抽签(公平但残忍)\n");
choice = getch();
if(choice == '1') {
compassion += 10;
for(int i = 0; i < min(3, alive_flowers); i++) {
if(flower_health[i] < 50) {
flower_health[i] = 100;
PrintGreen(flower_names[i] + "被治好了!\n");
break;
}
}
}
else if(choice == '2') {
hope += 10;
for(int i = 0; i < min(3, alive_flowers); i++) {
flower_health[i] = 100;
PrintGreen("年轻的花" + flower_names[i] + "恢复了活力\n");
break;
}
}
else if(choice == '3') {
justice += 10;
for(int i = alive_flowers-1; i >= max(0, alive_flowers-3); i--) {
flower_health[i] = 100;
PrintGreen("老花" + flower_names[i] + "得到了救治\n");
break;
}
}
else {
vector<int> indices;
for(int i = 0; i < alive_flowers; i++) indices.push_back(i);
random_shuffle(indices.begin(), indices.end());
for(int i = 0; i < min(3, (int)indices.size()); i++) {
flower_health[indices[i]] = 100;
PrintGreen(flower_names[indices[i]] + "被抽中治好了\n");
}
}
getchar();
// 傍晚:合并提议
if(met_strangers) {
Print("\n傍晚,另一群幸存者的首领来找你\n");
Print("它说:“我们合并吧,一起活下去”\n");
Print("\n选择:\n");
Print("1.合并(人多力量大,但资源更紧张)\n");
Print("2.不合并(保持独立,但可能被孤立)\n");
Print("3.让他们加入,但保持主导权\n");
choice = getch();
if(choice == '1') {
alive_flowers += 5;
total_flowers += 5;
sunlight -= 30;
dew -= 20;
compassion += 10;
PrintGreen("\n你们合并了,现在有更多花了\n");
}
else if(choice == '2') {
justice += 10;
hope -= 5;
revenge += 5; // 拒绝合作增加复仇值
PrintYellow("\n你拒绝了合并,它们失望地走了\n");
}
else {
hope += 5;
PrintBlue("\n你主导了合并,秩序井然\n");
}
getchar();
}
// 第二夜事件
system("cls");
PrintPurple("=== 第二夜 ===\n\n");
Print("你发现有个花在偷偷藏食物\n");
Print("你问它为什么\n");
Print("它说:“我怕你抛弃我”\n");
Print("你抱住它:“永远不会”\n");
getchar();
decreaseResources();
checkDeaths();
randomEvent();
showStatus();
getchar();
}
void day3_betrayal() {
system("cls");
PrintBlue("=== 第三天:背叛与牺牲 ===\n\n");
Print("早晨,有人举报:昨晚有花偷了公共食物\n");
getchar();
// 选择1:如何处置
Print("\n如何处置偷食物的花?\n");
Print("A. 公开审判(公正但伤害感情)\n");
Print("B. 私下原谅(仁慈但可能纵容)\n");
Print("C. 装作不知道(逃避问题)\n");
char choice = getch();
string thief_name = flower_names[rand() % alive_flowers];
if(choice == 'A' || choice == 'a') {
justice += 15;
compassion -= 5;
for(int i = 0; i < alive_flowers; i++) {
flower_trust[i] -= 5;
}
PrintRed("\n你公开审判了" + thief_name + ",它很伤心\n");
Print("真相是:它偷食物是为了喂快死的朋友\n");
revenge += 5; // 不公正审判增加复仇值
}
else if(choice == 'B' || choice == 'b') {
compassion += 15;
justice -= 5;
PrintGreen("\n你私下原谅了" + thief_name + ",它哭着感谢你\n");
Print("它说它的朋友还是没挺过去...\n");
}
else {
hope -= 10;
PrintYellow("\n你装作不知道,但气氛很尴尬\n");
}
getchar();
// 中午:被攻击
Print("\n中午,另一群幸存者突然攻击你们\n");
Print("它们说:“资源不够,只能抢你们的”\n");
getchar();
Print("\n如何应对?\n");
Print("1.防守(保护自己的花)\n");
Print("2.谈判(尝试和解)\n");
Print("3.反击(打退它们)\n");
choice = getch();
if(choice == '1') {
int injured = rand() % 3 + 1;
for(int i = 0; i < injured; i++) {
int idx = rand() % alive_flowers;
flower_health[idx] -= 30;
PrintRed(flower_names[idx] + "受伤了!\n");
}
justice += 5;
revenge += 5; // 被攻击增加复仇值
}
else if(choice == '2') {
if(rand() % 100 < 50) {
PrintGreen("\n谈判成功!它们退走了\n");
hope += 10;
}
else {
PrintRed("\n谈判失败,它们抢走了资源\n");
sunlight -= 30;
dew -= 20;
hope -= 5;
revenge += 10; // 被抢增加复仇值
}
}
else {
PrintRed("\n你选择了反击,打退了它们\n");
justice += 10;
compassion -= 5;
revenge += 15; // 反击成功增加复仇值
}
getchar();
// 傍晚:发现真相
Print("\n傍晚,你发现一个可怕的事实:\n");
Print("病毒不是外来的\n");
Print("是系统为了“优化”而启动的\n");
Print("你们是“冗余代码”,要被清理\n");
getchar();
Print("\n告诉花们真相吗?\n");
Print("1.告诉(绝望,但真实)\n");
Print("2.隐瞒(保护,但欺骗)\n");
Print("3.只说一部分\n");
choice = getch();
if(choice == '1') {
for(int i = 0; i < alive_flowers; i++) {
flower_trust[i] += 10;
hope -= 10;
}
PrintPurple("\n你告诉了它们真相,花们沉默了\n");
Print("一朵小花说:“没关系,至少最后的时光有你”\n");
revenge += 10; // 知道真相增加复仇值
}
else if(choice == '2') {
for(int i = 0; i < alive_flowers; i++) {
flower_trust[i] -= 5;
hope += 5;
}
PrintYellow("\n你选择了隐瞒,花们还在努力\n");
}
else {
hope += 5;
PrintBlue("\n你只说了一部分,花们半信半疑\n");
}
getchar();
// 第三夜事件
system("cls");
PrintPurple("=== 第三夜 ===\n\n");
Print("你做了一个梦\n");
Print("梦见自己也是一朵花\n");
Print("梦见自己被删除的那一刻\n");
Print("醒来时,脸上有泪\n");
getchar();
betrayed = true;
decreaseResources();
checkDeaths();
randomEvent();
showStatus();
getchar();
}
void day4_hope() {
system("cls");
PrintBlue("=== 第四天:希望的碎片 ===\n\n");
Print("早晨,资源几乎耗尽\n");
Print("只剩最后一点阳光,只够撑到今晚\n");
getchar();
// 选择1:如何使用最后资源
Print("\n如何使用最后资源?\n");
Print("1.平均分配(大家都活一点)\n");
Print("2.集中给最强壮的(保送希望)\n");
Print("3.给最弱的(临终关怀)\n");
char choice = getch();
if(choice == '1') {
for(int i = 0; i < alive_flowers; i++) {
flower_health[i] += 10;
}
justice += 10;
PrintGreen("\n你平均分配了资源,大家都得到一点\n");
}
else if(choice == '2') {
int strongest = 0;
for(int i = 1; i < alive_flowers; i++) {
if(flower_health[i] > flower_health[strongest]) {
strongest = i;
}
}
flower_health[strongest] = 100;
hope += 10;
PrintGreen(flower_names[strongest] + "得到了全力救治\n");
}
else {
int weakest = 0;
for(int i = 1; i < alive_flowers; i++) {
if(flower_health[i] < flower_health[weakest]) {
weakest = i;
}
}
flower_health[weakest] = 50;
compassion += 15;
PrintPurple("你陪在" + flower_names[weakest] + "身边,它平静了许多\n");
}
getchar();
// 中午:发现种子
Print("\n中午,一朵老花找到你\n");
Print("它说它年轻时藏了一些“种子”\n");
Print("种下去可以长出新花\n");
Print("但需要露水和阳光,而你只剩最后一点\n");
getchar();
Print("\n种吗?\n");
Print("1.种(新生命,但消耗最后资源)\n");
Print("2.不种(保守,但没希望)\n");
Print("3.种一半(试试看)\n");
choice = getch();
if(choice == '1') {
sunlight -= 50;
dew -= 30;
planted_seed = true;
hope += 20;
PrintGreen("\n你种下了种子,期待着新生\n");
}
else if(choice == '2') {
hope -= 10;
PrintYellow("\n你决定不种,资源太宝贵了\n");
}
else {
sunlight -= 25;
dew -= 15;
planted_seed = true;
hope += 5;
PrintBlue("\n你种了一半种子,希望能发芽\n");
}
getchar();
// 傍晚:种子发芽
if(planted_seed && rand() % 100 < 70) {
Print("\n傍晚,种子发芽了!\n");
Print("是一朵小花,它看着你,说:\n");
setColor(10);
Print("“妈妈?”\n");
resetColor();
getchar();
Print("\n所有花都哭了\n");
Print("这是四天来第一个新生命\n");
getchar();
Print("\n给小花起什么名字?\n");
Print("1.希望\n");
Print("2.明天\n");
Print("3.延续\n");
Print("4.输入自定义名字\n");
choice = getch();
if(choice == '1') {
baby_flower_name = "希望";
}
else if(choice == '2') {
baby_flower_name = "明天";
}
else if(choice == '3') {
baby_flower_name = "延续";
}
else {
cout << "请输入名字: ";
cin >> baby_flower_name;
}
flower_names.push_back(baby_flower_name);
flower_health.push_back(100);
flower_trust.push_back(100);
flower_infected.push_back(false);
flower_memories.push_back("我是第一天出生的花");
alive_flowers++;
total_flowers++;
baby_flower_exists = true;
PrintGreen("\n小花" + baby_flower_name + "诞生了!\n");
}
getchar();
// 第四夜事件
system("cls");
PrintPurple("=== 第四夜 ===\n\n");
Print("你抱着小花\n");
Print("它不知道世界要毁灭了\n");
Print("它只是觉得在你怀里很温暖\n");
getchar();
Print("所有花围成一圈,中间是小花\n");
Print("它们开始讲自己的故事\n");
Print("讲怎么认识你的\n");
Print("讲第一次开花\n");
Print("讲最快乐的时光\n");
Print("小花听着,睡着了\n");
getchar();
decreaseResources();
checkDeaths();
randomEvent();
showStatus();
getchar();
}
void day5_final() {
system("cls");
PrintBlue("=== 第五天:最后的绽放 ===\n\n");
Print("最后一天了\n");
Print("病毒已经开始侵蚀避难所\n");
Print("墙壁在消失,地面在消失,天空在消失\n");
Print("你看着花们,它们也看着你\n");
getchar();
// 选择1:最后的时间做什么
Print("\n最后的时间做什么?\n");
Print("A. 一起唱歌(用最后的时光快乐)\n");
Print("B. 互相告别(认真说再见)\n");
Print("C. 沉默陪伴(什么都不用说)\n");
char choice = getch();
if(choice == 'A' || choice == 'a') {
hope += 20;
PrintPurple("\n你们一起唱歌,唱所有会唱的歌\n");
Print("花们的声音越来越小,但一直在唱\n");
}
else if(choice == 'B' || choice == 'b') {
compassion += 15;
PrintBlue("\n你和每一朵花告别\n");
Print("它们说着感谢的话,说着最深的记忆\n");
}
else {
justice += 10;
PrintGreen("\n你只是抱着它们,什么也没说\n");
Print("但你们懂彼此的心\n");
}
getchar();
// 中午:花开始消失
system("cls");
Print("\n中午,避难所只剩一半了\n");
Print("花们开始消失\n");
Print("一朵、两朵、三朵...\n");
getchar();
for(int i = 0; i < min(5, alive_flowers); i++) {
int idx = rand() % alive_flowers;
PrintRed(flower_names[idx] + "消失了,它最后说:“" + flower_memories[idx] + "”\n");
flower_names.erase(flower_names.begin() + idx);
flower_health.erase(flower_health.begin() + idx);
flower_trust.erase(flower_trust.begin() + idx);
flower_infected.erase(flower_infected.begin() + idx);
flower_memories.erase(flower_memories.begin() + idx);
alive_flowers--;
revenge += 3; // 每消失一朵花增加复仇值
Sleep(1000);
}
getchar();
// 傍晚:只剩最后一朵
Print("\n傍晚,只剩最后一朵花了\n");
if(baby_flower_exists && alive_flowers > 0 && flower_names[0] == baby_flower_name) {
Print("是小花" + baby_flower_name + "\n");
Print("它抱着你,问:“妈妈,我们要去哪?”\n");
}
else if(alive_flowers > 0) {
Print("是" + flower_names[0] + "\n");
Print("它看着你,问:“我们要去哪?”\n");
}
else {
Print("没有花了,只剩你一个人\n");
}
getchar();
if(alive_flowers > 0) {
Print("\n你最后的话:\n");
Print("1.“我爱你”(最简单)\n");
Print("2.“对不起,没能保护好你”(最愧疚)\n");
Print("3.“等我”(最执着)\n");
Print("4.沉默(最痛)\n");
choice = getch();
if(choice == '1') {
memory_fragments += 10;
PrintPurple("\n“我爱你”\n");
}
else if(choice == '2') {
compassion += 20;
PrintRed("\n“对不起,没能保护好你”\n");
revenge += 10; // 愧疚增加复仇值
}
else if(choice == '3') {
hope += 20;
PrintYellow("\n“等我”\n");
}
else {
justice += 10;
Print("\n你什么都没说,只是抱紧了它\n");
}
getchar();
// 最后一朵花消失
Print("\n最后一朵花也开始消散了\n");
Print("从脚开始,慢慢往上\n");
Print("它不哭,只是看着你\n");
Print("直到最后一刻\n");
getchar();
}
Print("\n最后只剩你了\n");
Print("你站在虚无中\n");
Print("周围什么都没有\n");
Print("连自己也在消失\n");
getchar();
// 终章:选择结局
system("cls");
setColor(12);
cout << "╔════════════════════════════════╗\n";
cout << "║ 终章:选择 ║\n";
cout << "╚════════════════════════════════╝\n\n";
resetColor();
Print("病毒问你:“你要怎么结束?”\n");
getchar();
Print("\n你的选择:\n");
Print("1.放弃(绝望之花)\n");
Print("2.回忆(希望之花)\n");
Print("3.传承(重生之花)\n");
Print("4.超越(真结局)\n");
Print("5.复仇(直面病毒)\n"); // 新增复仇选项
choice = getch();
if(choice == '1') {
ending_despair();
}
else if(choice == '2') {
ending_hope();
}
else if(choice == '3') {
ending_rebirth();
}
else if(choice == '4') {
if(memory_fragments >= 20 && compassion >= 70 && hope >= 70 && justice >= 70) {
ending_true();
}
else {
PrintRed("\n条件不足,无法超越...\n");
Print("按任意键重新选择...\n");
getch();
day5_final(); // 重新选择
}
}
else if(choice == '5') {
if(revenge >= 50) { // 需要足够的复仇值
PrintRed("\n你选择了复仇!\n");
Print("复仇值: " + to_string(revenge) + "/50\n");
getchar();
bool victory = revengeBattle();
if(victory) {
system("cls");
PrintGreen("\n你击败了病毒!\n");
PrintGreen("现在,你可以选择:\n\n");
Print("1.牺牲自己,用记忆复活所有花(需要记忆碎片≥20)\n");
Print("2.为它们建纪念碑,带着记忆活下去\n");
char final_choice = getch();
if(final_choice == '1') {
if(memory_fragments >= 20) {
ending_revenge_sacrifice();
}
else {
PrintRed("\n记忆碎片不足,无法复活...\n");
Print("自动选择纪念结局\n");
getchar();
ending_revenge_memorial();
}
}
else {
ending_revenge_memorial();
}
}
else {
// 战斗失败,自动进入绝望结局
ending_despair();
}
}
else {
PrintRed("\n你的复仇之心不够强烈!\n");
Print("当前复仇值: " + to_string(revenge) + "/50\n");
Print("按任意键重新选择...\n");
getch();
day5_final(); // 重新选择
}
}
else {
ending_despair();
}
}
// ==================== 游戏主函数 ====================
void playGame() {
prologue();
while(day <= 5 && alive_flowers > 0 && !ending_achieved) {
switch(day) {
case 1: day1_survival(); break;
case 2: day2_resources(); break;
case 3: day3_betrayal(); break;
case 4: day4_hope(); break;
case 5: day5_final(); break;
}
day++;
remaining_time--;
if(alive_flowers <= 0) {
PrintRed("\n所有花都凋谢了...\n");
getchar();
ending_despair();
break;
}
}
}
// ==================== 主函数 ====================
int main() {
srand(time(0));
SetConsoleTitle("花世界·终焉:最后的绽放");
system("cls");
setColor(12);
cout << "╔══════════════════════════════════════╗\n";
cout << "║ 花世界·终焉:最后的绽放 ║\n";
cout << "║ by xiaobb ║\n";
cout << "╚══════════════════════════════════════╝\n\n";
resetColor();
cout << "请输入你的名字: ";
cin >> player_name;
system("cls");
Print("这是一个关于末日的故事,有点刀,请准备好卫生纸\n");
Print("关于失去,关于珍惜,关于告别\n");
Print("你的每一个选择,都会影响结局\n");
Print("\n准备好了吗?\n");
Print("按任意键开始...\n");
getch();
playGame();
// 结局总结
system("cls");
setColor(12);
cout << "╔══════════════════════════════════════╗\n";
cout << "║ 游戏结束 ║\n";
cout << "╚══════════════════════════════════════╝\n\n";
resetColor();
if(ending_type == "true") {
PrintPurple("你达成了真结局:超越末日\n");
}
else if(ending_type == "hope") {
PrintGreen("你达成了结局:希望之花\n");
}
else if(ending_type == "rebirth") {
PrintBlue("你达成了结局:重生之花\n");
}
else if(ending_type == "revenge_sacrifice") {
setColor(12);
cout << "你达成了结局:复仇·牺牲之花\n";
resetColor();
}
else if(ending_type == "revenge_memorial") {
setColor(14);
cout << "你达成了结局:复仇·纪念之花\n";
resetColor();
}
else {
PrintRed("你达成了结局:绝望之花\n");
}
cout << "\n";
setColor(8);
cout << "最终统计:\n";
cout << "记忆碎片: " << memory_fragments << "\n";
cout << "怜悯值: " << compassion << "\n";
cout << "公正值: " << justice << "\n";
cout << "希望值: " << hope << "\n";
cout << "复仇值: " << revenge << "\n";
cout << "\n";
cout << "创造者:xiaobb\n";
cout << "特别鸣谢:所有花,还有玩游戏的你\n";
cout << "\n花会凋谢,但记忆永存\n";
cout << "\n按任意键退出...";
resetColor();
getch();
return 0;
}