跳到正文

个人记录

柏林陷落1.0.0-sc

YYCWD约 120 分钟
原文
文章信息与版本

文章信息

发布
2025年10月8日
收录
2025年12月12日
更新
2026年11月17日
篇幅
约 120 分钟

版本

  1. v2当前
  2. v1
C++
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <cstdio>

#ifdef _WIN32
    #include <windows.h>
#else
    #include <unistd.h>
#endif

using namespace std;

void delay_ms(int milliseconds) {
#ifdef _WIN32
    Sleep(milliseconds);
#else
    usleep(milliseconds * 1000);
#endif
}

void slowsay(const string& text, int delay = 30) {
    for (size_t i = 0; i < text.size(); ++i) {
        cout << text[i] << flush;
        if (text[i] == '.' || text[i] == '!' || text[i] == '?') {
            delay_ms(500);
        } else if (text[i] == ',') {
            delay_ms(200);
        } else {
            delay_ms(delay);
        }
    }
    cout << endl;
}

class City {
private:
    string name;
    int defenseLevel;
    bool isControlled;
    bool hasFortifications;
    string specialty;
    int resourceProduction;

public:
    City(string n, int def, bool fortified, string spec, int production)
        : name(n), defenseLevel(def), isControlled(true),
          hasFortifications(fortified), specialty(spec), resourceProduction(production) {}

    string getName() const { return name; }
    int getDefenseLevel() const { return defenseLevel; }
    bool isUnderControl() const { return isControlled; }
    bool hasFortress() const { return hasFortifications; }
    string getSpecialty() const { return specialty; }
    int getResourceProduction() const { return resourceProduction; }

    void upgradeDefenses(int amount) {
        if (specialty == "industry") {
            amount = static_cast<int>(amount * 1.2);
        }
        defenseLevel += amount;
        if (defenseLevel > 100) defenseLevel = 100;
        slowsay(name + "的防御等级提升至" + stringify(defenseLevel) + "!");
    }

    void damageDefenses(int amount) {
        if (specialty == "capital" || specialty == "fortress") {
            amount = static_cast<int>(amount * 0.8);
        }
        defenseLevel -= amount;
        if (defenseLevel < 0) defenseLevel = 0;
    }

    void capture() {
        if (isControlled) {
            isControlled = false;
            slowsay(name + "已被盟军攻占!防线出现缺口!");
        }
    }

    void recapture() {
        if (!isControlled) {
            isControlled = true;
            defenseLevel = 30 + rand() % 20;
            slowsay(name + "被成功收复!市民欢呼雀跃!");
        }
    }

    int produceResources() const {
        if (isControlled) {
            return resourceProduction;
        }
        return 0;
    }

    string stringify(int num) const {
        char buffer[20];
        sprintf(buffer, "%d", num);
        return string(buffer);
    }
};

class GameState {
private:
    int morale;
    int troops;
    int nationalGuerrillas;
    int tanks;
    int heavyTanks;
    int aircraft;
    int supplies;
    int fuel;
    int alliesPressure;
    int turn;
    bool gameOver;
    bool victory;
    vector<City> cities;
    int reputation;

    bool abilityEmergencyDraft;
    bool abilityMoraleBoost;
    bool abilityTacticalRetreat;

    vector<string> medals;

public:
    GameState() : morale(55), troops(7500), nationalGuerrillas(4500),  // 降低初始兵力和士气
                 tanks(35), heavyTanks(15), aircraft(20),
                 supplies(450), fuel(550), alliesPressure(70),  // 提高初始盟军压力
                 turn(1), gameOver(false), victory(false), reputation(50),
                 abilityEmergencyDraft(false), abilityMoraleBoost(false),
                 abilityTacticalRetreat(false) {
        srand((unsigned int)time(NULL));

        cities.push_back(City("柏林", 55, true, "capital", 15));       // 降低初始防御
        cities.push_back(City("德累斯顿", 35, false, "industry", 20));
        cities.push_back(City("汉堡", 35, true, "port", 25));
        cities.push_back(City("慕尼黑", 20, false, "arsenal", 10));
        cities.push_back(City("柯尼斯堡", 30, true, "fortress", 5));
        cities.push_back(City("鲁尔区", 25, false, "resources", 35));
        cities.push_back(City("法兰克福", 35, false, "transport", 15));
        cities.push_back(City("斯图加特", 35, false, "tech", 10));
    }

    int getMorale() const { return morale; }
    int getTroops() const { return troops; }
    int getNationalGuerrillas() const { return nationalGuerrillas; }
    int getTanks() const { return tanks; }
    int getHeavyTanks() const { return heavyTanks; }
    int getAircraft() const { return aircraft; }
    int getSupplies() const { return supplies; }
    int getFuel() const { return fuel; }
    int getAlliesPressure() const { return alliesPressure; }
    int getTurn() const { return turn; }
    bool isGameOver() const { return gameOver; }
    bool isVictory() const { return victory; }
    int getReputation() const { return reputation; }
    vector<City>& getCities() { return cities; }
    const vector<City>& getCities() const { return cities; }
    vector<string> getMedals() const { return medals; }

    bool hasEmergencyDraft() const { return abilityEmergencyDraft; }
    bool hasMoraleBoost() const { return abilityMoraleBoost; }
    bool hasTacticalRetreat() const { return abilityTacticalRetreat; }

    bool allCitiesLost() const {
        for (size_t i = 0; i < cities.size(); ++i) {
            if (cities[i].isUnderControl()) return false;
        }
        return true;
    }

    bool hasMajorCities() const {
        for (size_t i = 0; i < cities.size(); ++i) {
            if (cities[i].isUnderControl() && cities[i].hasFortress()) {
                return true;
            }
        }
        return false;
    }

    bool hasLostCities() const {
        for (size_t i = 0; i < cities.size(); ++i) {
            if (!cities[i].isUnderControl()) {
                return true;
            }
        }
        return false;
    }

    vector<int> getLostCitiesIndices() const {
        vector<int> lostIndices;
        for (size_t i = 0; i < cities.size(); ++i) {
            if (!cities[i].isUnderControl()) {
                lostIndices.push_back(i);
            }
        }
        return lostIndices;
    }

    bool canRecaptureCities() const {
        return hasLostCities() && morale > 80;  // 提高夺回城市的士气要求
    }

    bool attemptRecaptureCity(int cityIndex) {
        if (cityIndex < 0 || static_cast<size_t>(cityIndex) >= cities.size()) {
            return false;
        }

        City& targetCity = cities[cityIndex];
        if (targetCity.isUnderControl()) {
            return false;
        }

        int cityImportance = 1;
        if (targetCity.getSpecialty() == "capital") cityImportance = 1.8;  // 提高重要城市难度
        else if (targetCity.getSpecialty() == "resources" || targetCity.getSpecialty() == "transport") cityImportance = 1.5;

        // 降低夺回成功率
        int successChance = 35;  // 基础成功率从30%降至20%
        successChance += (troops + nationalGuerrillas) / 400;  // 每800名士兵增加1%(原为500)
        successChance += (tanks + heavyTanks * 2) / 2;  // 坦克加成减半
        successChance += reputation / 4;  // 声望加成降低

        successChance = static_cast<int>(successChance / cityImportance);
        if (successChance > 50) successChance = 55;  // 最高成功率从60%降至50%
        if (successChance < 10) successChance = 15;  // 最低成功率从20%降至10%

        bool success = (rand() % 100) < successChance;

        // 增加夺回行动的损失
        int baseLoss = success ? 2000 : 4000;  // 基础损失提高
        int troopLoss = static_cast<int>(baseLoss * cityImportance) + rand() % 1000;
        int guerrillaLoss = static_cast<int>(troopLoss * 0.8);  // 国民掷弹兵损失比例提高
        int tankLoss = static_cast<int>((5 + rand() % 10) * cityImportance * 1.2);  // 坦克损失增加20%
        int heavyTankLoss = static_cast<int>((3 + rand() % 7) * cityImportance * 1.2);
        int fuelCost = static_cast<int>((50 + rand() % 30) * cityImportance * 1.2);
        int supplyCost = static_cast<int>((80 + rand() % 40) * cityImportance * 1.2);

        updateTroops(-troopLoss);
        updateNationalGuerrillas(-guerrillaLoss);
        updateTanks(-tankLoss);
        updateHeavyTanks(-heavyTankLoss);
        updateFuel(-fuelCost);
        updateSupplies(-supplyCost);

        if (success) {
            targetCity.recapture();
            int moraleBoost = targetCity.getSpecialty() == "capital" ? 20 : 10 + rand() % 5;  // 降低士气提升
            int repBoost = targetCity.getSpecialty() == "capital" ? 15 : 5 + rand() % 5;  // 降低声望提升

            updateMorale(moraleBoost);
            updateReputation(repBoost);
            updateAlliesPressure(-(5 + rand() % 5));  // 降低压力缓解效果

            return true;
        } else {
            int moralePenalty = targetCity.getSpecialty() == "capital" ? 30 : 20 + rand() % 10;  // 提高失败惩罚
            int repPenalty = targetCity.getSpecialty() == "capital" ? 20 : 10 + rand() % 5;

            updateMorale(-moralePenalty);
            updateReputation(-repPenalty);
            updateAlliesPressure(20 + rand() % 10);  // 增加压力惩罚
            return false;
        }
    }

