跳到正文

休闲·娱乐

脑叶小游戏

yiwugougou约 8 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年7月19日
篇幅
约 8 分钟

版本

  1. v1当前
C++
#include <bits/stdc++.h>
using namespace std;
string s[6]={"Unkown","ZAYIN","TETH","HE","WAW","ALEPH"};
// 员工类
class Employee {
public:
    std::string name; // 员工名字
    int health;      // 生命值
    int skill;       // 技能值

    Employee(std::string n, int h, int s) : name(n), health(h), skill(s) {}

    // 受到伤害
    void takeDamage(int damage) {
        health -= damage;
        if (health < 0) health = 0;
    }

    // 判断是否存活
    bool isAlive() const {
        return health > 0;
    }
};

// 异常实体类
class Abnormality {
public:
    std::string name;       // 异常实体名字
    int dangerLevel;       // 危险等级
    bool isContained;       // 是否被收容

    Abnormality(std::string n, int d) : name(n), dangerLevel(d), isContained(true) {}

    // 突破收容
    void breach() {
        isContained = false;
        std::cout << name << " 突破了收容!\n";
    }

    // 与员工交互
    void interact(Employee& employee) {
        if (!isContained) {
            int damage = dangerLevel * 10;
            employee.takeDamage(damage);
            std::cout << employee.name << " 受到了 " << damage << " 点伤害,来自 " << name << "!\n";
        } else {
            std::cout << name << " 被成功收容。收集到能量!\n";
        }
    }
};

// 游戏管理类
class Game {
public:
    std::vector<Employee> employees;    // 员工列表
    std::vector<Abnormality> abnormalities; // 异常实体列表
    int energy; // 能量值

    Game() : energy(0) {
        // 初始化员工和异常实体
        employees.push_back(Employee("马克思", 140, 5));
        employees.push_back(Employee("弗兰力", 160, 5));
        employees.push_back(Employee("朱丽叶", 180, 4));
        employees.push_back(Employee("XJ", 200, 5));
        employees.push_back(Employee("DHX", 170, 5));
        employees.push_back(Employee("XYY", 160, 5));
        employees.push_back(Employee("DYC", 190, 5));
        employees.push_back(Employee("GRJ", 200, 5));
        abnormalities.push_back(Abnormality("焦化少女", 2));
        abnormalities.push_back(Abnormality("一罪与百善", 1));
        abnormalities.push_back(Abnormality("[一无所有]", 5));
        abnormalities.push_back(Abnormality("惩戒鸟", 2));
        abnormalities.push_back(Abnormality("大鸟", 4));
        abnormalities.push_back(Abnormality("审判鸟", 4));
    }

    // 游戏主循环
    void play() {
        srand(time(0));
        while (true) {
            std::cout << "当前能量: " << energy << "\n";
            std::cout << "请选择要处理的异常实体:\n";
            for (int i = 0; i < abnormalities.size(); ++i) {
                std::cout << i + 1 << ". " << abnormalities[i].name
                          <<"  "<< s[abnormalities[i].dangerLevel]<< "\n";
            }

            int choice;
            std::cin >> choice;
            choice--;

            if (choice < 0 || choice >= abnormalities.size()) {
                std::cout << "选择无效!\n";
                continue;
            }

            std::cout << "请选择派遣的员工:\n";
            for (int i = 0; i < employees.size(); ++i) {
                std::cout << i + 1 << ". " << employees[i].name
                          << " (生命值: " << employees[i].health
                          << ", 技能值: " << employees[i].skill << ")\n";
            }

            int empChoice;
            std::cin >> empChoice;
            empChoice--;

            if (empChoice < 0 || empChoice >= employees.size()) {
                std::cout << "选择无效!\n";
                continue;
            }

            abnormalities[choice].interact(employees[empChoice]);

            if (!employees[empChoice].isAlive()) {
                std::cout << employees[empChoice].name << " 已死亡!\n";
                employees.erase(employees.begin() + empChoice);
            }

            if (employees.empty()) {
                std::cout << "所有员工均已死亡。游戏结束!\n";
                break;
            }

            // 随机突破收容事件
            if (rand() % 10 < 2) {
                abnormalities[rand() % abnormalities.size()].breach();
            }

            energy += 10; // 每次成功处理增加能量
        }
    }
};

int main() {
    Game game;
    game.play();
    return 0;
}
原文