    void updateMorale(int change) {
        morale += change;
        if (morale < 0) morale = 0;
        if (morale > 100) morale = 100;
    }

    void updateTroops(int change) {
        troops += change;
        if (troops < 0) troops = 0;
    }

    void updateNationalGuerrillas(int change) {
        nationalGuerrillas += change;
        if (nationalGuerrillas < 0) nationalGuerrillas = 0;
    }

    void updateTanks(int change) {
        tanks += change;
        if (tanks < 0) tanks = 0;
    }

    void updateHeavyTanks(int change) {
        heavyTanks += change;
        if (heavyTanks < 0) heavyTanks = 0;
    }

    void updateAircraft(int change) {
        aircraft += change;
        if (aircraft < 0) aircraft = 0;
    }

    void updateSupplies(int change) {
        supplies += change;
        if (supplies < 0) supplies = 0;
    }

    void updateFuel(int change) {
        fuel += change;
        if (fuel < 0) fuel = 0;
    }

    void updateAlliesPressure(int change) {
        alliesPressure += change;
        if (alliesPressure < 0) alliesPressure = 0;
        if (alliesPressure > 100) alliesPressure = 100;
    }

    void updateReputation(int change) {
        int oldRep = reputation;
        reputation += change;
        if (reputation < 0) reputation = 0;
        if (reputation > 100) reputation = 100;

        checkAndUnlockAbilities(oldRep);
    }

    void checkAndUnlockAbilities(int oldRep) {
        // 提高技能解锁门槛
        if (!abilityEmergencyDraft && reputation >= 70 && oldRep < 70) {  // 从60提高到70
            abilityEmergencyDraft = true;
            slowsay("\n【声望技能解锁】紧急征兵:动员效率提升,士气影响降低!");
        }

        if (!abilityMoraleBoost && reputation >= 90 && oldRep < 90) {  // 从80提高到90
            abilityMoraleBoost = true;
            slowsay("\n【声望技能解锁】士气鼓舞:可随时使用一次大幅提升全军士气!");
        }

        if (!abilityTacticalRetreat && reputation >= 95 && oldRep < 95) {  // 从90提高到95
            abilityTacticalRetreat = true;
            slowsay("\n【声望技能解锁】战术撤退:撤退时损失降低50%,资源回收率提升!");
        }
    }

    void addMedal(string medal) {
        medals.push_back(medal);
        slowsay("获得勋章:" + medal + "!");
    }

    void nextTurn() {
        turn++;

        // 城市资源生产保持不变(满足不改变物资数量的要求)
        int totalResources = 0;
        for (size_t i = 0; i < cities.size(); ++i) {
            totalResources += cities[i].produceResources();
        }

        int supplyGain = static_cast<int>(totalResources * 0.6);
        int fuelGain = static_cast<int>(totalResources * 0.4);
        updateSupplies(supplyGain);
        updateFuel(fuelGain);

        if (totalResources > 0) {
            slowsay("\n各控制城市共生产了 " + stringify(totalResources) + " 单位资源:");
            slowsay("获得 " + stringify(supplyGain) + " 单位补给和 " + stringify(fuelGain) + " 单位燃料");
        }

        // 降低城市特色的正面效果
        for (size_t i = 0; i < cities.size(); ++i) {
            if (cities[i].isUnderControl()) {
                if (cities[i].getSpecialty() == "capital") {
                    updateMorale(1);  // 首都士气恢复从2降至1
                }
                else if (cities[i].getSpecialty() == "arsenal" && rand() % 100 < 20) {  // 概率从40%降至20%
                    int repair = 1;  // 修复数量从1-2降至固定1
                    updateTanks(repair);
                    slowsay(cities[i].getName() + "兵工厂修复了" + stringify(repair) + "辆坦克!");
                }
                else if (cities[i].getSpecialty() == "port" && rand() % 100 < 15) {  // 概率从30%降至15%
                    int supplyGain = 10 + rand() % 20;  // 数量减少
                    updateSupplies(supplyGain);
                    slowsay(cities[i].getName() + "港口获得了" + stringify(supplyGain) + "单位补给!");
                }
                else if (cities[i].getSpecialty() == "fortress" && rand() % 100 < 30) {  // 概率从50%降至30%
                    cities[i].upgradeDefenses(1 + rand() % 2);  // 修复量减少
                    slowsay(cities[i].getName() + "要塞自动修复了部分防御工事!");
                }
                else if (cities[i].getSpecialty() == "tech" && rand() % 100 < 15) {  // 概率从30%降至15%
                    slowsay(cities[i].getName() + "的情报部门提供了盟军部署信息!");
                    updateAlliesPressure(-(1 + rand() % 3));  // 效果减弱
                }
            }
        }
    }

    void checkGameOver() {
        // 延长胜利所需回合数(从15回合增至20回合)
        if (turn > 20) {
            gameOver = true;
            victory = true;
        }
        else if (troops + nationalGuerrillas <= 0 || morale <= 0 || allCitiesLost()) {
            gameOver = true;
            victory = false;
        }
    }

    void useMoraleBoost() {
        if (abilityMoraleBoost) {
            updateMorale(20);  // 效果从30降至20
            slowsay("\n【使用士气鼓舞】全军士气得到提升!");
            abilityMoraleBoost = false;
        } else {
            slowsay("该技能尚未解锁或已使用!");
        }
    }

    string stringify(int num) const {
        char buffer[20];
        sprintf(buffer, "%d", num);
        return string(buffer);
    }
};

class LastStandGame {
private:
    GameState state;

    void showTitle() const {
        slowsay("=========================================");
		slowsay("         1945 - 帝国的最后防线           ");
		slowsay("=========================================");
		slowsay("1945年4月,东线红军逼近柏林,西线盟军稳步推进。");
		slowsay("第三帝国已风雨飘摇,但抵抗仍在继续。");
		slowsay("作为德军指挥官,你的任务是指挥残余部队进行最后的抵抗。");
		slowsay("守住关键城市,尽可能拖延盟军的进攻,为帝国争取一线生机。");
		slowsay("提示:8座城市各有独特功能,合理利用城市特色是胜利关键!\n");
    }

    void showStatus() const {
        slowsay("\n----- 第 " + state.stringify(state.getTurn()) + " 回合 战报 -----");
        slowsay("常规部队: " + state.stringify(state.getTroops()) + " 人");
        slowsay("国民掷弹兵: " + state.stringify(state.getNationalGuerrillas()) + " 人");
        slowsay("常规坦克: " + state.stringify(state.getTanks()) + " 辆");
        slowsay("重型坦克: " + state.stringify(state.getHeavyTanks()) + " 辆");
        slowsay("空军力量: " + state.stringify(state.getAircraft()) + " 架");
        slowsay("补给储备: " + state.stringify(state.getSupplies()) + " 单位");
        slowsay("燃料储备: " + state.stringify(state.getFuel()) + " 单位");
        slowsay("部队士气: " + state.stringify(state.getMorale()) + "% " + getMoraleDescription());
        slowsay("指挥声望: " + state.stringify(state.getReputation()) + "%");
        slowsay("盟军压力: " + state.stringify(state.getAlliesPressure()) + "% " + getPressureDescription());

        slowsay("\n----- 已解锁技能 -----");
        if (state.hasEmergencyDraft()) slowsay("? 紧急征兵:动员效率+30%,士气损耗-50%");
        if (state.hasMoraleBoost()) slowsay("? 士气鼓舞:可使用一次(+20士气)");
        if (state.hasTacticalRetreat()) slowsay("? 战术撤退:损失-50%,资源回收+50%");
        else slowsay("(声望提升可解锁更多技能)");

        slowsay("\n----- 关键城市状态 -----");
        const vector<City>& cities = state.getCities();
        for (size_t i = 0; i < cities.size(); ++i) {
            string specialty = "";
            if (cities[i].getSpecialty() == "capital") specialty = " [首都:防御韧性+20%]";
            else if (cities[i].getSpecialty() == "industry") specialty = " [工业:防御升级+20%]";
            else if (cities[i].getSpecialty() == "port") specialty = " [港口:概率获得补给]";
            else if (cities[i].getSpecialty() == "arsenal") specialty = " [兵工厂:修复坦克]";
            else if (cities[i].getSpecialty() == "fortress") specialty = " [要塞:超强防御+自动修复]";
            else if (cities[i].getSpecialty() == "resources") specialty = " [资源:高产出+35单位/回合]";
            else if (cities[i].getSpecialty() == "transport") specialty = " [交通:降低行动消耗]";
            else if (cities[i].getSpecialty() == "tech") specialty = " [科技:提供情报优势]";

            string status = cities[i].isUnderControl() ?
                "【我方控制】防御: " + state.stringify(cities[i].getDefenseLevel()) + specialty :
                "【已被占领】";
            slowsay(cities[i].getName() + ": " + status);
        }

        slowsay("-----------------------------------------");
    }

    string getMoraleDescription() const {
        int m = state.getMorale();
        if (m > 80) return "(高昂)";
        if (m > 60) return "(良好)";
        if (m > 40) return "(一般)";
        if (m > 20) return "(低落)";
        return "(崩溃边缘)";
    }

    string getPressureDescription() const {
        int p = state.getAlliesPressure();
        if (p > 80) return "(极度危险)";
        if (p > 60) return "(压力巨大)";
        if (p > 40) return "(压力明显)";
        if (p > 20) return "(压力较小)";
        return "(压力轻微)";
    }

    void showCommands() const {
        slowsay("\n请选择你的行动:");
        slowsay("1. 集中防御 - 加强防线,减少损失但消耗更多补给");
        slowsay("2. 局部反击 - 对盟军薄弱点进行反击,提升士气但风险高");
        slowsay("3. 战略撤退 - 保存实力,重整部队,回收部分资源");
        slowsay("4. 动员民众 - 征召平民参战,增加兵力但降低补给");
        slowsay("5. 破坏设施 - 延缓敌军推进,降低盟军压力");
        slowsay("6. 升级防御 - 加强城市防御工事,提高坚守能力");
        slowsay("7. 空中打击 - 使用剩余空军攻击敌军,消耗大量燃料");
        slowsay("8. 转移资源 - 将补给和燃料集中到关键防线");
        slowsay("9. 部队调动 - 在城市间调配兵力,强化薄弱环节");

        if (state.canRecaptureCities()) {
            slowsay("10. 夺回城市 - 发动反攻收复失地,风险高且损失大");
        }

        if (state.hasMoraleBoost()) {
            int optionNum = state.canRecaptureCities() ? 11 : 10;
            slowsay(state.stringify(optionNum) + ". 使用士气鼓舞 - 立即提升20点士气(一次性)");
        }

        cout << "请输入命令编号: " << flush;
    }

    void executeDefend() {
        slowsay("\n你下令所有部队收缩防线,建立纵深防御体系。");

        int supplyCost = 60 + rand() % 40;  // 增加补给消耗
        int fuelCost = 15 + rand() % 20;    // 增加燃料消耗

        bool hasTransport = false;
        const vector<City>& cities = state.getCities();
        for (size_t i = 0; i < cities.size(); ++i) {
            if (cities[i].isUnderControl() && cities[i].getSpecialty() == "transport") {
                hasTransport = true;
                break;
            }
        }

        if (hasTransport) {
            supplyCost = static_cast<int>(supplyCost * 0.9);  // 交通枢纽效果减弱(从80%降至90%)
            fuelCost = static_cast<int>(fuelCost * 0.9);
            slowsay("利用法兰克福交通枢纽,防御行动资源消耗略有降低!");
        }

        if (state.getSupplies() < supplyCost || state.getFuel() < fuelCost) {
            slowsay("防御行动因资源不足而效果大打折扣!");
            supplyCost = static_cast<int>(supplyCost * 0.7);  // 资源不足时效果更差
            fuelCost = static_cast<int>(fuelCost * 0.7);
        }

        state.updateSupplies(-supplyCost);
        state.updateFuel(-fuelCost);

        // 降低防御加成效果
        int defenseBonus = 0;
        vector<City> mutableCities = state.getCities();
        for (size_t i = 0; i < mutableCities.size(); ++i) {
            if (mutableCities[i].isUnderControl()) {
                defenseBonus += mutableCities[i].getDefenseLevel() / 8;  // 从5降至8,降低加成
            }
        }

        defenseBonus += state.getHeavyTanks();  // 重型坦克加成减半

        int baseLoss = static_cast<int>((15 + rand() % 25) * (state.getAlliesPressure() / 100.0));  // 提高基础损失
        int troopLoss = static_cast<int>(baseLoss * (100 - defenseBonus) / 90.0);  // 降低防御减免效果
        int guerrillaLoss = static_cast<int>(troopLoss * 0.5);  // 提高国民掷弹兵损失比例
        int tankLoss = (troopLoss / 20) + rand() % 4;  // 增加坦克损失
        int heavyTankLoss = (tankLoss / 1);  // 重型坦克损失增加

        state.updateTroops(-troopLoss);
        state.updateNationalGuerrillas(-guerrillaLoss);
        state.updateTanks(-tankLoss);
        state.updateHeavyTanks(-heavyTankLoss);

        // 降低士气对防御的加成
        if (state.getMorale() > 60) {
            troopLoss = static_cast<int>(troopLoss * 0.9);  // 从70%降至90%
            guerrillaLoss = static_cast<int>(guerrillaLoss * 0.7);  // 从50%降至70%
            slowsay("高昂的士气使防御略微稳固,损失略有减少。");
        } else if (state.getMorale() < 30) {
            guerrillaLoss = static_cast<int>(guerrillaLoss * 1.8);  // 从150%提高到180%
            slowsay("低落的士气严重影响了部队战斗力,损失大幅增加。");
        }

        slowsay("防御战中损失了约 " + state.stringify(troopLoss) + " 名常规士兵、" +
                state.stringify(guerrillaLoss) + " 名国民掷弹兵、" +
                state.stringify(tankLoss) + " 辆常规坦克和 " +
                state.stringify(heavyTankLoss) + " 辆重型坦克。");
        slowsay("消耗了 " + state.stringify(supplyCost) + " 单位补给和 " +
                state.stringify(fuelCost) + " 单位燃料。");

        // 降低正面效果
        state.updateMorale(2 + rand() % 3);  // 从5-10降至2-5
        state.updateReputation(1 + rand() % 2);  // 从3-6降至1-3
        state.updateAlliesPressure(5 + rand() % 5);  // 增加盟军压力增长
    }

    void executeAttack() {
        slowsay("\n你下令对盟军防线的薄弱点发动局部反击。");

        // 提高反击所需兵力门槛
        if (state.getTroops() + state.getNationalGuerrillas() < 2500 ||  // 从1500提高到2500
            state.getTanks() + state.getHeavyTanks() < 8) {  // 从5提高到8
            slowsay("兵力严重不足,无法组织有效反击!");
            state.updateMorale(-10);  // 增加惩罚
            return;
        }

        int techBonus = 0;
        const vector<City>& cities = state.getCities();
        for (size_t i = 0; i < cities.size(); ++i) {
            if (cities[i].isUnderControl() && cities[i].getSpecialty() == "tech") {
                techBonus = 10;  // 从15降至10
                break;
            }
        }

        // 降低反击成功率
        int successChance = 20 + (state.getTanks()) + (state.getHeavyTanks() * 2) +  // 降低坦克加成
                          (state.getMorale() / 8) + (state.getReputation() / 15) + techBonus;  // 降低士气和声望加成
        int randNum = rand() % 100;

        if (randNum < successChance) {
            int enemyLoss = 800 + rand() % 1500;  // 降低敌军损失
            int ourLoss = 500 + rand() % 1000;  // 增加我方损失
            int guerrillaLoss = static_cast<int>(ourLoss * 0.4);  // 从20%提高到40%
            int tankLoss = 2 + rand() % 4;  // 增加坦克损失
            int heavyTankLoss = 1 + rand() % 2;  // 增加重型坦克损失
            int fuelCost = 30 + rand() % 30 + state.getHeavyTanks() * 8;  // 增加燃料消耗

            bool hasTransport = false;
            for (size_t i = 0; i < cities.size(); ++i) {
                if (cities[i].isUnderControl() && cities[i].getSpecialty() == "transport") {
                    hasTransport = true;
                    break;
                }
            }

            if (hasTransport) {
                fuelCost = static_cast<int>(fuelCost * 0.9);  // 效果减弱
                slowsay("利用交通优势,反击燃料消耗略有降低!");
            }

            state.updateTroops(-ourLoss);
            state.updateNationalGuerrillas(-guerrillaLoss);
            state.updateTanks(-tankLoss);
            state.updateHeavyTanks(-heavyTankLoss);
            state.updateFuel(-fuelCost);
            state.updateMorale(8 + rand() % 7);  // 降低士气提升
            state.updateReputation(5 + rand() % 4);  // 降低声望提升
            state.updateAlliesPressure(-(5 + rand() % 5));  // 降低压力缓解

            slowsay("反击成功!盟军被迫后退,损失约 " + state.stringify(enemyLoss) + " 人。");
            slowsay("我方损失 " + state.stringify(ourLoss) + " 名常规士兵、" +
                    state.stringify(guerrillaLoss) + " 名国民掷弹兵和 " +
                    state.stringify(tankLoss) + " 辆坦克,消耗 " +
                    state.stringify(fuelCost) + " 单位燃料。");

            // 降低收复失地概率
            if (rand() % 100 < 15 && !state.hasMajorCities()) {  // 从30%降至15%
                vector<City>& mutableCities = state.getCities();
                for (size_t i = 0; i < mutableCities.size(); ++i) {
                    if (!mutableCities[i].isUnderControl()) {
                        mutableCities[i].recapture();
                        slowsay("成功收复" + mutableCities[i].getName() + "!");
                        break;
                    }
                }
            }
        } else {
            // 增加失败损失
            int ourLoss = 1200 + rand() % 2000;  // 从800-2300提高到1200-3200
            int guerrillaLoss = static_cast<int>(ourLoss * 0.6);  // 从40%提高到60%
            int tankLoss = 8 + rand() % 12;  // 增加坦克损失
            int heavyTankLoss = 3 + rand() % 7;  // 增加重型坦克损失
            int fuelCost = 25 + rand() % 25;  // 增加燃料消耗

            state.updateTroops(-ourLoss);
            state.updateNationalGuerrillas(-guerrillaLoss);
            state.updateTanks(-tankLoss);
            state.updateHeavyTanks(-heavyTankLoss);
            state.updateFuel(-fuelCost);
            state.updateMorale(-(15 + rand() % 20));  // 增加士气惩罚
            state.updateReputation(-(8 + rand() % 7));  // 增加声望惩罚
            state.updateAlliesPressure(15 + rand() % 15);  // 增加压力增长

            slowsay("反击失败!德军遭到盟军顽强抵抗并遭受重大损失。");
            slowsay("我方损失 " + state.stringify(ourLoss) + " 名常规士兵、" +
                    state.stringify(guerrillaLoss) + " 名国民掷弹兵、" +
                    state.stringify(tankLoss) + " 辆常规坦克和 " +
                    state.stringify(heavyTankLoss) + " 辆重型坦克,消耗 " +
                    state.stringify(fuelCost) + " 单位燃料。");

            // 增加丢失城市概率
            if (rand() % 100 < 60) {  // 从40%提高到60%
                vector<City>& mutableCities = state.getCities();
                for (size_t i = 0; i < mutableCities.size(); ++i) {
                    if (mutableCities[i].isUnderControl() && rand() % 100 < 40) {  // 提高单个城市被攻占概率
                        mutableCities[i].capture();
                        break;
                    }
                }
            }
        }

        state.updateSupplies(-(60 + rand() % 40));  // 增加补给消耗
    }

    void executeRetreat() {
        slowsay("\n你下令部队有序撤退,保存有生力量。");

        int baseLoss = 300 + rand() % 700;  // 增加基础损失
        int supplyGain = 5 + rand() % 20;   // 减少资源回收
        int fuelGain = 3 + rand() % 10;     // 减少资源回收

        if (state.hasTacticalRetreat()) {
            baseLoss = static_cast<int>(baseLoss * 0.7);  // 技能效果减弱(从50%降至70%)
            supplyGain = static_cast<int>(supplyGain * 1.2);  // 从150%降至120%
            fuelGain = static_cast<int>(fuelGain * 1.2);
            slowsay("【战术撤退生效】损失有所降低,资源回收率略有提升!");
        }

        bool hasTransport = false;
        const vector<City>& cities = state.getCities();
        for (size_t i = 0; i < cities.size(); ++i) {
            if (cities[i].isUnderControl() && cities[i].getSpecialty() == "transport") {
                hasTransport = true;
                break;
            }
        }

        if (hasTransport) {
            baseLoss = static_cast<int>(baseLoss * 0.9);  // 效果减弱(从80%降至90%)
            supplyGain = static_cast<int>(supplyGain * 1.1);  // 从120%降至110%
            fuelGain = static_cast<int>(fuelGain * 1.1);
            slowsay("利用交通网络,撤退损失略微降低,资源回收略有增加!");
        }

        int troopLoss = baseLoss;
        int guerrillaLoss = static_cast<int>(baseLoss * 0.8);  // 增加掷弹兵损失比例

        state.updateTroops(-troopLoss);
        state.updateNationalGuerrillas(-guerrillaLoss);
        state.updateSupplies(supplyGain);
        state.updateFuel(fuelGain);

        // 增加士气损失
        int moraleLoss = state.hasTacticalRetreat() ? (5 + rand() % 8) : (10 + rand() % 15);
        state.updateMorale(-moraleLoss);
        state.updateAlliesPressure(8 + rand() % 7);  // 增加压力增长

        slowsay("撤退过程中损失了 " + state.stringify(troopLoss) + " 名常规士兵和 " +
                state.stringify(guerrillaLoss) + " 名国民掷弹兵,成功回收了 " +
                state.stringify(supplyGain) + " 单位补给和 " +
                state.stringify(fuelGain) + " 单位燃料。");

        // 降低增援概率
        int reinforceChance = 10 + (state.getReputation() / 8);  // 从20+声望/5降至10+声望/8
        if (rand() % 100 < reinforceChance) {
            int reinforcements = 300 + rand() % 800;  // 减少增援数量
            state.updateTroops(reinforcements);
            slowsay("一支溃散的部队归建,带来了 " + state.stringify(reinforcements) + " 名援兵!");
            state.updateMorale(5);
        }
    }

    void executeMobilize() {
        slowsay("\n你下令动员平民和预备役人员参战。");

        int cityBonus = 0;
        const vector<City>& cities = state.getCities();
        for (size_t i = 0; i < cities.size(); ++i) {
            if (cities[i].isUnderControl()) cityBonus++;
        }

        // 减少征召数量
        int baseTroops = 300 + rand() % 1000;  // 从500-2000降至300-1300
        int supplyCost = 80 + rand() % 50;  // 增加补给消耗

        if (state.hasEmergencyDraft()) {
            baseTroops = static_cast<int>(baseTroops * 1.1);  // 技能效果减弱(从130%降至110%)
            supplyCost = static_cast<int>(supplyCost * 0.9);  // 从80%升至90%
            slowsay("【紧急征兵生效】征召效率略有提升,补给消耗略有降低!");
        }

        int newTroops = static_cast<int>(baseTroops * (1 + cityBonus * 0.1));  // 降低城市加成
        int newGuerrillas = static_cast<int>(newTroops * 0.3);  // 减少掷弹兵比例
        newTroops -= newGuerrillas;

        state.updateTroops(newTroops);
        state.updateNationalGuerrillas(newGuerrillas);
        state.updateSupplies(-supplyCost);

        // 增加负面效果概率
        if (rand() % 100 < 30) {  // 正面效果概率从50%降至30%
            state.updateMorale(3 + rand() % 7);  // 降低正面效果
            state.updateReputation(3 + rand() % 4);
            slowsay("民众积极响应号召,部队士气有所提升。");
        } else {
            int moralePenalty = state.hasEmergencyDraft() ? (5 + rand() % 10) : (10 + rand() % 15);  // 增加惩罚
            int repPenalty = state.hasEmergencyDraft() ? (3 + rand() % 5) : (5 + rand() % 7);

            state.updateMorale(-moralePenalty);
            state.updateReputation(-repPenalty);
            slowsay("民众对动员感到恐慌和不满,部队士气受到严重影响。");
        }

        slowsay("成功征召了 " + state.stringify(newTroops) + " 名常规士兵和 " +
                state.stringify(newGuerrillas) + " 名国民掷弹兵,但消耗了大量补给。");
        state.updateAlliesPressure(10 + rand() % 10);  // 增加压力增长
    }

    void executeSabotage() {
        slowsay("\n你下令破坏基础设施,以延缓盟军推进。");

        int troopsUsed = 500 + rand() % 700;  // 增加所需兵力
        int pressureReduction = 5 + rand() % 10;  // 降低效果

        if (state.getNationalGuerrillas() >= troopsUsed) {
            state.updateNationalGuerrillas(-troopsUsed);
            pressureReduction = static_cast<int>(pressureReduction * 1.1);  // 效果减弱
            slowsay("国民掷弹兵执行破坏任务。");
        } else {
            int useGuerrillas = state.getNationalGuerrillas();
            int useTroops = troopsUsed - useGuerrillas;
            state.updateNationalGuerrillas(-useGuerrillas);
            state.updateTroops(-useTroops);
            troopsUsed = useGuerrillas + useTroops;
        }

        if (troopsUsed < 200) {  // 提高所需兵力门槛
            slowsay("没有足够兵力执行破坏行动!");
            return;
        }

        state.updateAlliesPressure(-pressureReduction);

        slowsay("破坏行动延缓了盟军推进,盟军压力降低" + state.stringify(pressureReduction) + "%。");
        slowsay("执行破坏任务损失了 " + state.stringify(troopsUsed) + " 名士兵。");

        // 增加失败概率
        if (rand() % 100 < 50) {  // 从30%提高到50%
            slowsay("大部分破坏小组被盟军发现,任务效果大打折扣。");
            state.updateAlliesPressure(pressureReduction * 0.7);  // 恢复更多压力
            state.updateMorale(-8);  // 增加惩罚
            state.updateReputation(-8);
        } else {
            state.updateMorale(3 + rand() % 4);  // 降低正面效果
            state.updateReputation(3 + rand() % 2);
        }
    }

    void executeUpgradeDefenses() {
        slowsay("\n你下令加强关键城市的防御工事。");

        vector<City>& cities = state.getCities();
        slowsay("可升级防御的城市:");
        for (size_t i = 0; i < cities.size(); ++i) {
            if (cities[i].isUnderControl()) {
                string bonus = (cities[i].getSpecialty() == "industry") ? " [工业加成+20%]" : "";
                slowsay(state.stringify(static_cast<int>(i+1)) + ". " + cities[i].getName() +
                        " (当前防御: " + state.stringify(cities[i].getDefenseLevel()) + ")" + bonus);
            }
        }

        cout << "请选择要升级防御的城市编号: " << flush;
        int choice;
        cin >> choice;

        if (choice < 1 || choice > static_cast<int>(cities.size()) || !cities[choice-1].isUnderControl()) {
            slowsay("无效选择,错失了升级防御的机会。");
            return;
        }

        // 增加升级成本
        int cost = 100 + rand() % 70;  // 从80-130提高到100-170
        if (cities[choice-1].getSpecialty() == "industry") {
            cost = static_cast<int>(cost * 0.9);  // 效果减弱(从80%升至90%)
            slowsay("利用工业优势,升级成本略有降低!");
        }

        if (state.getSupplies() < cost) {
            slowsay("补给严重不足,无法升级防御工事!");
            return;
        }

        state.updateSupplies(-cost);
        cities[choice-1].upgradeDefenses(15 + rand() % 10);  // 降低升级效果(从20-35降至15-25)
        state.updateReputation(3);  // 降低声望提升

        slowsay("升级防御消耗了 " + state.stringify(cost) + " 单位补给。");
    }

    void executeAirStrike() {
        slowsay("\n你下令剩余空军对盟军集结地发动突袭。");

        if (state.getAircraft() < 5) {  // 提高所需飞机数量(从3提高到5)
            slowsay("空军力量严重不足,无法执行有效打击!");
            return;
        }

        int fuelCost = 60 + rand() % 40;  // 增加燃料消耗
        if (state.getFuel() < fuelCost) {
            slowsay("燃料严重不足,无法执行空中打击!");
            return;
        }

        int techBonus = 0;
        const vector<City>& cities = state.getCities();
        for (size_t i = 0; i < cities.size(); ++i) {
            if (cities[i].isUnderControl() && cities[i].getSpecialty() == "tech") {
                techBonus = 10;  // 从15降至10
                break;
            }
        }

        int planesLost = 2 + rand() % 4;  // 增加飞机损失
        int successChance = 30 + (state.getAircraft() * 2) + (state.getReputation() / 8) + techBonus;  // 降低成功率

        state.updateAircraft(-planesLost);
        state.updateFuel(-fuelCost);

        if (rand() % 100 < successChance) {
            slowsay("空中打击取得一定效果,盟军补给线遭到轻微破坏。");
            state.updateAlliesPressure(-(5 + rand() % 8));  // 降低效果
            state.updateMorale(5 + rand() % 4);  // 降低士气提升
            state.updateReputation(5 + rand() % 3);  // 降低声望提升
        } else {
            slowsay("空中打击惨败,我方损失惨重且收效甚微。");
            state.updateAlliesPressure(8 + rand() % 7);  // 增加压力增长
            state.updateMorale(-(8 + rand() % 7));  // 增加惩罚
            state.updateReputation(-(8 + rand() % 6));  // 增加惩罚
        }

        slowsay("行动中损失了 " + state.stringify(planesLost) + " 架飞机,消耗了 " +
                state.stringify(fuelCost) + " 单位燃料。");
    }

    void executeResourceTransfer() {
        slowsay("\n你下令将资源集中调配到关键防线。");

        int supplyCost = 30 + rand() % 20;  // 增加补给消耗
        if (state.getSupplies() < supplyCost) {
            slowsay("补给不足,无法有效转移资源!");
            return;
        }

        bool hasTransport = false;
        const vector<City>& cities = state.getCities();
        for (size_t i = 0; i < cities.size(); ++i) {
            if (cities[i].isUnderControl() && cities[i].getSpecialty() == "transport") {
                hasTransport = true;
                break;
            }
        }

        if (hasTransport) {
            supplyCost = static_cast<int>(supplyCost * 0.8);  // 保持效果,因为其他方面已削弱
            slowsay("利用交通网络,资源转移成本降低20%!");
        }

        state.updateSupplies(-supplyCost);

        // 降低正面效果
        int effect = rand() % 3;
        switch (effect) {
            case 0:
                {
                    int fuelGain = 20 + rand() % 15;  // 减少燃料增加
                    state.updateFuel(fuelGain);
                    slowsay("成功调配了燃料储备,增加了 " + state.stringify(fuelGain) + " 单位燃料。");
                }
                break;
            case 1:
                {
                    vector<City>& mutableCities = state.getCities();
                    for (size_t i = 0; i < mutableCities.size(); ++i) {
                        if (mutableCities[i].isUnderControl()) {
                            mutableCities[i].upgradeDefenses(5 + rand() % 5);  // 减少防御提升
                        }
                    }
                    slowsay("资源被用于加固所有控制中的城市防御。");
                }
                break;
            case 2:
                slowsay("资源调配略微提升了部队机动性。");
                state.updateMorale(5 + rand() % 5);  // 降低士气提升
                break;
        }

        state.updateReputation(3);  // 降低声望提升
    }

    void executeTroopMovement() {
        slowsay("\n你下令在各城市间调配兵力,强化薄弱环节。");

        vector<City>& cities = state.getCities();
        vector<int> controlledCities;

        slowsay("可调动部队的城市(我方控制):");
        for (size_t i = 0; i < cities.size(); ++i) {
            if (cities[i].isUnderControl()) {
                controlledCities.push_back(i);
                slowsay(state.stringify(static_cast<int>(controlledCities.size())) + ". " + cities[i].getName() +
                        " (防御: " + state.stringify(cities[i].getDefenseLevel()) + ")");
            }
        }

        if (controlledCities.size() < 2) {
            slowsay("控制的城市不足2个,无法执行部队调动!");
            return;
        }

        cout << "请选择调出部队的城市编号: " << flush;
        int fromChoice;
        cin >> fromChoice;

        if (fromChoice < 1 || fromChoice > static_cast<int>(controlledCities.size())) {
            slowsay("无效选择,部队调动失败!");
            return;
        }

        int fromCityIdx = controlledCities[fromChoice - 1];

        cout << "请选择调入部队的城市编号: " << flush;
        int toChoice;
        cin >> toChoice;

        if (toChoice < 1 || toChoice > static_cast<int>(controlledCities.size()) || toChoice == fromChoice) {
            slowsay("无效选择,部队调动失败!");
            return;
        }

        int toCityIdx = controlledCities[toChoice - 1];

        // 降低可调动兵力比例
        int totalTroops = state.getTroops() + state.getNationalGuerrillas();
        if (totalTroops < 2000) {  // 提高兵力门槛(从1000提高到2000)
            slowsay("兵力不足,无法执行有效调动!");
            return;
        }

        int movePercentage = 5 + rand() % 16;  // 从10-30%降至5-21%
        int troopsToMove = static_cast<int>(totalTroops * movePercentage / 100.0);
        int guerrillasToMove = static_cast<int>(troopsToMove * 0.2);  // 降低掷弹兵比例
        int regularsToMove = troopsToMove - guerrillasToMove;

        bool hasTransport = false;
        for (size_t i = 0; i < cities.size(); ++i) {
            if (cities[i].isUnderControl() && cities[i].getSpecialty() == "transport") {
                hasTransport = true;
                break;
            }
        }

        if (hasTransport) {
            troopsToMove = static_cast<int>(troopsToMove * 1.1);  // 效果减弱(从120%降至110%)
            slowsay("利用交通枢纽,部队调动规模略有增加!");
        }

        // 增加调动损耗
        int loss = static_cast<int>(troopsToMove * 0.2);  // 从10%提高到20%
        regularsToMove -= loss / 2;
        guerrillasToMove -= loss - loss / 2;

        state.updateTroops(-regularsToMove);
        state.updateNationalGuerrillas(-guerrillasToMove);
        state.updateTroops(regularsToMove);
        state.updateNationalGuerrillas(guerrillasToMove);

        // 增加补给消耗
        int supplyCost = 15 + rand() % 20;  // 从10-25提高到15-35
        state.updateSupplies(-supplyCost);

        slowsay("成功从" + cities[fromCityIdx].getName() + "调动 " +
                state.stringify(regularsToMove) + " 名常规士兵和 " +
                state.stringify(guerrillasToMove) + " 名国民掷弹兵到" +
                cities[toCityIdx].getName() + ",途中损失约 " + state.stringify(loss) + " 人。");
        slowsay("调动消耗了 " + state.stringify(supplyCost) + " 单位补给。");

        // 降低调入城市防御提升
        cities[toCityIdx].upgradeDefenses(3 + rand() % 7);  // 从5-15降至3-10
        state.updateReputation(2);  // 降低声望提升
    }

    void executeRecaptureCity() {
        if (!state.canRecaptureCities()) {
            slowsay("无法执行夺回城市行动!需要士气高昂且有失守的城市。");
            return;
        }

        slowsay("\n你决定发动反攻,收复被占领的城市!");
        slowsay("此行动将付出巨大代价,且成功几率渺茫...");

        vector<int> lostCities = state.getLostCitiesIndices();
        vector<City>& cities = state.getCities();

        slowsay("可尝试夺回的城市:");
        for (size_t i = 0; i < lostCities.size(); ++i) {
            int idx = lostCities[i];
            string importance = "";
            if (cities[idx].getSpecialty() == "capital") importance = " [首都 - 高风险目标]";
            else if (cities[idx].getSpecialty() == "resources") importance = " [资源重镇 - 高风险]";
            slowsay(state.stringify(static_cast<int>(i+1)) + ". " + cities[idx].getName() + importance);
        }

        cout << "请选择要夺回的城市编号: " << flush;
        int choice;
        cin >> choice;

        if (choice < 1 || choice > static_cast<int>(lostCities.size())) {
            slowsay("无效选择,错失了夺回城市的机会。");
            return;
        }

        int targetIdx = lostCities[choice - 1];
        string targetName = cities[targetIdx].getName();

        slowsay("集结所有可用力量,向" + targetName + "发动反攻!");

        bool success = state.attemptRecaptureCity(targetIdx);

        if (success) {
            slowsay("夺回" + targetName + "的行动取得成功!这是一场艰难的胜利!");
        } else {
            slowsay("夺回" + targetName + "的行动彻底失败!部队损失惨重...");
        }
    }

    void randomEvent() {
        int eventChance = rand() % 100;

        if (eventChance < 60) {  // 提高事件概率(从50%到60%)
            slowsay("\n----- 突发情况!-----");

            int eventType = rand() % 15;

            switch (eventType) {
                case 0:  // 降低正面事件概率,减少收益
                    {
                        int supplies = 30 + rand() % 70;  // 减少补给
                        state.updateSupplies(supplies);
                        slowsay("一支小规模补给车队突破封锁到达,获得了 " + state.stringify(supplies) + " 单位补给!");
                        state.updateMorale(3);  // 降低士气提升
                    }
                    break;
                case 1:  // 增强负面事件效果
                    {
                        slowsay("多位高级将领在战斗中阵亡,部队指挥陷入混乱。");
                        state.updateMorale(-20);  // 增加惩罚
                        state.updateReputation(-15);
                        state.updateAlliesPressure(8);
                    }
                    break;
                case 2:  // 减弱正面事件效果
                    {
                        slowsay("小雨导致道路泥泞,盟军推进速度略有减慢。");
                        state.updateAlliesPressure(-5);  // 降低效果
                    }
                    break;
                case 3:  // 增强负面事件效果
                    {
                        int desertions = 800 + rand() % 1500;  // 增加逃兵数量
                        slowsay("大规模士兵因绝望而叛变逃亡,损失 " + state.stringify(desertions) + " 人。");
                        state.updateTroops(-desertions);
                        state.updateMorale(-15);  // 增加惩罚
                        state.updateReputation(-10);
                    }
                    break;
                case 4:  // 降低正面事件概率和效果
                    {
                        if (state.getTurn() > 8) {  // 推迟出现时间
                            slowsay("少量V2火箭投入战斗,对盟军后方造成一定破坏!");
                            state.updateAlliesPressure(-10);  // 降低效果
                            state.updateMorale(8);  // 降低士气提升
                        } else {
                            slowsay("发现了少量被遗忘的武器储备。");
                            state.updateSupplies(20 + rand() % 30);  // 减少补给
                        }
                    }
                    break;
                case 5:  // 降低正面事件概率和效果
                    {
                        if (state.getReputation() > 60) {  // 提高触发门槛
                            slowsay("潜伏的间谍提供了有限的盟军进攻计划。");
                            state.updateAlliesPressure(-5);  // 降低效果
                            state.updateMorale(3);  // 降低士气提升
                        } else {
                            slowsay("间谍网络被彻底摧毁,失去了情报来源。");
                            state.updateAlliesPressure(8);  // 增加压力
                        }
                    }
                    break;
                case 6:  // 降低正面事件概率和效果
                    {
                        int support = rand() % 100;
                        if (support < 20) {  // 从50%降至20%
                            slowsay("当地民众提供了少量食物和住所。");
                            state.updateSupplies(20 + rand() % 20);  // 减少补给
                            state.updateMorale(5);  // 降低士气提升
                        } else {
                            slowsay("大规模平民骚乱,消耗了大量兵力维持秩序。");
                            state.updateTroops(-(400 + rand() % 500));  // 增加损失
                            state.updateMorale(-10);  // 增加惩罚
                        }
                    }
                    break;
                case 7:  // 增强负面事件效果
                    {
                        slowsay("严重燃料短缺,机械化部队几乎无法行动。");
                        state.updateFuel(-(30 + rand() % 40));  // 增加燃料损失
                        state.updateAlliesPressure(8);  // 增加压力
                    }
                    break;
                case 8:  // 降低正面事件概率和效果
                    {
                        int chance = 10 + (state.getReputation() / 5);  // 降低概率
                        if (rand() % 100 < chance) {
                            int reinf = 500 + rand() % 800;  // 减少援兵
                            int heavyTanks = 0;
                            if (state.getReputation() > 80) {  // 提高门槛
                                heavyTanks = 1 + rand() % 2;  // 减少重型坦克
                            }
                            state.updateTroops(reinf);
                            state.updateHeavyTanks(heavyTanks);
                            slowsay("一支小部队抵达,带来了 " + state.stringify(reinf) + " 名援兵和 " +
                                    state.stringify(heavyTanks) + " 辆重型坦克!");
                            state.updateMorale(10);  // 降低士气提升
                        }
                    }
                    break;
                case 9:  // 增强负面事件效果
                    {
                        slowsay("军营中爆发大规模瘟疫,严重影响了部队战斗力。");
                        int loss = 500 + rand() % 800;  // 增加损失
                        state.updateTroops(-loss);
                        state.updateMorale(-15);  // 增加惩罚
                        state.updateSupplies(-(40 + rand() % 30));  // 增加消耗
                    }
                    break;
                case 10:  // 降低正面事件概率和效果
                    {
                        bool hasIndustry = false;
                        const vector<City>& cities = state.getCities();
                        for (size_t i = 0; i < cities.size(); ++i) {
                            if (cities[i].isUnderControl() && cities[i].getSpecialty() == "industry") {
                                hasIndustry = true;
                                break;
                            }
                        }

                        if (hasIndustry && rand() % 100 < 30) {  // 降低概率
                            slowsay("工业生产部分恢复,修复了少量装备!");
                            state.updateTanks(1 + rand() % 3);  // 减少修复
                            state.updateSupplies(20 + rand() % 20);  // 减少补给
                        }
                    }
                    break;
                case 11:  // 降低正面事件概率和效果
                    {
                        if (rand() % 100 < 15) {  // 降低概率
                            slowsay("情报显示盟军内部出现短暂战略分歧。");
                            state.updateAlliesPressure(-8);  // 降低效果
                            state.updateMorale(5);  // 降低士气提升
                            state.updateReputation(3);  // 降低声望提升
                        }
                    }
                    break;
                case 12:  // 降低正面事件概率和效果
                    {
                        bool hasResources = false;
                        const vector<City>& cities = state.getCities();
                        for (size_t i = 0; i < cities.size(); ++i) {
                            if (cities[i].isUnderControl() && cities[i].getSpecialty() == "resources") {
                                hasResources = true;
                                break;
                            }
                        }

                        if (hasResources && rand() % 100 < 20) {  // 降低概率
                            int bonus = 30 + rand() % 50;  // 减少补给
                            state.updateSupplies(bonus);
                            slowsay("鲁尔区资源产量略有增加,额外获得 " + state.stringify(bonus) + " 单位补给!");
                            state.updateMorale(3);  // 降低士气提升
                        }
                    }
                    break;
                case 13:  // 增强负面事件效果
                    {
                        bool hasFortress = false;
                        int fortressIdx = -1;
                        vector<City>& mutableCities = state.getCities();
                        for (size_t i = 0; i < mutableCities.size(); ++i) {
                            if (mutableCities[i].isUnderControl() && mutableCities[i].getSpecialty() == "fortress") {
                                hasFortress = true;
                                fortressIdx = i;
                                break;
                            }
                        }

                        if (hasFortress) {
                            slowsay("盟军集中优势火力猛攻柯尼斯堡要塞!");
                            mutableCities[fortressIdx].damageDefenses(40 + rand() % 30);  // 增加破坏
                            state.updateAlliesPressure(8);  // 增加压力

                            if (mutableCities[fortressIdx].getDefenseLevel() < 30) {
                                slowsay("柯尼斯堡要塞防御濒临崩溃!");
                                state.updateMorale(-15);  // 增加惩罚
                            }
                        }
                    }
                    break;
                case 14:  // 降低正面事件概率和效果
                    {
                        bool hasTech = false;
                        const vector<City>& cities = state.getCities();
                        for (size_t i = 0; i < cities.size(); ++i) {
                            if (cities[i].isUnderControl() && cities[i].getSpecialty() == "tech") {
                                hasTech = true;
                                break;
                            }
                        }

                        if (hasTech && rand() % 100 < 10) {  // 降低概率
                            slowsay("斯图加特的科研人员取得微小技术突破。");
                            state.updateTanks(1 + rand() % 2);  // 减少装备增加
                            state.updateAircraft(1);  // 减少飞机增加
                            state.updateMorale(5);  // 降低士气提升
                        }
                    }
                    break;
            }
            slowsay("---------------------");
        }
    }

    void alliesAction() {
        slowsay("\n----- 盟军行动 -----");

        int attackIntensity = state.getAlliesPressure();
        vector<City>& cities = state.getCities();

        // 增加盟军攻击次数
        int numAttacks = 1;
        if (attackIntensity > 50) numAttacks = 2;  // 降低触发门槛
        if (attackIntensity > 80) numAttacks = 3;  // 降低触发门槛

        slowsay("盟军发动 " + state.stringify(numAttacks) + " 处猛烈攻势!");

        for (int a = 0; a < numAttacks; a++) {
            int targetCity = -1;
            int lowestDefense = 101;
            vector<int> possibleTargets;

            for (size_t i = 0; i < cities.size(); ++i) {
                if (cities[i].isUnderControl()) {
                    possibleTargets.push_back(i);
                    if (cities[i].getDefenseLevel() < lowestDefense) {
                        lowestDefense = cities[i].getDefenseLevel();
                    }
                }
            }

            if (possibleTargets.empty()) break;

            vector<int> weakTargets;
            for (int idx : possibleTargets) {
                if (cities[idx].getDefenseLevel() == lowestDefense) {
                    weakTargets.push_back(idx);
                }
            }

            targetCity = weakTargets[rand() % weakTargets.size()];

            // 提高优先攻击战略要地的概率
            if (rand() % 100 < 50) {  // 从30%提高到50%
                for (int idx : possibleTargets) {
                    if (cities[idx].getSpecialty() == "capital" ||
                        cities[idx].getSpecialty() == "resources" ||
                        cities[idx].getSpecialty() == "transport") {
                        targetCity = idx;
                        break;
                    }
                }
            }

            if (cities[targetCity].isUnderControl()) {
                slowsay("盟军集中优势兵力攻击" + cities[targetCity].getName() + "!");

                // 提高盟军攻击力
                int attackStrength = 40 + rand() % 60;  // 从30-80提高到40-100
                int defenseStrength = cities[targetCity].getDefenseLevel();

                if (attackStrength > defenseStrength) {
                    int damage = attackStrength - defenseStrength;
                    cities[targetCity].damageDefenses(damage * 1.2);  // 增加120%的破坏
                    slowsay(cities[targetCity].getName() + "防御工事严重受损,防御等级大幅下降!");

                    // 提高城市沦陷概率
                    if (cities[targetCity].getDefenseLevel() < 30 && rand() % 100 < 80) {  // 从60%提高到80%
                        cities[targetCity].capture();
                        state.updateAlliesPressure(8);  // 增加压力
                        state.updateMorale(-15);  // 增加士气惩罚

                        if (cities[targetCity].getSpecialty() == "resources") {
                            slowsay("失去重要资源产地,补给将严重短缺!");
                            state.updateMorale(-15);  // 增加惩罚
                        }
                        else if (cities[targetCity].getSpecialty() == "transport") {
                            slowsay("失去交通枢纽,部队机动性严重下降!");
                            state.updateAlliesPressure(8);  // 增加压力
                        }
                    }
                } else {
                    slowsay(cities[targetCity].getName() + "的防御勉强抵御了盟军的进攻!");
                    state.updateMorale(2);  // 降低士气提升
                }
            }
        }

        // 增加我方损失
        int ourLosses = static_cast<int>((attackIntensity / 100.0) * (800 + rand() % 1500) * numAttacks);  // 提高基础损失
        int guerrillaLoss = static_cast<int>(ourLosses * 0.5);  // 提高掷弹兵损失比例
        int tankLosses = static_cast<int>((attackIntensity / 100.0) * (3 + rand() % 10) * numAttacks);  // 增加坦克损失
        int heavyTankLosses = static_cast<int>(tankLosses * 0.7);  // 提高重型坦克损失比例
        int planeLosses = 0;

        // 提高盟军空袭概率和强度
        if (rand() % 100 < 70 && attackIntensity > 40) {  // 从50%提高到70%,降低门槛
            planeLosses = 2 + rand() % 4;  // 增加飞机损失
            slowsay("盟军发动大规模空袭,我方空军损失惨重!");
        }

        state.updateTroops(-ourLosses);
        state.updateNationalGuerrillas(-guerrillaLoss);
        state.updateTanks(-tankLosses);
        state.updateHeavyTanks(-heavyTankLosses);
        state.updateAircraft(-planeLosses);

        slowsay("盟军进攻造成我方约 " + state.stringify(ourLosses) + " 名常规士兵、" +
                state.stringify(guerrillaLoss) + " 名国民掷弹兵、" +
                state.stringify(tankLosses) + " 辆常规坦克、" +
                state.stringify(heavyTankLosses) + " 辆重型坦克和 " +
                state.stringify(planeLosses) + " 架飞机的损失。");

        // 提高重大攻势概率
        if (attackIntensity > 70 && rand() % 100 < 70) {  // 从80%降至70%,概率从60%提高到70%
            slowsay("盟军发动了毁灭性攻势,防线多处崩溃!");
            state.updateAlliesPressure(15);  // 增加压力
            state.updateMorale(-20);  // 增加惩罚
        } else if (attackIntensity < 40) {
            slowsay("盟军攻势暂时缓和,给了我们短暂的喘息之机。");
            state.updateMorale(3);  // 降低士气提升
        }

        slowsay("---------------------");
    }

public:
    void start() {
        showTitle();

        while (!state.isGameOver()) {
            showStatus();
            showCommands();

            int choice;
            cin >> choice;

            int moraleBoostOption = state.canRecaptureCities() ? 11 : 10;

            switch (choice) {
                case 1: executeDefend(); break;
                case 2: executeAttack(); break;
                case 3: executeRetreat(); break;
                case 4: executeMobilize(); break;
                case 5: executeSabotage(); break;
                case 6: executeUpgradeDefenses(); break;
                case 7: executeAirStrike(); break;
                case 8: executeResourceTransfer(); break;
                case 9: executeTroopMovement(); break;
                case 10: if (state.canRecaptureCities()) executeRecaptureCity();
                         else if (state.hasMoraleBoost()) state.useMoraleBoost();
                         else slowsay("无效命令!"); break;
                case 11: if (state.canRecaptureCities() && state.hasMoraleBoost())
                            state.useMoraleBoost();
                         else slowsay("无效命令!"); break;
                default:
                    slowsay("无效命令,错失了行动机会!");
                    state.updateAlliesPressure(8);  // 增加惩罚
            }

            if (state.getSupplies() < 50) {
                slowsay("\n警告:补给严重不足,部队战斗力大幅下降!");
                state.updateMorale(-15);  // 增加惩罚
            }

            if (state.getFuel() < 30) {
                slowsay("\n警告:燃料储备告急,机械化部队完全无法行动!");
                state.updateTanks(-(2 + rand() % 4));  // 增加损失
                state.updateHeavyTanks(-(1 + rand() % 3));  // 增加损失
            }

            randomEvent();
            alliesAction();
            state.nextTurn();
            state.checkGameOver();

            slowsay("\n按Enter键继续到下一回合...");
            cin.ignore();
            cin.get();

#ifdef _WIN32
            system("cls");
#else
            system("clear");
#endif
        }

        showGameOver();
    }

    void showGameOver() const {
        slowsay("\n=========================================");
        slowsay("             游戏结束                     ");
        slowsay("=========================================");

        if (state.isVictory()) {
            slowsay("难以置信!你在极端困难的情况下坚持到了第20回合。");
            slowsay("这是一场史诗般的防御战,你的指挥才能无与伦比。");
        } else {
            if (state.allCitiesLost()) {
                slowsay("所有关键城市均已陷落,抵抗彻底失败。");
            } else if (state.getTroops() + state.getNationalGuerrillas() <= 0) {
                slowsay("部队已全军覆没,无法继续抵抗。");
            } else {
                slowsay("部队士气彻底崩溃,抵抗终止。");
            }
            slowsay("你的抵抗在第 " + state.stringify(state.getTurn()) + " 回合结束。");
        }

        vector<string> medals = state.getMedals();
        if (!medals.empty()) {
            slowsay("\n----- 获得的勋章 -----");
            for (size_t i = 0; i < medals.size(); ++i) {
                slowsay("- " + medals[i]);
            }
        }

        slowsay("\n最终评估:");
        slowsay("坚持回合: " + state.stringify(state.getTurn()));
        slowsay("剩余部队: " + state.stringify(state.getTroops() + state.getNationalGuerrillas()) + " 人");
        slowsay("剩余装甲: " + state.stringify(state.getTanks() + state.getHeavyTanks()) + " 辆");
        slowsay("指挥声望: " + state.stringify(state.getReputation()) + "%");

        int remainingCities = 0;
        const vector<City>& cities = state.getCities();
        for (size_t i = 0; i < cities.size(); ++i) {
            if (cities[i].isUnderControl()) remainingCities++;
        }
        slowsay("守住的城市: " + state.stringify(remainingCities) + "/" + state.stringify(static_cast<int>(cities.size())));

        if (state.getReputation() > 80) {
            slowsay("你的指挥才能获得了极高评价,堪称军事天才。");
        } else if (state.getReputation() > 50) {
            slowsay("你的指挥表现良好,展现了坚韧的领导力。");
        } else if (state.getReputation() > 30) {
            slowsay("你的指挥中规中矩,未能创造奇迹。");
        } else {
            slowsay("极端困难的局势超出了你的指挥能力范围。");
        }

        slowsay("=========================================");
    }
};

int main() {
    LastStandGame game;
    game.start();
    return 0;
}
原文