C++火影忍者1.1.8

更新角色黑绝、漂泊浪客带土、波风水门(四代目火影)

我将代码进行了重新梳理,修复了很多bug:泉奈二技能bug、破面带土神威可受击bug、佐助天照可移动bug、水门普攻受击范围bug(测试时的bug)。

飘带的切刀是先使用1技能然后在1技能结束后1秒内按普攻切换状态

以下为1.1.8版本的代码一共2400多行:

cpp 复制代码
#include <iostream>
#include <conio.h>
#include <windows.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <thread>
#include <chrono>
#include <cmath>

using namespace std;

// ==================== 辅助函数 ====================
void setColor(int color) {
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, color);
}
void gotoxy(int x, int y) {
    if (x < 0) x = 0; if (y < 0) y = 0;
    COORD coord; coord.X = (SHORT)x; coord.Y = (SHORT)y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void hideCursor() {
    HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_CURSOR_INFO info; info.dwSize = 100; info.bVisible = FALSE;
    SetConsoleCursorInfo(consoleHandle, &info);
}
void clearScreen() { system("cls"); }

// ==================== 结构体 ====================
struct Skill {
    string name; int cooldown; int currentCD; int damageMin; int damageMax;
    string displayChar; int duration;
};
struct Character {
    string name; int hp; int maxHp; int x, y; bool available;
    vector<Skill> skills; int characterType;
};

// ==================== 地图常量 ====================
const int MAP_WIDTH = 100, MAP_HEIGHT = 24, MAP_START_X = 2, MAP_START_Y = 3, CHARACTER_ROW = MAP_HEIGHT - 1;

// ==================== 全局角色 ====================
Character player, enemy;
bool gameRunning = false, skillInProgress = false, enemySkillInProgress = false;
int playerCharacterType = 0, enemyCharacterType = 0;

// ==================== 黑绝机制变量 ====================
bool playerBlackZetsuMode = false, playerBlackZetsuCarrier = false;
chrono::steady_clock::time_point playerBlackZetsuNormalCDEnd;

int increasePlayerDamage(int dmg) {
    if (playerBlackZetsuCarrier) return (int)(dmg * 1.1);
    return dmg;
}
int reducePlayerDamage(int dmg) {
    if (playerBlackZetsuCarrier) return (int)(dmg * 0.7);
    return dmg;
}

// ==================== 技能冷却时间点 ====================
chrono::steady_clock::time_point playerSkill1CDEnd, playerSkill2CDEnd, playerSkill3CDEnd;
chrono::steady_clock::time_point enemySkill1CDEnd, enemySkill2CDEnd, enemySkill3CDEnd;

// ==================== 佩恩天道变量 ====================
int playerShinraTenseiStack = 0, playerShinraTenseiRadius = 1, playerShinraTenseiCurrentCD = 15;
chrono::steady_clock::time_point playerShinraTenseiStart; bool playerShinraTenseiActive = false;
int enemyShinraTenseiStack = 0, enemyShinraTenseiRadius = 1, enemyShinraTenseiCurrentCD = 15;
chrono::steady_clock::time_point enemyShinraTenseiStart; bool enemyShinraTenseiActive = false;
bool playerBanshoTeninActive = false, enemyBanshoTeninActive = false;
chrono::steady_clock::time_point playerBanshoTeninEnd, enemyBanshoTeninEnd;
int playerBlackRodLeftX = 0, playerBlackRodRightX = 0, enemyBlackRodLeftX = 0, enemyBlackRodRightX = 0;
chrono::steady_clock::time_point lastEnemyAction;

// ==================== 鸣人变量 ====================
bool playerNarutoTailActive = false, enemyNarutoTailActive = false;
chrono::steady_clock::time_point playerNarutoTailEnd, enemyNarutoTailEnd;
int playerNarutoTailX[3] = { 0 }, enemyNarutoTailX[3] = { 0 };

// ==================== 黑棒变量 ====================
bool playerPainRodActive = false, enemyPainRodActive = false;
int playerPainRodX = 0, enemyPainRodX = 0;
chrono::steady_clock::time_point playerPainRodEnd, enemyPainRodEnd;
bool playerRodHitting = false, enemyRodHitting = false;
chrono::steady_clock::time_point playerRodHitEnd, enemyRodHitEnd;

// ==================== 带土变量 ====================
bool playerObitoKickActive = false, playerObitoWoodSpikeActive = false, playerObitoEnemyTrapped = false;
chrono::steady_clock::time_point playerObitoKickEnd, playerObitoWoodSpikeEnd, playerObitoEnemyTrappedEnd;
int playerObitoKickX = 0, playerObitoWoodSpikeX = 0;
bool playerObitoKamuiActive = false, playerObitoKamuiSpaceActive = false, playerObitoEnemyInSpace = false;
chrono::steady_clock::time_point playerObitoKamuiEnd, playerObitoKamuiSpaceEnd; int playerObitoSavedX = 0;
bool playerObitoFireActive = false, playerObitoWoodStormActive = false, playerObitoUltimateActive = false;

bool enemyObitoKickActive = false, enemyObitoWoodSpikeActive = false, enemyObitoEnemyTrapped = false;
chrono::steady_clock::time_point enemyObitoKickEnd, enemyObitoWoodSpikeEnd, enemyObitoEnemyTrappedEnd;
int enemyObitoKickX = 0, enemyObitoWoodSpikeX = 0;
bool enemyObitoKamuiActive = false, enemyObitoKamuiSpaceActive = false, enemyObitoPlayerInSpace = false;
chrono::steady_clock::time_point enemyObitoKamuiEnd, enemyObitoKamuiSpaceEnd; int enemyObitoSavedX = 0;
bool enemyObitoFireActive = false, enemyObitoWoodStormActive = false, enemyObitoUltimateActive = false;

// ==================== 博人变量 ====================
bool playerBorutoSwordActive = false; chrono::steady_clock::time_point playerBorutoSwordEnd;
int playerBorutoSwordX = 0; bool playerBorutoSwordSlashing = false;
bool playerBorutoRasenganActive = false; chrono::steady_clock::time_point playerBorutoRasenganEnd; bool playerBorutoRasenganHit = false;
bool playerBorutoMarkActive = false; chrono::steady_clock::time_point playerBorutoMarkEnd; int playerBorutoMarkX = 0;
bool playerBorutoTeleported = false; int playerBorutoTeleportSavedX = 0; bool playerBorutoTeleportBack = false;
chrono::steady_clock::time_point playerBorutoTeleportTime;
bool playerBorutoKarmaActive = false; chrono::steady_clock::time_point playerBorutoKarmaEnd;
bool playerBorutoFlying = false; chrono::steady_clock::time_point playerBorutoFlyingEnd;
int playerBorutoEnhancedAttackCount = 0; chrono::steady_clock::time_point playerBorutoEnhancedAttackCD;
bool playerBorutoBigRasenganActive = false; chrono::steady_clock::time_point playerBorutoBigRasenganDotEnd; bool playerBorutoBigRasenganHit = false;
bool playerBorutoEnhancedAttackActive = false; int playerBorutoEnhancedAttackX = 0;

bool enemyBorutoSwordActive = false; chrono::steady_clock::time_point enemyBorutoSwordEnd;
int enemyBorutoSwordX = 0; bool enemyBorutoSwordSlashing = false;
bool enemyBorutoRasenganActive = false; chrono::steady_clock::time_point enemyBorutoRasenganEnd; bool enemyBorutoRasenganHit = false;
bool enemyBorutoMarkActive = false; chrono::steady_clock::time_point enemyBorutoMarkEnd; int enemyBorutoMarkX = 0;
bool enemyBorutoTeleported = false; int enemyBorutoTeleportSavedX = 0; bool enemyBorutoTeleportBack = false;
chrono::steady_clock::time_point enemyBorutoTeleportTime;
bool enemyBorutoKarmaActive = false; chrono::steady_clock::time_point enemyBorutoKarmaEnd;
bool enemyBorutoFlying = false; chrono::steady_clock::time_point enemyBorutoFlyingEnd;
int enemyBorutoEnhancedAttackCount = 0; chrono::steady_clock::time_point enemyBorutoEnhancedAttackCD;

// ==================== 柱间变量 ====================
bool playerHashiramaStompActive = false; chrono::steady_clock::time_point playerHashiramaStompEnd; int playerHashiramaStompX = 0;
bool playerHashiramaWoodDragonActive = false; chrono::steady_clock::time_point playerHashiramaWoodDragonEnd;
bool playerHashiramaEnemyTrapped = false; chrono::steady_clock::time_point playerHashiramaWoodDragonTrapEnd;
bool playerHashiramaMyojinmonActive = false; bool playerHashiramaMyojinmonUsed = false;
bool playerHashiramaWoodGolemActive = false; chrono::steady_clock::time_point playerHashiramaWoodGolemEnd;
int playerHashiramaWoodGolemAttackCount = 0; chrono::steady_clock::time_point playerHashiramaWoodGolemAttackCD;
bool playerHashiramaUltimateActive = false;

bool enemyHashiramaStompActive = false; chrono::steady_clock::time_point enemyHashiramaStompEnd; int enemyHashiramaStompX = 0;
bool enemyHashiramaWoodDragonActive = false; chrono::steady_clock::time_point enemyHashiramaWoodDragonEnd;
bool enemyHashiramaEnemyTrapped = false; chrono::steady_clock::time_point enemyHashiramaWoodDragonTrapEnd;
bool enemyHashiramaMyojinmonActive = false; bool enemyHashiramaMyojinmonUsed = false;
bool enemyHashiramaWoodGolemActive = false; chrono::steady_clock::time_point enemyHashiramaWoodGolemEnd;
int enemyHashiramaWoodGolemAttackCount = 0; chrono::steady_clock::time_point enemyHashiramaWoodGolemAttackCD;
bool enemyHashiramaUltimateActive = false;

// ==================== 佐助变量 ====================
bool playerSasukeSlashActive = false; chrono::steady_clock::time_point playerSasukeSlashEnd, playerSasukeSlashCD;
bool playerSasukeAmaterasuActive = false; chrono::steady_clock::time_point playerSasukeAmaterasuEnd, playerSasukeAmaterasuTick;
bool playerSasukeAmaterasuHit = false;
bool playerSasukeSusanooActive = false; chrono::steady_clock::time_point playerSasukeSusanooEnd;
int playerSasukeSusanooSlashCount = 0; chrono::steady_clock::time_point playerSasukeSusanooSlashCD;
bool playerSasukeSusanooSlashActive = false; chrono::steady_clock::time_point playerSasukeSusanooSlashEnd;
bool playerSasukeUltimateActive = false; chrono::steady_clock::time_point playerSasukeSubSkillCD;

bool enemySasukeSlashActive = false; chrono::steady_clock::time_point enemySasukeSlashEnd, enemySasukeSlashCD;
bool enemySasukeAmaterasuActive = false; chrono::steady_clock::time_point enemySasukeAmaterasuEnd, enemySasukeAmaterasuTick;
bool enemySasukeAmaterasuHit = false;
bool enemySasukeSusanooActive = false; chrono::steady_clock::time_point enemySasukeSusanooEnd;
int enemySasukeSusanooSlashCount = 0; chrono::steady_clock::time_point enemySasukeSusanooSlashCD;
bool enemySasukeSusanooSlashActive = false; chrono::steady_clock::time_point enemySasukeSusanooSlashEnd;
bool enemySasukeUltimateActive = false; chrono::steady_clock::time_point enemySasukeSubSkillCD;

// ==================== 泉奈变量 ====================
bool playerIzunaSlashActive = false; chrono::steady_clock::time_point playerIzunaSlashEnd, playerIzunaSlashCD;
bool playerIzunaFireballActive = false; chrono::steady_clock::time_point playerIzunaFireballEnd;
bool playerIzunaCounterActive = false; chrono::steady_clock::time_point playerIzunaCounterEnd;
bool playerIzunaCounterTriggered = false;
bool playerIzunaSwordActive = false; chrono::steady_clock::time_point playerIzunaSwordEnd;
chrono::steady_clock::time_point playerIzunaSword2ndWindow; bool playerIzunaSword2ndUsed = false;
bool playerIzunaUltimateActive = false;

bool enemyIzunaSlashActive = false; chrono::steady_clock::time_point enemyIzunaSlashEnd, enemyIzunaSlashCD;
bool enemyIzunaFireballActive = false; chrono::steady_clock::time_point enemyIzunaFireballEnd;
bool enemyIzunaCounterActive = false; chrono::steady_clock::time_point enemyIzunaCounterEnd;
bool enemyIzunaCounterTriggered = false;
bool enemyIzunaSwordActive = false; chrono::steady_clock::time_point enemyIzunaSwordEnd;
bool enemyIzunaUltimateActive = false;

// ==================== 漂泊浪客变量(修改后) ====================
int playerWandererState = 0;
chrono::steady_clock::time_point playerWandererStateSwitchWindow;
bool playerWandererShortSkill2Used = false;
int playerWandererLongSkill2Count = 2;
bool playerWandererSpinActive = false;
chrono::steady_clock::time_point playerWandererSpinEnd;
bool playerWandererSpinEnemyTransferred = false; // 转刀时是否已传送敌人
int playerWandererSpinEnemySavedX = 0;           // 转刀前敌人X坐标
bool playerWandererShockActive = false;
int playerWandererShockEnemyY = 0;
chrono::steady_clock::time_point playerWandererShockDropTime;
chrono::steady_clock::time_point playerWandererNormalCDEnd, playerWandererSkill1CDEnd;
chrono::steady_clock::time_point playerWandererShortSubSkillCDEnd, playerWandererLongSkill2CDEnd, playerWandererLongSubSkillCDEnd;

int enemyWandererState = 0;
chrono::steady_clock::time_point enemyWandererStateSwitchWindow;
bool enemyWandererShortSkill2Used = false;
int enemyWandererLongSkill2Count = 2;
bool enemyWandererSpinActive = false;
chrono::steady_clock::time_point enemyWandererSpinEnd;
bool enemyWandererSpinEnemyTransferred = false;
int enemyWandererSpinEnemySavedX = 0;
bool enemyWandererShockActive = false;
int enemyWandererShockEnemyY = 0;
chrono::steady_clock::time_point enemyWandererShockDropTime;
chrono::steady_clock::time_point enemyWandererNormalCDEnd, enemyWandererSkill1CDEnd;
chrono::steady_clock::time_point enemyWandererShortSubSkillCDEnd, enemyWandererLongSkill2CDEnd, enemyWandererLongSubSkillCDEnd;

// ==================== 水门变量(修改后,去掉苦无/飞雷神相关) ====================
bool playerMinatoKunaiActive = false; int playerMinatoKunaiX = 0;
chrono::steady_clock::time_point playerMinatoNormalCDEnd;
bool playerMinatoMarkActive = false; int playerMinatoMarkX = 0;
chrono::steady_clock::time_point playerMinatoMarkEnd;
bool playerMinatoCounterReady = false;
chrono::steady_clock::time_point playerMinatoSkill1CDEnd, playerMinatoSkill2CDEnd, playerMinatoUltimateCDEnd;

bool enemyMinatoKunaiActive = false; int enemyMinatoKunaiX = 0;
chrono::steady_clock::time_point enemyMinatoNormalCDEnd;
bool enemyMinatoMarkActive = false; int enemyMinatoMarkX = 0;
chrono::steady_clock::time_point enemyMinatoMarkEnd;
bool enemyMinatoCounterReady = false;
chrono::steady_clock::time_point enemyMinatoSkill1CDEnd, enemyMinatoSkill2CDEnd, enemyMinatoUltimateCDEnd;

// ==================== AI变量 ====================
int enemyPhase = 0, enemyNormalAttackCount = 0; bool enemyUltimateReady = false;
int enemyAIMood = 0, enemyConsecutiveSkills = 0, enemyStuckCounter = 0, enemyLastActionType = -1;
chrono::steady_clock::time_point enemyLastSkillTime; bool enemyJustMoved = false;

// ==================== 工具函数 ====================
int getRemainingCD(chrono::steady_clock::time_point cdEnd) {
    auto now = chrono::steady_clock::now();
    if (now >= cdEnd) return 0;
    return chrono::duration_cast<chrono::seconds>(cdEnd - now).count() + 1;
}

vector<Character> getAllCharacters() {
    vector<Character> chars;
    chars.push_back({ "漩涡鸣人(九尾查克拉)",300,300,0,0,true,{{"螺旋丸",8,0,8,15,"O",1},{"九尾抓取",15,0,20,25,"------",0},{"尾兽玉",0,0,35,35,"0",3}},0 });
    chars.push_back({ "佐助(鹰小队)",300,300,0,0,false,{},0 });
    chars.push_back({ "旗木卡卡西(万花筒写轮眼)",300,300,0,0,false,{},0 });
    chars.push_back({ "波风水门(四代目火影)",300,300,0,0,true,{},9 });
    chars.push_back({ "春野樱(百豪怪力)",300,300,0,0,false,{},0 });
    chars.push_back({ "自来也(仙人模式)",300,300,0,0,false,{},0 });
    chars.push_back({ "纲手(百豪)",300,300,0,0,false,{},0 });
    chars.push_back({ "大蛇丸(八岐之术)",300,300,0,0,false,{},0 });
    chars.push_back({ "漩涡长门(轮回之力)",300,300,0,0,false,{},0 });
    chars.push_back({ "佩恩(天道)",300,300,0,0,true,{{"万象天引",12,0,10,13,"\\/",5},{"神罗天征",15,0,8,15,"()",3},{"超神罗天征",0,0,50,50,"{}",5}},1 });
    chars.push_back({ "佩恩(修罗道)",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波斑(虎皮面具男)",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波带土(忍界大战)",300,300,0,0,true,{{"木遁-扦插/火遁-火龙卷",20,0,12,16,"-",15},{"神威/神威-空间",10,0,0,0,"()",5},{"十尾入侵",0,0,50,50,"*",5}},2 });
    chars.push_back({ "大筒木博人",300,300,0,0,true,{{"螺旋丸-涡彦/大筒木-飞行",18,0,8,12,"O",3},{"亚-飞雷神/超大玉螺旋丸",8,0,10,18,"----",5},{"楔",45,0,0,0,"*",60}},3 });
    chars.push_back({ "千手柱间",300,300,0,0,true,{{"木龙扦插之术/明神门",15,0,15,20,"~",8},{"木人之术",18,0,22,35,"¥",5},{"千手观音",0,0,80,80,"\\",3}},4 });
    chars.push_back({ "宇智波佐助(六道-阴)",300,300,0,0,true,{{"天照",10,0,5,5,"-",5},{"天手力",8,0,12,18,")",2},{"地爆天星-斩",0,0,20,35,"*",5}},5 });
    chars.push_back({ "宇智波泉奈",300,300,0,0,true,{{"火遁-豪火球",18,0,18,21,"-",3},{"宇智波流剑术",20,0,20,24,"-",3},{"宇智波的荣耀",0,0,40,40,"|",5}},6 });
    chars.push_back({ "黑绝",300,300,0,0,true,{},7 });
    chars.push_back({ "宇智波带土(漂泊浪客)",300,300,0,0,true,{},8 });
    chars.push_back({ "佩恩(畜生道-男)",300,300,0,0,false,{},0 });
    chars.push_back({ "佩恩(畜生道-女)",300,300,0,0,false,{},0 });
    chars.push_back({ "佩恩(人间道)",300,300,0,0,false,{},0 });
    chars.push_back({ "佩恩(地狱道)",300,300,0,0,false,{},0 });
    chars.push_back({ "佩恩(饿鬼道)",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波斑",300,300,0,0,false,{},0 });
    chars.push_back({ "千手扉间",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波斑(秽土转生)",300,300,0,0,false,{},0 });
    chars.push_back({ "千手柱间(秽土转生)",300,300,0,0,false,{},0 });
    chars.push_back({ "千手扉间(秽土转生)",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波鼬(灭族之夜)",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波鼬(晓)",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波鼬(秽土转生)",300,300,0,0,false,{},0 });
    chars.push_back({ "面具男(灭族之夜)",300,300,0,0,false,{},0 });
    chars.push_back({ "旗木卡卡西(须佐能乎)",300,300,0,0,false,{},0 });
    chars.push_back({ "绝(晓)",300,300,0,0,false,{},0 });
    chars.push_back({ "鬼鲛(晓)",300,300,0,0,false,{},0 });
    chars.push_back({ "鬼鲛(鲛肌)",300,300,0,0,false,{},0 });
    chars.push_back({ "迪达拉(晓)",300,300,0,0,false,{},0 });
    chars.push_back({ "迪达拉(秽土转生)",300,300,0,0,false,{},0 });
    chars.push_back({ "蝎(晓)",300,300,0,0,false,{},0 });
    chars.push_back({ "蝎(秽土转生)",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波止水(万花筒写轮眼)",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波止水(须佐能乎)",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波佐助(须佐能乎)",300,300,0,0,false,{},0 });
    chars.push_back({ "漩涡鸣人(六道-阳)",300,300,0,0,false,{},0 });
    chars.push_back({ "神农",300,300,0,0,false,{},0 });
    chars.push_back({ "我爱罗(青年)",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波带土(十尾人柱力)",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波斑(十尾人柱力)",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波斑(六道)",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波带土(双神威)",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波带土(百战成灰)",300,300,0,0,false,{},0 });
    chars.push_back({ "春野樱(忍战)",300,300,0,0,false,{},0 });
    chars.push_back({ "我爱罗(忍战)",300,300,0,0,false,{},0 });
    chars.push_back({ "大筒木辉夜",300,300,0,0,false,{},0 });
    chars.push_back({ "角都(晓)",300,300,0,0,false,{},0 });
    chars.push_back({ "角都(秽土转生)",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波佐良娜",300,300,0,0,false,{},0 });
    chars.push_back({ "漩涡博人",300,300,0,0,false,{},0 });
    chars.push_back({ "漩涡向日葵",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波佐良娜(万花筒写轮眼)",300,300,0,0,false,{},0 });
    chars.push_back({ "川木(楔)",300,300,0,0,false,{},0 });
    chars.push_back({ "漩涡博人(桃式)",300,300,0,0,false,{},0 });
    chars.push_back({ "漩涡向日葵(九尾查克拉)",300,300,0,0,false,{},0 });
    chars.push_back({ "漩涡川木(青年)",300,300,0,0,false,{},0 });
    chars.push_back({ "漩涡鸣人(重粒子模式)",300,300,0,0,false,{},0 });
    chars.push_back({ "宇智波佐助(轮回眼)",300,300,0,0,false,{},0 });
    chars.push_back({ "大筒木桃式",300,300,0,0,false,{},0 });
    chars.push_back({ "大筒木金式",300,300,0,0,false,{},0 });
    chars.push_back({ "大筒木壹式",300,300,0,0,false,{},0 });
    return chars;
}

// ==================== 界面绘制 ====================
void drawStartScreen() {
    clearScreen(); hideCursor(); setColor(6);
    gotoxy(35, 10); cout << "=========================";
    gotoxy(35, 11); cout << "||                     ||";
    gotoxy(35, 12); cout << "||      火影忍者       ||";
    gotoxy(35, 13); cout << "||                     ||";
    gotoxy(35, 14); cout << "=========================";
    setColor(7); gotoxy(35, 17); cout << "按 ENTER 进入游戏";
}
void drawLaunchScreen(int selectedIndex) {
    clearScreen(); hideCursor(); setColor(6);
    gotoxy(40, 5); cout << "火 影 忍 者"; setColor(7);
    vector<string> options = { "对决模式","剧情模式","打开官网","退出游戏" };
    for (int i = 0; i < options.size(); i++) {
        gotoxy(35, 10 + i * 3);
        if (i == selectedIndex) { setColor(10); cout << "> "; }
        else { cout << "  "; }
        setColor(7); cout << options[i];
    }
    setColor(8); gotoxy(30, 25); cout << "W/S - 选择  |  ENTER - 确认";
}
void drawSelectScreen(int selectedIndex) {
    clearScreen(); hideCursor(); setColor(6);
    gotoxy(35, 2); cout << "=== 选择你的忍者 ===";
    vector<Character> chars = getAllCharacters();
    int row = 0, col = 0;
    for (int i = 0; i < chars.size(); i++) {
        int x = 2 + col * 24; int y = 5 + row * 3;
        gotoxy(x, y);
        if (i == selectedIndex) { setColor(10); cout << "> "; }
        else { cout << "  "; }
        if (chars[i].available) { setColor(10); }
        else { setColor(12); }
        cout << chars[i].name;
        col++; if (col >= 5) { col = 0; row++; }
    }
}
void drawBattleMap() {
    clearScreen(); hideCursor();
    gotoxy(2, 0); setColor(10); cout << player.name;
    if (playerBlackZetsuCarrier) cout << "(黑绝载体)";
    gotoxy(2, 1); cout << "HP: [";
    int hpBars = player.hp * 50 / player.maxHp; if (hpBars < 0) hpBars = 0;
    for (int i = 0; i < 50; i++) {
        if (i < hpBars) { setColor(10); cout << "#"; }
        else { setColor(8); cout << "-"; }
    }
    setColor(7); cout << "] " << player.hp << "/" << player.maxHp;
    gotoxy(MAP_WIDTH + MAP_START_X - 20, 0); setColor(12); cout << enemy.name;
    gotoxy(MAP_WIDTH + MAP_START_X - 20, 1); cout << "HP: [";
    hpBars = enemy.hp * 50 / enemy.maxHp; if (hpBars < 0) hpBars = 0;
    for (int i = 0; i < 50; i++) {
        if (i < hpBars) { setColor(12); cout << "#"; }
        else { setColor(8); cout << "-"; }
    }
    setColor(7); cout << "] " << enemy.hp << "/" << enemy.maxHp;

    gotoxy(MAP_START_X, MAP_START_Y); for (int i = 0; i < MAP_WIDTH; i++) cout << "-";
    gotoxy(MAP_START_X, MAP_START_Y + MAP_HEIGHT); for (int i = 0; i < MAP_WIDTH; i++) cout << "-";
    for (int i = 0; i < MAP_HEIGHT; i++) {
        gotoxy(MAP_START_X, MAP_START_Y + i); cout << "|";
        gotoxy(MAP_START_X + MAP_WIDTH, MAP_START_Y + i); cout << "|";
    }

    int charY = MAP_START_Y + CHARACTER_ROW;
    int enemyDrawY = charY;

    // 震刀/转刀时敌人高度调整
    if (enemyWandererShockActive) enemyDrawY = MAP_START_Y + enemyWandererShockEnemyY;
    else if (playerWandererShockActive) enemyDrawY = MAP_START_Y + CHARACTER_ROW; // 玩家震刀时敌人坐标由y控制,这里不变
    if (playerWandererSpinActive && playerWandererSpinEnemyTransferred) enemyDrawY = MAP_START_Y + CHARACTER_ROW - 2;
    else if (enemyWandererSpinActive && enemyWandererSpinEnemyTransferred) enemyDrawY = MAP_START_Y + CHARACTER_ROW - 2;
    if (!playerObitoEnemyInSpace && !enemyObitoPlayerInSpace) {
        gotoxy(MAP_START_X + enemy.x, enemyDrawY); setColor(12); cout << "&";
    }
    int borutoY = charY;
    if (playerBorutoFlying) {
        auto now = chrono::steady_clock::now();
        if (now < playerBorutoFlyingEnd) borutoY = charY - 2; else playerBorutoFlying = false;
    }
    if (enemyBorutoFlying) {
        auto now = chrono::steady_clock::now();
        if (now < enemyBorutoFlyingEnd) charY = MAP_START_Y + CHARACTER_ROW - 2; else enemyBorutoFlying = false;
    }
    if (playerWandererSpinActive) { gotoxy(MAP_START_X + player.x, borutoY - 1); setColor(13); cout << "-"; }
    if (enemyWandererSpinActive) { gotoxy(MAP_START_X + enemy.x, charY - 1); setColor(13); cout << "-"; }
    gotoxy(MAP_START_X + player.x, borutoY); setColor(10); cout << "@";
    if ((playerCharacterType == 8 && playerWandererState == 1) || playerWandererShockActive) { gotoxy(MAP_START_X + player.x - 1, borutoY); setColor(13); cout << "|"; }
    if ((enemyCharacterType == 8 && enemyWandererState == 1) || enemyWandererShockActive) { gotoxy(MAP_START_X + enemy.x - 1, charY); setColor(13); cout << "|"; }

    // ---------- 鸣人尾巴 ----------
    if (playerNarutoTailActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerNarutoTailEnd) {
            for (int i = 0; i < 3; i++) {
                if (playerNarutoTailX[i] > 0 && playerNarutoTailX[i] < MAP_WIDTH && playerNarutoTailX[i] != enemy.x) {
                    gotoxy(MAP_START_X + playerNarutoTailX[i], charY); setColor(14); cout << "-";
                }
            }
        }
        else { playerNarutoTailActive = false; }
    }
    if (enemyNarutoTailActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemyNarutoTailEnd) {
            for (int i = 0; i < 3; i++) {
                if (enemyNarutoTailX[i] > 0 && enemyNarutoTailX[i] < MAP_WIDTH && enemyNarutoTailX[i] != player.x) {
                    gotoxy(MAP_START_X + enemyNarutoTailX[i], charY); setColor(14); cout << "-";
                }
            }
        }
        else { enemyNarutoTailActive = false; }
    }
    // ---------- 黑棒 ----------
    if (playerPainRodActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerPainRodEnd) {
            if (playerPainRodX > 0 && playerPainRodX < MAP_WIDTH && playerPainRodX != enemy.x && playerPainRodX != player.x) {
                gotoxy(MAP_START_X + playerPainRodX, charY); setColor(8); cout << "\\";
            }
        }
        else { playerPainRodActive = false; playerRodHitting = false; }
    }
    if (enemyPainRodActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemyPainRodEnd) {
            if (enemyPainRodX > 0 && enemyPainRodX < MAP_WIDTH && enemyPainRodX != player.x && enemyPainRodX != enemy.x) {
                gotoxy(MAP_START_X + enemyPainRodX, charY); setColor(8); cout << "\\";
            }
        }
        else { enemyPainRodActive = false; enemyRodHitting = false; }
    }
    // ---------- 万象天引黑棒 ----------
    if (playerBanshoTeninActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerBanshoTeninEnd) {
            if (playerBlackRodLeftX > 0 && playerBlackRodLeftX != enemy.x && playerBlackRodLeftX != player.x) {
                gotoxy(MAP_START_X + playerBlackRodLeftX, charY); setColor(8); cout << "\\";
            }
            if (playerBlackRodRightX < MAP_WIDTH && playerBlackRodRightX != enemy.x && playerBlackRodRightX != player.x) {
                gotoxy(MAP_START_X + playerBlackRodRightX, charY); cout << "/";
            }
        }
        else { playerBanshoTeninActive = false; }
    }
    if (enemyBanshoTeninActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemyBanshoTeninEnd) {
            if (enemyBlackRodLeftX > 0 && enemyBlackRodLeftX != player.x && enemyBlackRodLeftX != enemy.x) {
                gotoxy(MAP_START_X + enemyBlackRodLeftX, charY); setColor(8); cout << "\\";
            }
            if (enemyBlackRodRightX < MAP_WIDTH && enemyBlackRodRightX != player.x && enemyBlackRodRightX != enemy.x) {
                gotoxy(MAP_START_X + enemyBlackRodRightX, charY); cout << "/";
            }
        }
        else { enemyBanshoTeninActive = false; }
    }
    // ---------- 带土踢 ----------
    if (playerObitoKickActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerObitoKickEnd) {
            if (playerObitoKickX > 0 && playerObitoKickX < MAP_WIDTH && playerObitoKickX != enemy.x) {
                gotoxy(MAP_START_X + playerObitoKickX, charY); setColor(8); cout << "-";
            }
        }
        else { playerObitoKickActive = false; }
    }
    if (enemyObitoKickActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemyObitoKickEnd) {
            if (enemyObitoKickX > 0 && enemyObitoKickX < MAP_WIDTH && enemyObitoKickX != player.x) {
                gotoxy(MAP_START_X + enemyObitoKickX, charY); setColor(8); cout << "-";
            }
        }
        else { enemyObitoKickActive = false; }
    }
    // ---------- 木遁扦插 ----------
    if (playerObitoWoodSpikeActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerObitoWoodSpikeEnd && playerObitoWoodSpikeX > 0 && playerObitoWoodSpikeX < MAP_WIDTH) {
            if (playerObitoWoodSpikeX != enemy.x && playerObitoWoodSpikeX != player.x) {
                gotoxy(MAP_START_X + playerObitoWoodSpikeX, charY); setColor(2); cout << "-";
            }
        }
        if (playerObitoEnemyTrapped && now < playerObitoEnemyTrappedEnd) {
            if (enemy.x - 1 > 0 && enemy.x - 1 != player.x) { gotoxy(MAP_START_X + enemy.x - 1, charY); setColor(2); cout << ">"; }
            if (enemy.x + 1 < MAP_WIDTH && enemy.x + 1 != player.x) { gotoxy(MAP_START_X + enemy.x + 1, charY); setColor(2); cout << "<"; }
        }
        else if (now >= playerObitoEnemyTrappedEnd) { playerObitoEnemyTrapped = false; playerObitoWoodSpikeActive = false; }
    }
    if (enemyObitoWoodSpikeActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemyObitoWoodSpikeEnd && enemyObitoWoodSpikeX > 0 && enemyObitoWoodSpikeX < MAP_WIDTH) {
            if (enemyObitoWoodSpikeX != player.x && enemyObitoWoodSpikeX != enemy.x) {
                gotoxy(MAP_START_X + enemyObitoWoodSpikeX, charY); setColor(2); cout << "-";
            }
        }
        if (enemyObitoEnemyTrapped && now < enemyObitoEnemyTrappedEnd) {
            if (player.x - 1 > 0 && player.x - 1 != enemy.x) { gotoxy(MAP_START_X + player.x - 1, charY); setColor(2); cout << ">"; }
            if (player.x + 1 < MAP_WIDTH && player.x + 1 != enemy.x) { gotoxy(MAP_START_X + player.x + 1, charY); setColor(2); cout << "<"; }
        }
    }
    // ---------- 神威 ----------
    if (playerObitoKamuiActive && !playerObitoKamuiSpaceActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerObitoKamuiEnd) {
            if (player.x - 1 > 0) { gotoxy(MAP_START_X + player.x - 1, charY); setColor(4); cout << "("; }
            if (player.x + 1 < MAP_WIDTH) { gotoxy(MAP_START_X + player.x + 1, charY); setColor(4); cout << ")"; }
        }
        else { playerObitoKamuiActive = false; }
    }
    if (enemyObitoKamuiActive && !enemyObitoKamuiSpaceActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemyObitoKamuiEnd) {
            if (enemy.x - 1 > 0) { gotoxy(MAP_START_X + enemy.x - 1, charY); setColor(4); cout << "("; }
            if (enemy.x + 1 < MAP_WIDTH) { gotoxy(MAP_START_X + enemy.x + 1, charY); setColor(4); cout << ")"; }
        }
        else { enemyObitoKamuiActive = false; }
    }
    // ---------- 博人剑术 ----------
    if (playerBorutoSwordActive && playerBorutoSwordSlashing) {
        if (playerBorutoSwordX > 0 && playerBorutoSwordX < MAP_WIDTH) {
            gotoxy(MAP_START_X + playerBorutoSwordX, charY); setColor(15); cout << "-";
            if (playerBorutoSwordX + 1 < MAP_WIDTH) { gotoxy(MAP_START_X + playerBorutoSwordX + 1, charY); setColor(15); cout << "-"; }
        }
    }
    if (enemyBorutoSwordActive && enemyBorutoSwordSlashing) {
        if (enemyBorutoSwordX > 0 && enemyBorutoSwordX < MAP_WIDTH) {
            gotoxy(MAP_START_X + enemyBorutoSwordX, charY); setColor(15); cout << "-";
            if (enemyBorutoSwordX + 1 < MAP_WIDTH) { gotoxy(MAP_START_X + enemyBorutoSwordX + 1, charY); setColor(15); cout << "-"; }
        }
    }
    // ---------- 螺旋丸涡彦 ----------
    if (playerBorutoRasenganActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerBorutoRasenganEnd) { gotoxy(MAP_START_X + enemy.x - 1, charY); setColor(11); cout << "O"; }
        else { playerBorutoRasenganActive = false; }
    }
    if (enemyBorutoRasenganActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemyBorutoRasenganEnd) { gotoxy(MAP_START_X + player.x + 1, charY); setColor(11); cout << "O"; }
        else { enemyBorutoRasenganActive = false; }
    }
    // ---------- 飞雷神标记(博人/水门通用) ----------
    if (playerBorutoMarkActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerBorutoMarkEnd) {
            if (playerBorutoMarkX > 0 && playerBorutoMarkX < MAP_WIDTH) {
                gotoxy(MAP_START_X + playerBorutoMarkX, charY - 1); setColor(9); cout << "*";
            }
        }
        else { playerBorutoMarkActive = false; }
    }
    if (enemyBorutoMarkActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemyBorutoMarkEnd) {
            if (enemyBorutoMarkX > 0 && enemyBorutoMarkX < MAP_WIDTH) {
                gotoxy(MAP_START_X + enemyBorutoMarkX, charY - 1); setColor(9); cout << "*";
            }
        }
        else { enemyBorutoMarkActive = false; }
    }
    // 水门标记
    if (playerMinatoMarkActive) {
        gotoxy(MAP_START_X + playerMinatoMarkX, charY - 1); setColor(6); cout << "#";
    }
    if (enemyMinatoMarkActive) {
        gotoxy(MAP_START_X + enemyMinatoMarkX, charY - 1); setColor(6); cout << "#";
    }
    // ---------- 柱间跺脚 ----------
    if (playerHashiramaStompActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerHashiramaStompEnd) {
            if (playerHashiramaStompX > 0 && playerHashiramaStompX < MAP_WIDTH && playerHashiramaStompX != enemy.x) {
                gotoxy(MAP_START_X + playerHashiramaStompX, charY); setColor(8); cout << "L";
            }
        }
        else { playerHashiramaStompActive = false; }
    }
    if (enemyHashiramaStompActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemyHashiramaStompEnd) {
            if (enemyHashiramaStompX > 0 && enemyHashiramaStompX < MAP_WIDTH && enemyHashiramaStompX != player.x) {
                gotoxy(MAP_START_X + enemyHashiramaStompX, charY); setColor(8); cout << "L";
            }
        }
        else { enemyHashiramaStompActive = false; }
    }
    // ---------- 木龙 ----------
    if (playerHashiramaWoodDragonActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerHashiramaWoodDragonEnd) {
            for (int i = 0; i < 10; i++) {
                int dx = player.x + 1 + i;
                if (dx < MAP_WIDTH && dx != enemy.x && dx != player.x) { gotoxy(MAP_START_X + dx, charY); setColor(2); cout << "~"; }
            }
            if (player.x + 1 < MAP_WIDTH) { gotoxy(MAP_START_X + player.x + 1, charY); setColor(2); cout << "€"; }
        }
        if (playerHashiramaEnemyTrapped && now < playerHashiramaWoodDragonTrapEnd) {
            if (enemy.x - 1 > 0 && enemy.x - 1 != player.x) { gotoxy(MAP_START_X + enemy.x - 1, charY); setColor(2); cout << ">"; }
            if (enemy.x + 1 < MAP_WIDTH && enemy.x + 1 != player.x) { gotoxy(MAP_START_X + enemy.x + 1, charY); setColor(2); cout << "<"; }
        }
    }
    if (enemyHashiramaWoodDragonActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemyHashiramaWoodDragonEnd) {
            for (int i = 0; i < 10; i++) {
                int dx = enemy.x - 1 - i;
                if (dx > 0 && dx != player.x && dx != enemy.x) { gotoxy(MAP_START_X + dx, charY); setColor(2); cout << "~"; }
            }
            if (enemy.x - 1 > 0) { gotoxy(MAP_START_X + enemy.x - 1, charY); setColor(2); cout << "€"; }
        }
        if (enemyHashiramaEnemyTrapped && now < enemyHashiramaWoodDragonTrapEnd) {
            if (player.x - 1 > 0 && player.x - 1 != enemy.x) { gotoxy(MAP_START_X + player.x - 1, charY); setColor(2); cout << ">"; }
            if (player.x + 1 < MAP_WIDTH && player.x + 1 != enemy.x) { gotoxy(MAP_START_X + player.x + 1, charY); setColor(2); cout << "<"; }
        }
    }
    // ---------- 明神门 ----------
    if (playerHashiramaMyojinmonActive) {
        if (enemy.x - 2 > 0 && enemy.x - 2 != player.x) { gotoxy(MAP_START_X + enemy.x - 2, charY); setColor(12); cout << "|"; }
        if (enemy.x + 2 < MAP_WIDTH && enemy.x + 2 != player.x) { gotoxy(MAP_START_X + enemy.x + 2, charY); setColor(12); cout << "|"; }
    }
    if (enemyHashiramaMyojinmonActive) {
        if (player.x - 2 > 0 && player.x - 2 != enemy.x) { gotoxy(MAP_START_X + player.x - 2, charY); setColor(12); cout << "|"; }
        if (player.x + 2 < MAP_WIDTH && player.x + 2 != enemy.x) { gotoxy(MAP_START_X + player.x + 2, charY); setColor(12); cout << "|"; }
    }
    // ---------- 木人 ----------
    if (playerHashiramaWoodGolemActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerHashiramaWoodGolemEnd) {
            for (int row = 0; row < 3; row++) {
                for (int col = 0; col < 4; col++) {
                    int gx = player.x - 1 + col, gy = charY - 3 - row;
                    if (gx > 0 && gx < MAP_WIDTH && gy > 0) { gotoxy(MAP_START_X + gx, MAP_START_Y + gy); setColor(6); cout << "¥"; }
                }
            }
        }
        else { playerHashiramaWoodGolemActive = false; playerHashiramaWoodGolemAttackCount = 0; }
    }
    if (enemyHashiramaWoodGolemActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemyHashiramaWoodGolemEnd) {
            for (int row = 0; row < 3; row++) {
                for (int col = 0; col < 4; col++) {
                    int gx = enemy.x - 1 + col, gy = charY - 3 - row;
                    if (gx > 0 && gx < MAP_WIDTH && gy > 0) { gotoxy(MAP_START_X + gx, MAP_START_Y + gy); setColor(6); cout << "¥"; }
                }
            }
        }
        else { enemyHashiramaWoodGolemActive = false; enemyHashiramaWoodGolemAttackCount = 0; }
    }
    // ---------- 佐助剑气/天照/须佐 ----------
    if (playerSasukeSlashActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerSasukeSlashEnd) { gotoxy(MAP_START_X + player.x + 1, charY); setColor(13); cout << ")"; }
        else { playerSasukeSlashActive = false; }
    }
    if (enemySasukeSlashActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemySasukeSlashEnd) { gotoxy(MAP_START_X + enemy.x - 1, charY); setColor(13); cout << ")"; }
        else { enemySasukeSlashActive = false; }
    }
    if (playerSasukeAmaterasuActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerSasukeAmaterasuEnd) {
            for (int i = 1; i <= 8; i++) {
                int ax = player.x + i; if (ax < MAP_WIDTH && ax < enemy.x && ax != player.x) {
                    gotoxy(MAP_START_X + ax, charY); setColor(13); cout << "-";
                }
            }
            if (enemy.x - 1 > 0) { gotoxy(MAP_START_X + enemy.x - 1, charY); setColor(13); cout << "|"; }
            if (enemy.x + 1 < MAP_WIDTH) { gotoxy(MAP_START_X + enemy.x + 1, charY); setColor(13); cout << "|"; }
            if (playerSasukeAmaterasuHit) {
                if (now >= playerSasukeAmaterasuTick) {
                    enemy.hp -= increasePlayerDamage(5); if (enemy.hp < 0) enemy.hp = 0;
                    playerSasukeAmaterasuTick = now + chrono::milliseconds(500);
                }
            }
        }
        else { playerSasukeAmaterasuActive = false; playerSasukeAmaterasuHit = false; skillInProgress = false; }
    }
    if (enemySasukeAmaterasuActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemySasukeAmaterasuEnd) {
            for (int i = 1; i <= 8; i++) {
                int ax = enemy.x - i; if (ax > 0 && ax > player.x && ax != enemy.x) {
                    gotoxy(MAP_START_X + ax, charY); setColor(13); cout << "-";
                }
            }
            if (player.x - 1 > 0) { gotoxy(MAP_START_X + player.x - 1, charY); setColor(13); cout << "|"; }
            if (player.x + 1 < MAP_WIDTH) { gotoxy(MAP_START_X + player.x + 1, charY); setColor(13); cout << "|"; }
            if (enemySasukeAmaterasuHit) {
                if (now >= enemySasukeAmaterasuTick) {
                    player.hp -= reducePlayerDamage(5); if (player.hp < 0) player.hp = 0;
                    enemySasukeAmaterasuTick = now + chrono::milliseconds(500);
                }
            }
        }
        else { enemySasukeAmaterasuActive = false; enemySasukeAmaterasuHit = false; enemySkillInProgress = false; }
    }
    if (playerSasukeSusanooActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerSasukeSusanooEnd) {
            for (int row = 0; row < 8; row++) {
                for (int col = 0; col < 4; col++) {
                    int sx = player.x - 1 + col, sy = charY - 2 - row;
                    if (sx > 0 && sx < MAP_WIDTH && sy > 0) { gotoxy(MAP_START_X + sx, MAP_START_Y + sy); setColor(13); cout << "#"; }
                }
            }
        }
        if (playerSasukeSusanooSlashActive) {
            for (int row = 0; row < 8; row++) {
                int sx = player.x + 3, sy = charY - 2 - row;
                if (sx > 0 && sx < MAP_WIDTH && sy > 0) { gotoxy(MAP_START_X + sx, MAP_START_Y + sy); setColor(13); cout << "}"; }
            }
        }
    }
    else { playerSasukeSusanooActive = false; playerSasukeSusanooSlashCount = 0; }
    if (enemySasukeSusanooActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemySasukeSusanooEnd) {
            for (int row = 0; row < 8; row++) {
                for (int col = 0; col < 4; col++) {
                    int sx = enemy.x - 1 + col, sy = charY - 2 - row;
                    if (sx > 0 && sx < MAP_WIDTH && sy > 0) { gotoxy(MAP_START_X + sx, MAP_START_Y + sy); setColor(13); cout << "#"; }
                }
            }
        }
        if (enemySasukeSusanooSlashActive) {
            for (int row = 0; row < 8; row++) {
                int sx = enemy.x - 3, sy = charY - 2 - row;
                if (sx > 0 && sx < MAP_WIDTH && sy > 0) { gotoxy(MAP_START_X + sx, MAP_START_Y + sy); setColor(13); cout << "}"; }
            }
        }
    }
    else { enemySasukeSusanooActive = false; enemySasukeSusanooSlashCount = 0; }
    // ---------- 泉奈 ----------
    if (playerIzunaSlashActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerIzunaSlashEnd) { gotoxy(MAP_START_X + player.x + 1, charY); setColor(9); cout << ")"; }
        else { playerIzunaSlashActive = false; }
    }
    if (enemyIzunaSlashActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemyIzunaSlashEnd) { gotoxy(MAP_START_X + enemy.x - 1, charY); setColor(9); cout << ")"; }
        else { enemyIzunaSlashActive = false; }
    }
    if (playerIzunaFireballActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerIzunaFireballEnd) {
            for (int i = 0; i < 6; i++) {
                int fx = player.x + 1 + i; if (fx < MAP_WIDTH && fx != enemy.x && fx != player.x) { gotoxy(MAP_START_X + fx, charY); setColor(12); cout << "-"; }
            }
            if (player.x + 7 < MAP_WIDTH) { gotoxy(MAP_START_X + player.x + 7, charY); setColor(14); cout << "*"; }
        }
        else { playerIzunaFireballActive = false; }
    }
    if (enemyIzunaFireballActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemyIzunaFireballEnd) {
            for (int i = 0; i < 6; i++) {
                int fx = enemy.x - 1 - i; if (fx > 0 && fx != player.x && fx != enemy.x) { gotoxy(MAP_START_X + fx, charY); setColor(12); cout << "-"; }
            }
            if (enemy.x - 7 > 0) { gotoxy(MAP_START_X + enemy.x - 7, charY); setColor(14); cout << "*"; }
        }
        else { enemyIzunaFireballActive = false; }
    }
    if (playerIzunaSwordActive) {
        auto now = chrono::steady_clock::now();
        if (now < playerIzunaSwordEnd) {
            for (int i = 0; i < 3; i++) {
                int sx = player.x + 1 + i; if (sx < MAP_WIDTH && sx != enemy.x && sx != player.x) { gotoxy(MAP_START_X + sx, charY); setColor(9); cout << "-"; }
            }
        }
        else { playerIzunaSwordActive = false; }
    }
    if (enemyIzunaSwordActive) {
        auto now = chrono::steady_clock::now();
        if (now < enemyIzunaSwordEnd) {
            for (int i = 0; i < 3; i++) {
                int sx = enemy.x - 1 - i; if (sx > 0 && sx != player.x && sx != enemy.x) { gotoxy(MAP_START_X + sx, charY); setColor(9); cout << "-"; }
            }
        }
        else { enemyIzunaSwordActive = false; }
    }
    if (playerIzunaCounterActive && !playerIzunaCounterTriggered) {
        gotoxy(MAP_START_X + player.x, charY - 1); setColor(11); cout << "!";
    }
    if (enemyIzunaCounterActive && !enemyIzunaCounterTriggered) {
        gotoxy(MAP_START_X + enemy.x, charY - 1); setColor(11); cout << "!";
    }
    // ---------- 博人超大玉螺旋丸持续伤害 ----------
    if (playerBorutoBigRasenganHit) {
        auto now = chrono::steady_clock::now();
        if (now < playerBorutoBigRasenganDotEnd) {
            int dotDamage = rand() % 4 + 2;
            enemy.hp -= increasePlayerDamage(dotDamage); if (enemy.hp < 0) enemy.hp = 0;
        }
        else { playerBorutoBigRasenganHit = false; }
    }
    // ---------- 博人楔状态结束 ----------
    if (playerBorutoKarmaActive) {
        auto now = chrono::steady_clock::now();
        if (now >= playerBorutoKarmaEnd) { playerBorutoKarmaActive = false; playerBorutoFlying = false; playerBorutoEnhancedAttackCount = 0; playerBorutoBigRasenganHit = false; }
    }
    if (enemyBorutoKarmaActive) {
        auto now = chrono::steady_clock::now();
        if (now >= enemyBorutoKarmaEnd) { enemyBorutoKarmaActive = false; enemyBorutoFlying = false; enemyBorutoEnhancedAttackCount = 0; }
    }

    // 技能信息栏
    setColor(7); gotoxy(MAP_START_X, MAP_START_Y + MAP_HEIGHT + 2);
    if (playerCharacterType == 7) {
        int cd = getRemainingCD(playerBlackZetsuNormalCDEnd);
        cout << "技能: K-普攻(移至左侧)";
        if (cd > 0) { setColor(8); cout << "(CD:" << cd << "s)"; }
        else { setColor(10); cout << "(就绪)"; }
        setColor(7); cout << " | J/I/O-无技能";
    }
    else if (playerCharacterType == 8) {
        cout << "状态:" << (playerWandererState == 0 ? "短刀" : "长刀") << " | K-剑气(CD:" << getRemainingCD(playerWandererNormalCDEnd) << "s)";
        cout << " | J-挥砍(CD:" << getRemainingCD(playerWandererSkill1CDEnd) << "s)";
        if (playerWandererState == 0) {
            cout << " | I-三连斩(" << (playerWandererShortSkill2Used ? "已用" : "可用") << ")";
            if (playerWandererShortSkill2Used) cout << " | U-转刀(CD:" << getRemainingCD(playerWandererShortSubSkillCDEnd) << "s)";
        }
        else {
            cout << " | I-神威虚化(剩余" << playerWandererLongSkill2Count << "次,CD:" << getRemainingCD(playerWandererLongSkill2CDEnd) << "s)";
            cout << " | U-震刀(CD:" << getRemainingCD(playerWandererLongSubSkillCDEnd) << "s)";
        }
        cout << " | O-奥义(敌HP<=80)";
    }
    else if (playerCharacterType == 9) {
        cout << "技能: K-苦无刺击(CD:" << getRemainingCD(playerMinatoNormalCDEnd) << "s) | J-螺旋丸(CD:" << getRemainingCD(playerMinatoSkill1CDEnd) << "s)";
        cout << " | I-神速(CD:" << getRemainingCD(playerMinatoSkill2CDEnd) << "s)";
        if (playerMinatoCounterReady) cout << "(可防反)";
        cout << " | O-超大玉螺旋丸(敌HP<=75)";
    }
    else if (playerCharacterType == 0) {
        int cd1 = getRemainingCD(playerSkill1CDEnd), cd2 = getRemainingCD(playerSkill2CDEnd);
        cout << "技能: K-普攻 | J-螺旋丸";
        if (cd1 > 0) { setColor(8); cout << "(CD:" << cd1 << "s)"; }
        else { setColor(10); cout << "(就绪)"; }
        setColor(7); cout << " | I-九尾抓取";
        if (cd2 > 0) { setColor(8); cout << "(CD:" << cd2 << "s)"; }
        else { setColor(10); cout << "(就绪)"; }
        setColor(7); cout << " | O-尾兽玉(敌HP<=35)";
    }
    else if (playerCharacterType == 1) {
        int cd1 = getRemainingCD(playerSkill1CDEnd), cd2 = getRemainingCD(playerSkill2CDEnd);
        cout << "技能: K-普攻 | J-万象天引";
        if (cd1 > 0) { setColor(8); cout << "(CD:" << cd1 << "s)"; }
        else { setColor(10); cout << "(就绪)"; }
        setColor(7); cout << " | I-神罗天征";
        if (playerShinraTenseiActive) { setColor(11); cout << "(激活中)"; }
        else if (cd2 > 0) { setColor(8); cout << "(CD:" << cd2 << "s)"; }
        else { setColor(10); cout << "(就绪)"; }
        setColor(7); cout << " | O-超神罗天征(敌HP<=50)";
    }
    else if (playerCharacterType == 2) {
        int cd1 = getRemainingCD(playerSkill1CDEnd), cd2 = getRemainingCD(playerSkill2CDEnd);
        cout << "技能: K-普攻 | J-";
        if (playerObitoEnemyTrapped) { if (playerObitoFireActive) cout << "火遁-火龙卷(已用)"; else cout << "火遁-火龙卷(可用)"; }
        else cout << "木遁-扦插";
        if (cd1 > 0) { setColor(8); cout << "(CD:" << cd1 << "s)"; }
        else { setColor(10); cout << "(就绪)"; }
        setColor(7); cout << " | I-";
        if (playerObitoKamuiSpaceActive) { cout << "神威空间"; setColor(11); cout << "(空间中)"; }
        else if (playerObitoEnemyTrapped && !playerObitoWoodStormActive) { cout << "木遁-暴风乱舞(可用)"; }
        else if (playerObitoEnemyTrapped && playerObitoWoodStormActive) { cout << "暴风乱舞(已用)"; }
        else if (playerObitoKamuiActive) { cout << "神威-空间"; setColor(11); cout << "(虚化中)"; }
        else { cout << "神威"; if (cd2 > 0) { setColor(8); cout << "(CD:" << cd2 << "s)"; } else { setColor(10); cout << "(就绪)"; } }
        setColor(7); cout << " | O-十尾入侵(敌HP<=50)";
    }
    else if (playerCharacterType == 3) {
        if (playerBorutoKarmaActive) {
            auto now = chrono::steady_clock::now();
            int remaining = chrono::duration_cast<chrono::seconds>(playerBorutoKarmaEnd - now).count(); if (remaining < 0) remaining = 0;
            int cd1 = getRemainingCD(playerSkill1CDEnd), cd2 = getRemainingCD(playerSkill2CDEnd);
            cout << "技能: K-"; if (playerBorutoFlying) cout << "强化螺旋丸(" << 3 - playerBorutoEnhancedAttackCount << ")"; else cout << "普攻";
            cout << " | J-大筒木飞行";
            if (cd1 > 0) { setColor(8); cout << "(CD:" << cd1 << "s)"; }
            else { setColor(10); cout << "(就绪)"; }
            setColor(7); cout << " | I-超大玉螺旋丸";
            if (cd2 > 0) { setColor(8); cout << "(CD:" << cd2 << "s)"; }
            else { setColor(10); cout << "(就绪)"; }
            setColor(7); cout << " | 楔:" << remaining << "s";
        }
        else {
            int cd1 = getRemainingCD(playerSkill1CDEnd), cd2 = getRemainingCD(playerSkill2CDEnd);
            cout << "技能: K-普攻 | J-螺旋丸涡彦";
            if (cd1 > 0) { setColor(8); cout << "(CD:" << cd1 << "s)"; }
            else { setColor(10); cout << "(就绪)"; }
            setColor(7); cout << " | I-亚飞雷神";
            if (playerBorutoTeleported && playerBorutoTeleportBack) { setColor(10); cout << "(可返回)"; }
            else if (cd2 > 0) { setColor(8); cout << "(CD:" << cd2 << "s)"; }
            else { setColor(10); cout << "(就绪)"; }
            setColor(7); int ucd = getRemainingCD(playerSkill3CDEnd);
            if (ucd > 0) cout << " | O-楔(CD:" << ucd << "s)"; else cout << " | O-楔(可用)";
        }
    }
    else if (playerCharacterType == 4) {
        int cd1 = getRemainingCD(playerSkill1CDEnd), cd2 = getRemainingCD(playerSkill2CDEnd);
        cout << "技能: K-普攻 | J-";
        if (playerHashiramaEnemyTrapped && !playerHashiramaMyojinmonUsed) cout << "明神门(可用)";
        else cout << "木龙扦插之术";
        if (cd1 > 0) { setColor(8); cout << "(CD:" << cd1 << "s)"; }
        else { setColor(10); cout << "(就绪)"; }
        setColor(7); cout << " | I-木人之术";
        if (playerHashiramaWoodGolemActive) { cout << "(激活中"; if (playerHashiramaWoodGolemAttackCount < 2) cout << ",可按K攻击"; cout << ")"; }
        else if (cd2 > 0) { setColor(8); cout << "(CD:" << cd2 << "s)"; }
        else { setColor(10); cout << "(就绪)"; }
        setColor(7); if (enemy.hp <= 80 && getRemainingCD(playerSkill3CDEnd) <= 0) cout << " | O-千手观音(可用)"; else cout << " | O-千手观音(不可用)";
    }
    else if (playerCharacterType == 5) {
        int cd1 = getRemainingCD(playerSkill1CDEnd), cd2 = getRemainingCD(playerSkill2CDEnd);
        cout << "技能: K-普攻 | J-天照";
        if (cd1 > 0) { setColor(8); cout << "(CD:" << cd1 << "s)"; }
        else { setColor(10); cout << "(就绪)"; }
        setColor(7); cout << " | I-天手力";
        if (cd2 > 0) { setColor(8); cout << "(CD:" << cd2 << "s)"; }
        else { setColor(10); cout << "(就绪)"; }
        setColor(7); cout << " | U-须佐能乎";
        if (playerSasukeSusanooActive) cout << "(开启中)"; else { int scd = getRemainingCD(playerSasukeSubSkillCD); if (scd > 0) { setColor(8); cout << "(CD:" << scd << "s)"; } else { setColor(10); cout << "(可用)"; } }
        setColor(7); if (playerSasukeSusanooActive && enemy.hp <= 65) cout << " | O-地爆天星斩(可用)"; else cout << " | O-地爆天星斩(不可用)";
    }
    else if (playerCharacterType == 6) {
        int cd1 = getRemainingCD(playerSkill1CDEnd), cd2 = getRemainingCD(playerSkill2CDEnd);
        cout << "技能: K-普攻 | J-豪火球";
        if (cd1 > 0) { setColor(8); cout << "(CD:" << cd1 << "s)"; }
        else { setColor(10); cout << "(就绪)"; }
        setColor(7); cout << " | I-宇智波流剑术";
        auto nc = chrono::steady_clock::now();
        if (playerIzunaSword2ndWindow > nc && !playerIzunaSword2ndUsed) { setColor(10); cout << "(二段可用)"; }
        else if (cd2 > 0) { setColor(8); cout << "(CD:" << cd2 << "s)"; }
        else { setColor(10); cout << "(就绪)"; }
        setColor(7); cout << " | U-宇智波防反";
        int scd = getRemainingCD(playerSkill3CDEnd); if (scd > 0) { setColor(8); cout << "(CD:" << scd << "s)"; }
        else { setColor(10); cout << "(可用)"; }
        setColor(7); if (enemy.hp <= 70 && getRemainingCD(playerSkill3CDEnd) <= 0) cout << " | O-宇智波的荣耀(可用)"; else cout << " | O-宇智波的荣耀(不可用)";
    }
    gotoxy(MAP_START_X, MAP_START_Y + MAP_HEIGHT + 3); cout << "移动: A-左移 D-右移";
}

// ==================== 伤害辅助 ====================
int getShinraTenseiDamage(int stack) {
    int minDamage, maxDamage;
    switch (stack) {
    case 1: minDamage = 8; maxDamage = 12; break;
    case 2: minDamage = 9; maxDamage = 13; break;
    case 3: minDamage = 10; maxDamage = 14; break;
    case 4: minDamage = 11; maxDamage = 15; break;
    case 5: minDamage = 12; maxDamage = 15; break;
    default: minDamage = 8; maxDamage = 12; break;
    }
    return rand() % (maxDamage - minDamage + 1) + minDamage;
}

// ==================== 玩家技能函数 ====================
// ---------- 鸣人 ----------
void playerNarutoNormalAttack() {
    int d = abs(player.x - enemy.x);
    if (player.x < enemy.x && d >= 1 && d <= 3) {
        int dmg = increasePlayerDamage(rand() % 4 + 3);
        if (playerNarutoTailActive) {
            for (int i = 0; i < 3; i++) if (playerNarutoTailX[i] > 0 && playerNarutoTailX[i] < MAP_WIDTH && playerNarutoTailX[i] != enemy.x) { gotoxy(MAP_START_X + playerNarutoTailX[i], MAP_START_Y + CHARACTER_ROW); cout << " "; }
        }
        playerNarutoTailActive = true; playerNarutoTailEnd = chrono::steady_clock::now() + chrono::milliseconds(1500);
        for (int i = 0; i < 3; i++) { playerNarutoTailX[i] = player.x + 1 + i; if (playerNarutoTailX[i] >= enemy.x) { playerNarutoTailX[i] = 0; break; } }
        enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
        gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "玩家普攻造成 " << dmg << " 点伤害!     ";
    }
    else { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << (player.x >= enemy.x ? "无法向后攻击!" : "距离太远,无法攻击!"); }
}
void playerNarutoSkill1() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < playerSkill1CDEnd) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "螺旋丸冷却中..."; return; }
    skillInProgress = true; int t = enemy.x - 1; if (t < player.x + 1) t = player.x + 1;
    while (player.x < t) { player.x++; if (player.x >= enemy.x) { player.x = enemy.x - 1; break; } drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(50)); }
    int sx = player.x + 1; if (sx < enemy.x && sx != enemy.x && sx != player.x) { gotoxy(MAP_START_X + sx, MAP_START_Y + CHARACTER_ROW); setColor(14); cout << "O"; }
    this_thread::sleep_for(chrono::seconds(1)); if (sx < enemy.x && sx != enemy.x && sx != player.x) { gotoxy(MAP_START_X + sx, MAP_START_Y + CHARACTER_ROW); cout << " "; }
    int dmg = increasePlayerDamage(rand() % 8 + 8); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "螺旋丸造成 " << dmg << " 点伤害!"; playerSkill1CDEnd = now + chrono::seconds(8); skillInProgress = false;
}
void playerNarutoSkill2() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < playerSkill2CDEnd) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "九尾抓取冷却中..."; return; }
    skillInProgress = true; bool caught = false; int len = 20;
    for (int i = 0; i < len; i++) { int cx = player.x + 1 + i; if (cx >= MAP_WIDTH || cx >= enemy.x) break; if (cx != enemy.x && cx != player.x) { gotoxy(MAP_START_X + cx, MAP_START_Y + CHARACTER_ROW); setColor(14); cout << "-"; } if (cx == enemy.x - 1) { caught = true; break; } }
    if (caught && enemy.x - 1 != player.x && enemy.x - 1 != enemy.x) { gotoxy(MAP_START_X + (enemy.x - 1), MAP_START_Y + CHARACTER_ROW); setColor(14); cout << "O"; }
    this_thread::sleep_for(chrono::milliseconds(500)); for (int i = 0; i < len; i++) { int cx = player.x + 1 + i; if (cx >= MAP_WIDTH || cx >= enemy.x) break; if (cx != enemy.x && cx != player.x) { gotoxy(MAP_START_X + cx, MAP_START_Y + CHARACTER_ROW); cout << " "; } }
    if (caught) { int dmg = increasePlayerDamage(rand() % 6 + 20); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0; gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "九尾抓取造成 " << dmg << " 点伤害!"; playerSkill2CDEnd = now + chrono::seconds(15); }
    else { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "未抓取到敌人,CD减半"; playerSkill2CDEnd = now + chrono::seconds(7); }
    skillInProgress = false;
}
void playerNarutoUltimate() {
    if (skillInProgress || enemySkillInProgress) return;
    if (enemy.hp > 35) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "对方HP需<=35!"; return; }
    skillInProgress = true; gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "尾兽玉蓄力中...";
    int sx = player.x + 1, ex = enemy.x - 1, dist = ex - sx, steps = 30;
    for (int i = 0; i <= steps; i++) {
        int cx = sx + (dist * i / steps); if (cx >= enemy.x) cx = enemy.x - 1;
        if (i > 0) { int px = sx + (dist * (i - 1) / steps); if (px >= enemy.x) px = enemy.x - 1; if (px != enemy.x && px != player.x) { gotoxy(MAP_START_X + px, MAP_START_Y + CHARACTER_ROW); cout << " "; } }
        if (cx != enemy.x && cx != player.x) { gotoxy(MAP_START_X + cx, MAP_START_Y + CHARACTER_ROW); setColor(14); cout << "0"; }
        this_thread::sleep_for(chrono::milliseconds(100));
    }
    if (ex != enemy.x && ex != player.x) { gotoxy(MAP_START_X + ex, MAP_START_Y + CHARACTER_ROW); cout << " "; }
    enemy.hp -= increasePlayerDamage(35); if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "尾兽玉造成35点伤害!"; skillInProgress = false;
}

// ---------- 佩恩 ----------
void playerPainNormalAttack() {
    if (player.x >= enemy.x) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "无法向后攻击!"; return; }
    if (playerPainRodActive) { if (playerPainRodX > 0 && playerPainRodX < MAP_WIDTH && playerPainRodX != enemy.x && playerPainRodX != player.x) { gotoxy(MAP_START_X + playerPainRodX, MAP_START_Y + CHARACTER_ROW); cout << " "; } playerPainRodActive = false; playerRodHitting = false; }
    int rx = player.x + 3; if (rx >= enemy.x) rx = enemy.x - 1; if (rx <= player.x) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "敌人太近!"; return; }
    if (rx == enemy.x) rx = enemy.x - 1;
    playerPainRodActive = true; playerPainRodX = rx; playerPainRodEnd = chrono::steady_clock::now() + chrono::milliseconds(1500);
    int dmg = increasePlayerDamage(rand() % 3 + 4); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    if (rx == enemy.x - 1) { playerRodHitting = true; playerRodHitEnd = playerPainRodEnd; gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "黑棒命中!造成" << dmg << "点伤害!"; }
    else { playerRodHitting = false; gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "黑棒造成" << dmg << "点伤害!"; }
}
void playerPainSkill1() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < playerSkill1CDEnd) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "万象天引冷却中..."; return; }
    int tx = player.x + 2; if (tx >= MAP_WIDTH - 1) tx = MAP_WIDTH - 2;
    enemySkillInProgress = true;
    while (enemy.x > tx) { enemy.x--; if (enemy.x <= player.x) { enemy.x = player.x + 2; break; } drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(30)); }
    enemy.x = tx; playerBlackRodLeftX = enemy.x - 1; playerBlackRodRightX = enemy.x + 1;
    playerBanshoTeninActive = true; playerBanshoTeninEnd = now + chrono::seconds(5);
    int dmg = increasePlayerDamage(rand() % 4 + 10); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "万象天引造成" << dmg << "点伤害!";
    playerSkill1CDEnd = now + chrono::seconds(12); enemySkillInProgress = false;
}
void finishPlayerShinraTensei() {
    for (int r = 1; r <= playerShinraTenseiRadius; r++) {
        int lx = player.x - r, rx = player.x + r;
        if (lx > 0 && lx != enemy.x && lx != player.x) { gotoxy(MAP_START_X + lx, MAP_START_Y + CHARACTER_ROW); cout << " "; }
        if (rx < MAP_WIDTH && rx != enemy.x && rx != player.x) { gotoxy(MAP_START_X + rx, MAP_START_Y + CHARACTER_ROW); cout << " "; }
    }
    playerSkill2CDEnd = chrono::steady_clock::now() + chrono::seconds(playerShinraTenseiCurrentCD);
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "神罗天征结束,CD:" << playerShinraTenseiCurrentCD << "s";
    playerShinraTenseiActive = false; playerShinraTenseiStack = 0; playerShinraTenseiRadius = 1; skillInProgress = false;
}
void playerPainSkill2() {
    if (enemySkillInProgress) return;
    if (skillInProgress && !playerShinraTenseiActive) return;
    auto now = chrono::steady_clock::now();
    if (!playerShinraTenseiActive) {
        if (now < playerSkill2CDEnd) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "神罗天征冷却中..."; return; }
        playerShinraTenseiActive = true; playerShinraTenseiStack = 1; playerShinraTenseiRadius = 1;
        playerShinraTenseiStart = now; playerShinraTenseiCurrentCD = 15; skillInProgress = true;
        int dmg = increasePlayerDamage(getShinraTenseiDamage(1)); bool hit = (enemy.x >= player.x - 1 && enemy.x <= player.x + 1);
        if (hit) { enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0; }
        for (int r = 1; r <= 1; r++) { int lx = player.x - r, rx = player.x + r; if (lx > 0 && lx != enemy.x && lx != player.x) { gotoxy(MAP_START_X + lx, MAP_START_Y + CHARACTER_ROW); setColor(11); cout << "("; } if (rx < MAP_WIDTH && rx != enemy.x && rx != player.x) { gotoxy(MAP_START_X + rx, MAP_START_Y + CHARACTER_ROW); cout << ")"; } }
        gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << (hit ? "神罗天征造成" + to_string(dmg) + "点伤害!" : "神罗天征激活!再次按I叠加");
        this_thread::sleep_for(chrono::milliseconds(500));
    }
    else {
        auto el = chrono::duration_cast<chrono::seconds>(now - playerShinraTenseiStart).count();
        if (el >= 3) { finishPlayerShinraTensei(); return; }
        if (playerShinraTenseiStack < 5) {
            playerShinraTenseiStack++; playerShinraTenseiRadius++; playerShinraTenseiCurrentCD += 2;
            int dmg = increasePlayerDamage(getShinraTenseiDamage(playerShinraTenseiStack));
            int lb = player.x - playerShinraTenseiRadius, rb = player.x + playerShinraTenseiRadius;
            bool hit = (enemy.x >= lb && enemy.x <= rb); if (hit) { enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0; }
            for (int r = 1; r < playerShinraTenseiRadius; r++) { int lx = player.x - r, rx = player.x + r; if (lx > 0 && lx != enemy.x && lx != player.x) { gotoxy(MAP_START_X + lx, MAP_START_Y + CHARACTER_ROW); cout << " "; } if (rx < MAP_WIDTH && rx != enemy.x && rx != player.x) { gotoxy(MAP_START_X + rx, MAP_START_Y + CHARACTER_ROW); cout << " "; } }
            for (int r = 1; r <= playerShinraTenseiRadius; r++) { int lx = player.x - r, rx = player.x + r; if (lx > 0 && lx != enemy.x && lx != player.x) { gotoxy(MAP_START_X + lx, MAP_START_Y + CHARACTER_ROW); setColor(11); cout << "("; } if (rx < MAP_WIDTH && rx != enemy.x && rx != player.x) { gotoxy(MAP_START_X + rx, MAP_START_Y + CHARACTER_ROW); cout << ")"; } }
            gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << (hit ? "神罗天征第" + to_string(playerShinraTenseiStack) + "层造成" + to_string(dmg) + "点伤害!" : "扩大到第" + to_string(playerShinraTenseiStack) + "层");
        }
        this_thread::sleep_for(chrono::milliseconds(500));
    }
    auto cn = chrono::steady_clock::now(); auto el = chrono::duration_cast<chrono::seconds>(cn - playerShinraTenseiStart).count();
    if (el >= 3 || playerShinraTenseiStack >= 5) { this_thread::sleep_for(chrono::milliseconds(500)); finishPlayerShinraTensei(); }
}
void playerPainUltimate() {
    if (skillInProgress || enemySkillInProgress) return;
    if (enemy.hp > 50) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "对方HP需<=50!"; return; }
    skillInProgress = true; int tx = MAP_WIDTH / 2;
    while (player.x != tx) { if (player.x < tx) player.x++; else player.x--; drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(20)); }
    for (int s = 1; s <= 5; s++) {
        for (int r = 1; r <= s; r++) { int lx = player.x - r, rx = player.x + r; if (lx > 1 && lx != enemy.x && lx != player.x) { gotoxy(MAP_START_X + lx, MAP_START_Y + CHARACTER_ROW); setColor(13); cout << "{"; } if (rx < MAP_WIDTH && rx != enemy.x && rx != player.x) { gotoxy(MAP_START_X + rx, MAP_START_Y + CHARACTER_ROW); cout << "}"; } }
        enemy.hp -= increasePlayerDamage(10); if (enemy.hp < 0) enemy.hp = 0;
        gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "超神罗天征第" << s << "秒造成10点伤害!"; this_thread::sleep_for(chrono::seconds(1)); if (enemy.hp <= 0) break;
    }
    for (int r = 1; r <= 5; r++) { int lx = player.x - r, rx = player.x + r; if (lx > 1 && lx != enemy.x && lx != player.x) { gotoxy(MAP_START_X + lx, MAP_START_Y + CHARACTER_ROW); cout << " "; } if (rx < MAP_WIDTH && rx != enemy.x && rx != player.x) { gotoxy(MAP_START_X + rx, MAP_START_Y + CHARACTER_ROW); cout << " "; } }
    playerSkill1CDEnd = chrono::steady_clock::now(); gotoxy(2, MAP_START_Y + MAP_HEIGHT + 5); cout << "万象天引CD已重置!"; skillInProgress = false;
}

// ---------- 带土 ----------
void playerObitoNormalAttack() {
    if (player.x >= enemy.x) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "无法向后攻击!"; return; }
    int d = abs(player.x - enemy.x); if (d < 1 || d > 2) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "距离不合适!"; return; }
    int kx = player.x + 1; if (kx >= enemy.x) kx = enemy.x - 1; if (kx <= player.x) return;
    playerObitoKickActive = true; playerObitoKickX = kx; playerObitoKickEnd = chrono::steady_clock::now() + chrono::milliseconds(1000);
    int dmg = increasePlayerDamage(rand() % 3 + 6); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "踢腿造成" << dmg << "点伤害!";
}
void playerObitoSkill1() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now();
    if (playerObitoEnemyTrapped && !playerObitoFireActive) {
        int sx = player.x, tx = enemy.x - 3; if (tx < 2) tx = 2;
        skillInProgress = true; playerObitoFireActive = true; player.x = tx; drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(300));
        int fx = player.x + 1; for (int i = 0; i < 8; i++) { int px = fx + i; if (px < MAP_WIDTH && px != enemy.x && px != player.x) { gotoxy(MAP_START_X + px, MAP_START_Y + CHARACTER_ROW); setColor(6); cout << "~"; } }
        int dmg = increasePlayerDamage(rand() % 5 + 14); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
        gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "火遁-火龙卷造成" << dmg << "点伤害!";
        this_thread::sleep_for(chrono::seconds(2)); for (int i = 0; i < 8; i++) { int px = fx + i; if (px < MAP_WIDTH && px != enemy.x && px != player.x) { gotoxy(MAP_START_X + px, MAP_START_Y + CHARACTER_ROW); cout << " "; } }
        player.x = sx; playerObitoFireActive = false; skillInProgress = false; return;
    }
    if (now < playerSkill1CDEnd) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "木遁-扦插冷却中..."; return; }
    skillInProgress = true; playerObitoWoodSpikeX = player.x + 1; playerObitoWoodSpikeActive = true; playerObitoWoodSpikeEnd = now + chrono::milliseconds(500);
    bool hit = false;
    for (int i = 0; i < 30; i++) {
        int cx = player.x + 1 + i; if (cx >= MAP_WIDTH || cx >= enemy.x) break; if (cx != enemy.x && cx != player.x) { gotoxy(MAP_START_X + cx, MAP_START_Y + CHARACTER_ROW); setColor(2); cout << "-"; }
        if (cx == enemy.x - 1) { hit = true; break; } this_thread::sleep_for(chrono::milliseconds(20));
    }
    if (hit) { playerObitoEnemyTrapped = true; playerObitoEnemyTrappedEnd = now + chrono::seconds(15); int dmg = increasePlayerDamage(rand() % 5 + 12); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0; gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "木遁-扦插命中!"; }
    else { playerObitoWoodSpikeActive = false; gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "未命中!"; }
    for (int i = 0; i < 30; i++) { int cx = player.x + 1 + i; if (cx >= MAP_WIDTH || cx >= enemy.x) break; if (cx != enemy.x && cx != player.x) { gotoxy(MAP_START_X + cx, MAP_START_Y + CHARACTER_ROW); cout << " "; } }
    playerSkill1CDEnd = now + chrono::seconds(hit ? 20 : 10); skillInProgress = false;
}
void playerObitoSkill2() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now();
    if (playerObitoKamuiActive && !playerObitoKamuiSpaceActive) {
        playerObitoKamuiActive = false; playerObitoKamuiSpaceActive = true; playerObitoSavedX = player.x;
        int tx = enemy.x - 1; if (tx < 1) tx = 1; player.x = tx; playerObitoEnemyInSpace = true; playerObitoKamuiSpaceEnd = now + chrono::seconds(3);
        gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "神威-空间!"; drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(500));
        for (int s = 0; s < 3; s++) { int dmg = increasePlayerDamage(rand() % 3 + 8); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0; this_thread::sleep_for(chrono::seconds(1)); if (enemy.hp <= 0) break; }
        playerObitoEnemyInSpace = false; playerObitoKamuiSpaceActive = false; enemy.x = player.x + 3; if (enemy.x >= MAP_WIDTH - 2) enemy.x = MAP_WIDTH - 3;
        gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "敌人被吐出!"; playerSkill2CDEnd = now + chrono::seconds(10); return;
    }
    if (playerObitoEnemyTrapped && !playerObitoWoodStormActive) {
        skillInProgress = true; playerObitoWoodStormActive = true; int sx = player.x, tx = enemy.x - 5; if (tx < 2) tx = 2; player.x = tx;
        drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(300));
        for (int i = 0; i < 20; i++) { int bx = player.x + 1 + i; if (bx >= MAP_WIDTH || bx >= enemy.x) break; if (bx != enemy.x && bx != player.x) { gotoxy(MAP_START_X + bx, MAP_START_Y + CHARACTER_ROW - 1); setColor(2); cout << "_"; gotoxy(MAP_START_X + bx, MAP_START_Y + CHARACTER_ROW); setColor(2); cout << "-"; } }
        for (int s = 0; s < 6; s++) { if (abs(player.x - enemy.x) <= 20) { enemy.hp -= increasePlayerDamage(8); if (enemy.hp < 0) enemy.hp = 0; } this_thread::sleep_for(chrono::seconds(1)); if (enemy.hp <= 0) break; }
        for (int i = 0; i < 20; i++) { int bx = player.x + 1 + i; if (bx >= MAP_WIDTH) break; if (bx != enemy.x && bx != player.x) { gotoxy(MAP_START_X + bx, MAP_START_Y + CHARACTER_ROW - 1); cout << " "; gotoxy(MAP_START_X + bx, MAP_START_Y + CHARACTER_ROW); cout << " "; } }
        player.x = sx; playerObitoWoodStormActive = false; skillInProgress = false; return;
    }
    if (now < playerSkill2CDEnd) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "神威冷却中..."; return; }
    playerObitoKamuiActive = true; playerObitoKamuiEnd = now + chrono::seconds(5); gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "神威激活!按I进入空间";
}
void playerObitoUltimate() {
    if (skillInProgress || enemySkillInProgress) return;
    if (enemy.hp > 50) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "对方HP需<=50!"; return; }
    skillInProgress = true; playerObitoUltimateActive = true; int cy = MAP_START_Y + CHARACTER_ROW, tby = cy - 5;
    for (int r = 0; r < 5; r++) for (int c = 0; c < 10; c++) { int x = player.x - 5 + c, y = tby - r; if (x > 0 && x < MAP_WIDTH && y > 0) { gotoxy(MAP_START_X + x, MAP_START_Y + y); setColor(8); cout << "*"; } }
    gotoxy(MAP_START_X + player.x, MAP_START_Y + tby - 5); setColor(10); cout << "@"; this_thread::sleep_for(chrono::seconds(2));
    int bx = player.x;
    for (int s = 0; s < 25; s++) {
        int by = tby - 5 + s; if (by >= cy) break; if (s > 0) { int py = tby - 5 + s - 1; if (py < cy && py > 0) { gotoxy(MAP_START_X + bx, MAP_START_Y + py); cout << " "; } }
        if (by > 0 && bx != enemy.x) { gotoxy(MAP_START_X + bx, MAP_START_Y + by); setColor(7); cout << "O"; } this_thread::sleep_for(chrono::milliseconds(150));
    }
    gotoxy(MAP_START_X + bx, MAP_START_Y + cy - 1); cout << " ";
    for (int r = 0; r < 5; r++) for (int c = 0; c < 10; c++) { int x = player.x - 5 + c, y = tby - r; if (x > 0 && x < MAP_WIDTH && y > 0) { gotoxy(MAP_START_X + x, MAP_START_Y + y); cout << " "; } }
    gotoxy(MAP_START_X + player.x, MAP_START_Y + tby - 5); cout << " ";
    enemy.hp -= increasePlayerDamage(50); if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "十尾入侵造成50点伤害!"; playerObitoUltimateActive = false; skillInProgress = false;
}

// ---------- 博人 ----------
void playerBorutoNormalAttack() {
    if (player.x >= enemy.x) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "无法向后攻击!"; return; }
    int d = abs(player.x - enemy.x); if (d < 1 || d > 4) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "距离不合适!"; return; }
    if (playerObitoKamuiActive && !playerObitoKamuiSpaceActive) return;
    playerBorutoSwordActive = true; playerBorutoSwordSlashing = true; playerBorutoSwordEnd = chrono::steady_clock::now() + chrono::milliseconds(2000); playerBorutoSwordX = player.x + 1;
    int d1 = increasePlayerDamage(rand() % 3 + 7); enemy.hp -= d1; if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "第一刀造成" << d1 << "点伤害!"; this_thread::sleep_for(chrono::milliseconds(400));
    if (playerRodHitting || playerBanshoTeninActive || playerObitoEnemyTrapped || playerHashiramaEnemyTrapped || playerSasukeAmaterasuHit || playerIzunaCounterActive) { playerBorutoSwordActive = false; playerBorutoSwordSlashing = false; return; }
    int d2 = increasePlayerDamage(rand() % 4 + 7); enemy.hp -= d2; if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "第二刀造成" << d2 << "点伤害!"; this_thread::sleep_for(chrono::milliseconds(400));
    if (playerRodHitting || playerBanshoTeninActive || playerObitoEnemyTrapped || playerHashiramaEnemyTrapped || playerSasukeAmaterasuHit || playerIzunaCounterActive) { playerBorutoSwordActive = false; playerBorutoSwordSlashing = false; return; }
    int d3 = increasePlayerDamage(rand() % 5 + 8); enemy.hp -= d3; if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "第三刀造成" << d3 << "点伤害!"; playerBorutoSwordActive = false; playerBorutoSwordSlashing = false;
}
void playerBorutoEnhancedAttack() {
    if (!playerBorutoFlying) return; if (playerBorutoEnhancedAttackCount >= 3) return;
    auto now = chrono::steady_clock::now(); if (now < playerBorutoEnhancedAttackCD) return;
    playerBorutoEnhancedAttackCount++; playerBorutoEnhancedAttackCD = now + chrono::milliseconds(2500);
    int sx = player.x + 1, ex = enemy.x, steps = 25, lx = 0;
    for (int i = 0; i <= steps; i++) {
        int cx = sx + ((ex - sx) * i / steps); if (cx >= enemy.x) break;
        if (i > 0) { int px = sx + ((ex - sx) * (i - 1) / steps); if (px != enemy.x && px != player.x) { gotoxy(MAP_START_X + px, MAP_START_Y + CHARACTER_ROW); cout << " "; } }
        if (cx != enemy.x && cx != player.x) { gotoxy(MAP_START_X + cx, MAP_START_Y + CHARACTER_ROW); setColor(11); cout << "O"; } lx = cx;
        this_thread::sleep_for(chrono::milliseconds(100));
    }
    int dmg = increasePlayerDamage(rand() % 7 + 8); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "强化螺旋丸造成" << dmg << "点伤害!"; if (lx != enemy.x && lx != player.x) { gotoxy(MAP_START_X + lx, MAP_START_Y + CHARACTER_ROW); cout << " "; }
}
void playerBorutoSkill1() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now();
    if (playerBorutoKarmaActive) { if (playerBorutoFlying) return; if (now < playerSkill1CDEnd) return; playerBorutoFlying = true; playerBorutoFlyingEnd = now + chrono::seconds(10); playerBorutoEnhancedAttackCount = 0; playerSkill1CDEnd = now + chrono::seconds(6); gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "大筒木-飞行!"; return; }
    if (now < playerSkill1CDEnd) return;
    skillInProgress = true; int tx = enemy.x - 3; if (tx < 2) tx = 2;
    while (player.x > tx) { player.x--; drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(30)); }
    while (player.x < tx) { player.x++; drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(30)); }
    playerBorutoRasenganActive = true; playerBorutoRasenganEnd = now + chrono::seconds(3); playerBorutoRasenganHit = true;
    for (int s = 0; s < 3; s++) { int dmg = increasePlayerDamage(rand() % 5 + 8); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0; gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "螺旋丸涡彦第" << s + 1 << "秒造成" << dmg << "点伤害!"; this_thread::sleep_for(chrono::seconds(1)); if (enemy.hp <= 0) break; }
    playerBorutoRasenganActive = false; tx = enemy.x - 8; if (tx < 1) tx = 1; player.x = tx;
    playerBorutoMarkActive = true; playerBorutoMarkX = enemy.x; playerBorutoMarkEnd = now + chrono::seconds(10);
    playerBorutoTeleported = false; playerBorutoTeleportBack = false; playerSkill1CDEnd = now + chrono::seconds(18); skillInProgress = false;
}
void playerBorutoSkill2() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now();
    if (playerBorutoKarmaActive) { if (playerBorutoFlying) return; if (now < playerSkill2CDEnd) return; skillInProgress = true; int bx = player.x + 1; for (int s = 0; s < 20; s++) { int cx = bx + s; if (cx >= enemy.x) break; if (s > 0) { gotoxy(MAP_START_X + cx - 1, MAP_START_Y + CHARACTER_ROW); cout << " "; } if (cx != enemy.x && cx != player.x) { gotoxy(MAP_START_X + cx, MAP_START_Y + CHARACTER_ROW); setColor(11); cout << "O"; } this_thread::sleep_for(chrono::milliseconds(50)); } int dmg = increasePlayerDamage(rand() % 6 + 15); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0; playerBorutoBigRasenganHit = true; playerBorutoBigRasenganDotEnd = now + chrono::seconds(5); gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "超大玉螺旋丸造成" << dmg << "点伤害!"; gotoxy(MAP_START_X + enemy.x - 1, MAP_START_Y + CHARACTER_ROW); cout << " "; playerSkill2CDEnd = now + chrono::seconds(15); skillInProgress = false; return; }
    if (playerBorutoMarkActive && !playerBorutoTeleported) { playerBorutoTeleportSavedX = player.x; player.x = enemy.x - 3; if (player.x < 1) player.x = 1; playerBorutoTeleported = true; playerBorutoTeleportTime = now; int dmg = increasePlayerDamage(rand() % 9 + 10); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0; gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "飞雷神·草薙剑造成" << dmg << "点伤害!"; playerBorutoTeleportBack = true; return; }
    if (playerBorutoTeleported && playerBorutoTeleportBack) { auto ts = chrono::duration_cast<chrono::seconds>(now - playerBorutoTeleportTime).count(); if (ts <= 5) { player.x = playerBorutoTeleportSavedX; playerBorutoTeleported = false; playerBorutoTeleportBack = false; playerSkill2CDEnd = now + chrono::seconds(8); gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "飞雷神返回!"; return; } else { playerBorutoTeleportBack = false; } }
    if (now < playerSkill2CDEnd) return;
}
void playerBorutoUltimate() {
    if (skillInProgress || enemySkillInProgress) return; if (playerBorutoKarmaActive) return;
    auto now = chrono::steady_clock::now(); if (now < playerSkill3CDEnd) return;
    skillInProgress = true; playerBorutoKarmaActive = true; playerBorutoKarmaEnd = now + chrono::seconds(60); playerSkill3CDEnd = now + chrono::seconds(45);
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "楔激活!"; skillInProgress = false;
}

// ---------- 柱间 ----------
void playerHashiramaNormalAttack() {
    if (player.x >= enemy.x) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "无法向后攻击!"; return; }
    int d = abs(player.x - enemy.x); if (d < 1 || d > 5) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "距离不合适!"; return; }
    playerHashiramaStompActive = true; playerHashiramaStompX = player.x + 1; playerHashiramaStompEnd = chrono::steady_clock::now() + chrono::milliseconds(800);
    int dmg = increasePlayerDamage(rand() % 3 + 8); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "跺脚造成" << dmg << "点伤害!";
}
void playerHashiramaWoodGolemAttack() {
    if (!playerHashiramaWoodGolemActive) return; if (playerHashiramaWoodGolemAttackCount >= 2) return;
    auto now = chrono::steady_clock::now(); if (now < playerHashiramaWoodGolemAttackCD) return;
    playerHashiramaWoodGolemAttackCount++; playerHashiramaWoodGolemAttackCD = now + chrono::milliseconds(2000);
    int sx = player.x + 1; for (int i = 0; i < 15; i++) { int dx = sx + i; if (dx >= MAP_WIDTH || dx >= enemy.x) break; if (dx != enemy.x && dx != player.x) { gotoxy(MAP_START_X + dx, MAP_START_Y + CHARACTER_ROW); setColor(2); cout << "~"; } this_thread::sleep_for(chrono::milliseconds(30)); }
    int dmg = increasePlayerDamage(rand() % 14 + 22); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "化龙造成" << dmg << "点伤害!"; for (int i = 0; i < 15; i++) { int dx = sx + i; if (dx >= MAP_WIDTH || dx >= enemy.x) break; if (dx != enemy.x && dx != player.x) { gotoxy(MAP_START_X + dx, MAP_START_Y + CHARACTER_ROW); cout << " "; } }
}
void playerHashiramaSkill1() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now();
    if (playerHashiramaEnemyTrapped && !playerHashiramaMyojinmonUsed) { skillInProgress = true; playerHashiramaMyojinmonActive = true; playerHashiramaMyojinmonUsed = true; int dmg = increasePlayerDamage(rand() % 16 + 20); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0; gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "明神门造成" << dmg << "点伤害!"; this_thread::sleep_for(chrono::seconds(2)); playerHashiramaMyojinmonActive = false; playerHashiramaEnemyTrapped = false; playerHashiramaWoodDragonActive = false; skillInProgress = false; return; }
    if (now < playerSkill1CDEnd) return;
    skillInProgress = true; playerHashiramaWoodDragonActive = true; playerHashiramaWoodDragonEnd = now + chrono::milliseconds(1000);
    int sx = player.x + 1; bool hit = false;
    for (int i = 0; i < 20; i++) { int dx = sx + i; if (dx >= MAP_WIDTH || dx >= enemy.x) break; if (dx != enemy.x && dx != player.x) { gotoxy(MAP_START_X + dx, MAP_START_Y + CHARACTER_ROW); setColor(2); cout << "~"; } if (dx == enemy.x - 1) { hit = true; break; } this_thread::sleep_for(chrono::milliseconds(30)); }
    if (hit) { playerHashiramaEnemyTrapped = true; playerHashiramaWoodDragonTrapEnd = now + chrono::seconds(8); playerHashiramaMyojinmonUsed = false; int dmg = increasePlayerDamage(rand() % 6 + 15); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0; gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "木龙扦插命中!"; }
    else { playerHashiramaWoodDragonActive = false; gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "未命中!"; }
    playerSkill1CDEnd = now + chrono::seconds(15); skillInProgress = false;
}
void playerHashiramaSkill2() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < playerSkill2CDEnd) return; if (playerHashiramaWoodGolemActive) return;
    skillInProgress = true; playerHashiramaWoodGolemActive = true; playerHashiramaWoodGolemEnd = now + chrono::seconds(5);
    playerHashiramaWoodGolemAttackCount = 0; playerHashiramaWoodGolemAttackCD = now; playerSkill2CDEnd = now + chrono::seconds(18);
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "木人之术!"; skillInProgress = false;
}
void playerHashiramaUltimate() {
    if (skillInProgress || enemySkillInProgress) return; if (enemy.hp > 80) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "对方HP需<=80!"; return; }
    skillInProgress = true; int tx = 15; while (player.x > tx) { player.x--; drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(20)); }
    int cy = MAP_START_Y + CHARACTER_ROW; for (int r = 0; r < 3; r++) for (int c = 0; c < 4; c++) { int gx = player.x - 1 + c, gy = cy - 3 - r; if (gx > 0 && gx < MAP_WIDTH && gy > 0) { gotoxy(MAP_START_X + gx, MAP_START_Y + gy); setColor(6); cout << "¥"; } }
    for (int i = 0; i < 10; i++) { int ax = player.x + 4 + i; if (ax < MAP_WIDTH && ax != enemy.x) { gotoxy(MAP_START_X + ax, cy); setColor(6); cout << "\\"; } this_thread::sleep_for(chrono::milliseconds(100)); }
    enemy.hp -= increasePlayerDamage(80); if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "千手观音造成80点伤害!"; this_thread::sleep_for(chrono::seconds(2));
    for (int i = 0; i < 10; i++) { int ax = player.x + 4 + i; if (ax < MAP_WIDTH) { gotoxy(MAP_START_X + ax, cy); cout << " "; } }
    for (int r = 0; r < 3; r++) for (int c = 0; c < 4; c++) { int gx = player.x - 1 + c, gy = cy - 3 - r; if (gx > 0 && gx < MAP_WIDTH && gy > 0) { gotoxy(MAP_START_X + gx, MAP_START_Y + gy); cout << " "; } }
    skillInProgress = false;
}

// ---------- 佐助 ----------
void playerSasukeNormalAttack() {
    if (player.x >= enemy.x) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "无法向后攻击!"; return; }
    int d = abs(player.x - enemy.x); if (d < 1 || d > 10) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "距离不合适!"; return; }
    auto now = chrono::steady_clock::now(); if (now < playerSasukeSlashCD) return;
    if (playerSasukeSusanooActive && playerSasukeSusanooSlashCount < 3) {
        playerSasukeSusanooSlashActive = true; playerSasukeSusanooSlashEnd = now + chrono::milliseconds(1500); playerSasukeSusanooSlashCount++;
        int sx = player.x + 3; for (int i = 0; i <= d; i++) { int cx = sx + i; if (cx >= enemy.x) break; if (i > 0) { int px = sx + (i - 1); for (int r = 0; r < 8; r++) { int sy = MAP_START_Y + CHARACTER_ROW - 2 - r; if (sy > 0) { gotoxy(MAP_START_X + px, MAP_START_Y + sy); cout << " "; } } } for (int r = 0; r < 8; r++) { int sy = MAP_START_Y + CHARACTER_ROW - 2 - r; if (sy > 0 && cx != enemy.x && cx != player.x) { gotoxy(MAP_START_X + cx, MAP_START_Y + sy); setColor(13); cout << "}"; } } this_thread::sleep_for(chrono::milliseconds(80)); }
        int lx = sx + d; if (lx >= enemy.x) lx = enemy.x - 1; for (int r = 0; r < 8; r++) { int sy = MAP_START_Y + CHARACTER_ROW - 2 - r; if (sy > 0) { gotoxy(MAP_START_X + lx, MAP_START_Y + sy); cout << " "; } }
        int dmg = increasePlayerDamage(rand() % 6 + 25); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
        gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "须佐能乎斩造成" << dmg << "点伤害!"; if (playerSasukeSusanooSlashCount >= 3) { playerSasukeSusanooActive = false; playerSasukeSusanooSlashCount = 0; } return;
    }
    playerSasukeSlashActive = true; playerSasukeSlashEnd = now + chrono::milliseconds(500); playerSasukeSlashCD = now + chrono::milliseconds(1500);
    int sx = player.x + 1; for (int i = 0; i <= d; i++) { int cx = sx + i; if (cx >= enemy.x) break; if (i > 0) { int px = sx + (i - 1); if (px != enemy.x && px != player.x) { gotoxy(MAP_START_X + px, MAP_START_Y + CHARACTER_ROW); cout << " "; } } if (cx != enemy.x && cx != player.x) { gotoxy(MAP_START_X + cx, MAP_START_Y + CHARACTER_ROW); setColor(13); cout << ")"; } this_thread::sleep_for(chrono::milliseconds(30)); }
    int lx = sx + d; if (lx >= enemy.x) lx = enemy.x - 1; if (lx != enemy.x && lx != player.x) { gotoxy(MAP_START_X + lx, MAP_START_Y + CHARACTER_ROW); cout << " "; }
    int dmg = increasePlayerDamage(rand() % 3 + 8); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "剑气造成" << dmg << "点伤害!";
}
void playerSasukeSkill1() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < playerSkill1CDEnd) return; int d = abs(player.x - enemy.x); if (d > 8) return;
    skillInProgress = true; playerSasukeAmaterasuActive = true; playerSasukeAmaterasuEnd = now + chrono::seconds(5);
    playerSasukeAmaterasuTick = now + chrono::milliseconds(500); playerSasukeAmaterasuHit = true; playerSkill1CDEnd = now + chrono::seconds(10);
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "天照!";
}
void playerSasukeSkill2() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < playerSkill2CDEnd) return;
    skillInProgress = true; int tx = enemy.x - 5; if (tx < 1) tx = 1; player.x = tx;
    int dmg = increasePlayerDamage(rand() % 7 + 12); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "天手力造成" << dmg << "点伤害!"; playerSkill2CDEnd = now + chrono::seconds(8); skillInProgress = false;
}
void playerSasukeSubSkill() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < playerSasukeSubSkillCD) return;
    if (playerSasukeSusanooActive) { playerSasukeSusanooActive = false; playerSasukeSusanooSlashCount = 0; gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "须佐能乎关闭!"; return; }
    playerSasukeSusanooActive = true; playerSasukeSusanooEnd = now + chrono::seconds(45); playerSasukeSusanooSlashCount = 0; playerSasukeSubSkillCD = now + chrono::seconds(15);
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "完全体须佐能乎!";
}
void playerSasukeUltimate() {
    if (skillInProgress || enemySkillInProgress) return; if (!playerSasukeSusanooActive) return; if (enemy.hp > 65) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "对方HP需<=65!"; return; }
    skillInProgress = true; int tx = 5; while (player.x > tx) { player.x--; drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(20)); }
    int d1 = increasePlayerDamage(rand() % 16 + 20); enemy.hp -= d1; if (enemy.hp < 0) enemy.hp = 0;
    int cy = MAP_START_Y + CHARACTER_ROW; for (int r = 0; r < 5; r++) for (int c = 0; c < 5; c++) { int bx = enemy.x - 2 + c, by = cy - 4 - r; if (bx > 0 && bx < MAP_WIDTH && by > 0) { gotoxy(MAP_START_X + bx, MAP_START_Y + by); setColor(8); cout << "*"; } } this_thread::sleep_for(chrono::seconds(1));
    for (int r = 0; r < 8; r++) { int sx = player.x + 3, sy = cy - 2 - r; if (sx > 0 && sx < MAP_WIDTH && sy > 0) { gotoxy(MAP_START_X + sx, MAP_START_Y + sy); setColor(13); cout << "}"; } }
    enemy.hp -= increasePlayerDamage(45); if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "地爆天星斩造成" << d1 + 45 << "点伤害!"; this_thread::sleep_for(chrono::seconds(2));
    for (int r = 0; r < 5; r++) for (int c = 0; c < 5; c++) { int bx = enemy.x - 2 + c, by = cy - 4 - r; if (bx > 0 && bx < MAP_WIDTH && by > 0) { gotoxy(MAP_START_X + bx, MAP_START_Y + by); cout << " "; } }
    for (int r = 0; r < 8; r++) { int sx = player.x + 3, sy = cy - 2 - r; if (sx > 0 && sx < MAP_WIDTH && sy > 0) { gotoxy(MAP_START_X + sx, MAP_START_Y + sy); cout << " "; } }
    playerSasukeSusanooActive = false; playerSasukeSusanooSlashCount = 0; skillInProgress = false;
}

// ---------- 泉奈 ----------
void playerIzunaNormalAttack() {
    if (player.x >= enemy.x) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "无法向后攻击!"; return; }
    auto now = chrono::steady_clock::now(); if (now < playerIzunaSlashCD) return;
    playerIzunaSlashActive = true; playerIzunaSlashEnd = now + chrono::milliseconds(2000); playerIzunaSlashCD = now + chrono::milliseconds(1500);
    int sx = player.x + 1, d = abs(player.x - enemy.x); for (int i = 0; i <= d; i++) { int cx = sx + i; if (cx >= enemy.x) break; if (i > 0) { int px = sx + (i - 1); if (px != enemy.x && px != player.x) { gotoxy(MAP_START_X + px, MAP_START_Y + CHARACTER_ROW); cout << " "; } } if (cx != enemy.x && cx != player.x) { gotoxy(MAP_START_X + cx, MAP_START_Y + CHARACTER_ROW); setColor(9); cout << ")"; } this_thread::sleep_for(chrono::milliseconds(30)); }
    int lx = sx + d; if (lx >= enemy.x) lx = enemy.x - 1; if (lx != enemy.x && lx != player.x) { gotoxy(MAP_START_X + lx, MAP_START_Y + CHARACTER_ROW); cout << " "; }
    int dmg = increasePlayerDamage(rand() % 3 + 8); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "剑气造成" << dmg << "点伤害!";
}
void playerIzunaSkill1() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < playerSkill1CDEnd) return; int d = abs(player.x - enemy.x); if (d > 8) return;
    skillInProgress = true; playerIzunaFireballActive = true; playerIzunaFireballEnd = now + chrono::milliseconds(1500);
    for (int i = 0; i < 8; i++) { int fx = player.x + 1 + i; if (fx < MAP_WIDTH && fx != enemy.x && fx != player.x) { gotoxy(MAP_START_X + fx, MAP_START_Y + CHARACTER_ROW); setColor(12); cout << "-"; } this_thread::sleep_for(chrono::milliseconds(30)); }
    if (player.x + 7 < MAP_WIDTH) { gotoxy(MAP_START_X + player.x + 7, MAP_START_Y + CHARACTER_ROW); setColor(14); cout << "*"; }
    int dmg = increasePlayerDamage(rand() % 4 + 18); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "火遁-豪火球造成" << dmg << "点伤害!";
    this_thread::sleep_for(chrono::milliseconds(500)); for (int i = 0; i < 8; i++) { int fx = player.x + 1 + i; if (fx < MAP_WIDTH && fx != enemy.x && fx != player.x) { gotoxy(MAP_START_X + fx, MAP_START_Y + CHARACTER_ROW); cout << " "; } }
    playerIzunaFireballActive = false; playerSkill1CDEnd = now + chrono::seconds(18); skillInProgress = false;
}
void playerIzunaSubSkill() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < playerSkill3CDEnd) return; if (playerIzunaCounterActive) return;
    playerIzunaCounterActive = true; playerIzunaCounterEnd = now + chrono::seconds(5); playerIzunaCounterTriggered = false;
    if (player.x > 2) player.x--; gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "宇智波防反!";
}
void playerIzunaSkill2() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now(); int cy = MAP_START_Y + CHARACTER_ROW;
    if (playerIzunaSword2ndWindow > now && !playerIzunaSword2ndUsed) {
        playerIzunaSword2ndUsed = true; skillInProgress = true;
        for (int r = 0; r < 2; r++) { int sx = player.x + 1, d = abs(player.x - enemy.x), y = cy - 1 + r; for (int i = 0; i <= d; i++) { int cx = sx + i; if (cx >= enemy.x) break; if (i > 0) { int px = sx + (i - 1); if (px != enemy.x && px != player.x) { gotoxy(MAP_START_X + px, MAP_START_Y + y); cout << " "; } } if (cx != enemy.x && cx != player.x) { gotoxy(MAP_START_X + cx, MAP_START_Y + y); setColor(9); cout << ")"; } this_thread::sleep_for(chrono::milliseconds(30)); } int lx = sx + d; if (lx >= enemy.x) lx = enemy.x - 1; if (lx != enemy.x && lx != player.x) { gotoxy(MAP_START_X + lx, MAP_START_Y + y); cout << " "; } }
        int dmg = increasePlayerDamage(rand() % 4 + 15); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
        gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "二段剑气造成" << dmg << "点伤害!"; playerSkill2CDEnd = now + chrono::seconds(20); skillInProgress = false; return;
    }
    if (now < playerSkill2CDEnd) return;
    skillInProgress = true; playerIzunaSwordActive = true; playerIzunaSwordEnd = now + chrono::milliseconds(1000);
    for (int i = 0; i < 3; i++) { int sx = player.x + 1 + i; if (sx < MAP_WIDTH && sx != enemy.x && sx != player.x) { gotoxy(MAP_START_X + sx, cy); setColor(9); cout << "-"; } }
    int dmg = increasePlayerDamage(rand() % 5 + 20); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "宇智波流剑术造成" << dmg << "点伤害!";
    playerIzunaSword2ndWindow = now + chrono::seconds(3); playerIzunaSword2ndUsed = false; skillInProgress = false;
}
void playerIzunaUltimate() {
    if (skillInProgress || enemySkillInProgress) return; if (enemy.hp > 70) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "对方HP需<=70!"; return; }
    skillInProgress = true; int cy = MAP_START_Y + CHARACTER_ROW; int mx = MAP_WIDTH / 2; enemy.x = mx;
    for (int s = 0; s < 15; s++) { int ry = MAP_START_Y + s; for (int c = 0; c < MAP_WIDTH; c += 3) { if (c != player.x) { gotoxy(MAP_START_X + c, ry); setColor(12); cout << "|"; } if (c + 1 != player.x) { gotoxy(MAP_START_X + c + 1, ry); setColor(14); cout << "*"; } } this_thread::sleep_for(chrono::milliseconds(100)); if (s > 0) { int py = MAP_START_Y + s - 1; for (int c = 0; c < MAP_WIDTH; c += 3) { gotoxy(MAP_START_X + c, py); cout << " "; gotoxy(MAP_START_X + c + 1, py); cout << " "; } } }
    enemy.hp -= increasePlayerDamage(40); if (enemy.hp < 0) enemy.hp = 0;
    for (int i = 0; i < 3; i++) { int sx = player.x + 1 + i; if (sx < MAP_WIDTH) { gotoxy(MAP_START_X + sx, cy); setColor(9); cout << "-"; } } this_thread::sleep_for(chrono::seconds(1));
    enemy.hp -= increasePlayerDamage(30); if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "宇智波的荣耀造成70点伤害!"; for (int i = 0; i < 3; i++) { int sx = player.x + 1 + i; if (sx < MAP_WIDTH) { gotoxy(MAP_START_X + sx, cy); cout << " "; } }
    skillInProgress = false;
}

// ---------- 漂泊浪客(修改后) ----------
void playerWandererNormalAttack() {
    if (skillInProgress || enemySkillInProgress || playerWandererSpinActive || playerWandererShockActive) return;
    auto now = chrono::steady_clock::now(); if (now < playerWandererNormalCDEnd) return;
    for (int i = player.x + 1; i < enemy.x; i++) {
        gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); setColor(13); cout << ")";
        this_thread::sleep_for(chrono::milliseconds(15));
        if (i != enemy.x - 1) { gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); cout << " "; }
    }
    int dmg = increasePlayerDamage(rand() % 3 + 10); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    playerWandererNormalCDEnd = now + chrono::milliseconds(300);
}
void playerWandererSkill1() {
    if (playerWandererShockActive) { playerWandererShockActive = false; enemySkillInProgress = false; }
    if (skillInProgress || enemySkillInProgress || playerWandererSpinActive || playerWandererShockActive) return;
    auto now = chrono::steady_clock::now(); if (now < playerWandererSkill1CDEnd) return;
    skillInProgress = true;
    for (int i = player.x + 1; i < enemy.x; i++) { gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); setColor(13); cout << "]"; this_thread::sleep_for(chrono::milliseconds(20)); if (i != enemy.x - 1) { gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); cout << " "; } }
    int dmg1 = increasePlayerDamage(rand() % 3 + 8); enemy.hp -= dmg1; if (enemy.hp < 0) enemy.hp = 0;
    this_thread::sleep_for(chrono::milliseconds(500));
    for (int i = player.x + 1; i < enemy.x; i++) { gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); setColor(13); cout << "}"; this_thread::sleep_for(chrono::milliseconds(20)); if (i != enemy.x - 1) { gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); cout << " "; } }
    int dmg2 = increasePlayerDamage(rand() % 4 + 12); enemy.hp -= dmg2; if (enemy.hp < 0) enemy.hp = 0;
    playerWandererSkill1CDEnd = now + chrono::milliseconds(500);
    playerWandererStateSwitchWindow = now + chrono::seconds(1);
    skillInProgress = false;
}
void playerWandererShortSkill2() {
    if (playerWandererShockActive) { playerWandererShockActive = false; enemySkillInProgress = false; }
    if (skillInProgress || enemySkillInProgress || playerWandererSpinActive || playerWandererShockActive) return;
    if (playerWandererShortSkill2Used || playerWandererState != 0) return;
    skillInProgress = true;
    for (int j = 0; j < 3; j++) {
        for (int i = player.x + 1; i < enemy.x; i++) { gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); setColor(13); cout << "]"; this_thread::sleep_for(chrono::milliseconds(10)); if (i != enemy.x - 1) { gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); cout << " "; } }
        int dmg = increasePlayerDamage(rand() % 5 + 12); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    }
    playerWandererShortSkill2Used = true;
    playerWandererShortSubSkillCDEnd = chrono::steady_clock::now() + chrono::seconds(5);
    skillInProgress = false;
}
void playerWandererShortSubSkill() {
    if (skillInProgress || enemySkillInProgress || !playerWandererShortSkill2Used || playerWandererState != 0) return;
    if (playerWandererSpinActive) return;
    auto now = chrono::steady_clock::now();
    if (now < playerWandererShortSubSkillCDEnd) return;
    playerWandererSpinActive = true;
    playerWandererSpinEnd = now + chrono::seconds(15);
    enemySkillInProgress = true;
    // 传送敌人至正上方2格
    playerWandererSpinEnemySavedX = enemy.x;
    playerWandererSpinEnemyTransferred = true;
    enemy.x = player.x;
}
void playerWandererLongSkill2() {
    if (playerWandererShockActive) { playerWandererShockActive = false; enemySkillInProgress = false; }
    if (skillInProgress || enemySkillInProgress || playerWandererSpinActive || playerWandererShockActive) return;
    if (playerWandererState != 1 || playerWandererLongSkill2Count <= 0) return;
    auto now = chrono::steady_clock::now();
    if (now < playerWandererLongSkill2CDEnd) return;
    playerObitoKamuiActive = true; playerObitoKamuiEnd = now + chrono::seconds(5);
    playerWandererLongSkill2Count--;
    playerWandererLongSkill2CDEnd = now + chrono::seconds(8);
}
void playerWandererLongSubSkill() {
    if (skillInProgress || enemySkillInProgress || playerWandererSpinActive || playerWandererShockActive) return;
    if (playerWandererState != 1) return;
    // 震刀距离判断:敌人必须在右侧8格内
    int dist = enemy.x - player.x;
    if (dist < 1 || dist > 8) {
        gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "距离太远,无法震刀!";
        return;
    }
    playerWandererShockActive = true;
    playerWandererShockEnemyY = CHARACTER_ROW - 5;
    enemySkillInProgress = true;
    int dmg = increasePlayerDamage(rand() % 6 + 25);
    enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    playerWandererShockDropTime = chrono::steady_clock::now();
}
void playerWandererUltimate() {
    if (playerWandererShockActive) { playerWandererShockActive = false; enemySkillInProgress = false; }
    if (skillInProgress || enemySkillInProgress || playerWandererSpinActive || playerWandererShockActive) return;
    if (enemy.hp > 80) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "对方HP需<=80!"; return; }
    skillInProgress = true; enemySkillInProgress = true;
    int targetX = MAP_WIDTH / 2;
    while (player.x < targetX) player.x++;
    drawBattleMap();
    gotoxy(MAP_START_X + player.x + 1, MAP_START_Y + CHARACTER_ROW); setColor(13); cout << "------";
    this_thread::sleep_for(chrono::seconds(1));
    enemy.hp -= increasePlayerDamage(80); if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(MAP_START_X + player.x + 1, MAP_START_Y + CHARACTER_ROW); cout << "  ";
    skillInProgress = false; enemySkillInProgress = false;
}
void playerWandererSwitchState() {
    if (playerWandererState == 0) playerWandererState = 1;
    else playerWandererState = 0;
}

// ---------- 水门(修改后) ----------
void playerMinatoNormalAttack() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now();
    if (now < playerMinatoNormalCDEnd) return;
    for (int i = player.x + 1; i < enemy.x; i++) {
        gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); setColor(14); cout << "-";
        this_thread::sleep_for(chrono::milliseconds(20));
        gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); cout << " ";
    }
    int dmg = increasePlayerDamage(rand() % 3 + 8); // 8-10
    enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    playerMinatoNormalCDEnd = now + chrono::milliseconds(500);
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "苦无刺击造成" << dmg << "点伤害!";
}
void playerMinatoSkill1() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < playerMinatoSkill1CDEnd) return;
    skillInProgress = true;
    player.x = enemy.x - 2; if (player.x < 1) player.x = 1;
    drawBattleMap();
    gotoxy(MAP_START_X + player.x + 1, MAP_START_Y + CHARACTER_ROW); setColor(14); cout << "〇";
    this_thread::sleep_for(chrono::milliseconds(800));
    int dmg = increasePlayerDamage(rand() % 7 + 18); enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(MAP_START_X + player.x + 1, MAP_START_Y + CHARACTER_ROW); cout << " ";
    playerMinatoSkill1CDEnd = now + chrono::seconds(15);
    skillInProgress = false;
}
void playerMinatoSkill2() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < playerMinatoSkill2CDEnd) return;
    if (!playerMinatoMarkActive) {
        skillInProgress = true;
        for (int i = player.x + 1; i < enemy.x; i++) {
            gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); setColor(14); cout << "-";
            this_thread::sleep_for(chrono::milliseconds(10));
            gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); cout << " ";
        }
        playerMinatoMarkActive = true; playerMinatoMarkX = enemy.x; playerMinatoMarkEnd = now + chrono::seconds(10);
        playerMinatoCounterReady = true;
        skillInProgress = false;
        gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "飞雷神标记已刻印";
    }
    else if (playerMinatoCounterReady) {
        enemySkillInProgress = true;
        playerMinatoSkill1();
        playerMinatoCounterReady = false;
        playerMinatoMarkActive = false;
    }
    playerMinatoSkill2CDEnd = now + chrono::seconds(10);
}
void playerMinatoUltimate() {
    if (skillInProgress || enemySkillInProgress) return;
    if (enemy.hp > 75) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "对方HP需<=75!"; return; }
    skillInProgress = true; enemySkillInProgress = true;
    gotoxy(MAP_START_X + enemy.x - 1, MAP_START_Y + CHARACTER_ROW); setColor(14); cout << "(0)";
    this_thread::sleep_for(chrono::seconds(2));
    int dmg = increasePlayerDamage(rand() % 6 + 75);
    enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    gotoxy(MAP_START_X + enemy.x - 1, MAP_START_Y + CHARACTER_ROW); cout << "   ";
    skillInProgress = false; enemySkillInProgress = false;
}

// ---------- 黑绝 ----------
void playerBlackZetsuNormalAttack() {
    if (player.x >= enemy.x) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "必须在敌人左侧!"; return; }
    auto now = chrono::steady_clock::now(); if (now < playerBlackZetsuNormalCDEnd) { gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "黑绝普攻冷却中..."; return; }
    player.x = enemy.x - 1; if (player.x < 1) player.x = 1;
    int dmg = rand() % 3 + 8; enemy.hp -= dmg; if (enemy.hp < 0) enemy.hp = 0;
    playerBlackZetsuNormalCDEnd = now + chrono::seconds(3);
    gotoxy(2, MAP_START_Y + MAP_HEIGHT + 4); cout << "黑绝普攻造成 " << dmg << " 点伤害!";
}

// ==================== 玩家动作分发 ====================
void playerNormalAttack() {
    if (playerCharacterType == 0) playerNarutoNormalAttack();
    else if (playerCharacterType == 1) playerPainNormalAttack();
    else if (playerCharacterType == 2) playerObitoNormalAttack();
    else if (playerCharacterType == 3) { if (playerBorutoKarmaActive && playerBorutoFlying) playerBorutoEnhancedAttack(); else playerBorutoNormalAttack(); }
    else if (playerCharacterType == 4) { if (playerHashiramaWoodGolemActive) playerHashiramaWoodGolemAttack(); else playerHashiramaNormalAttack(); }
    else if (playerCharacterType == 5) playerSasukeNormalAttack();
    else if (playerCharacterType == 6) playerIzunaNormalAttack();
    else if (playerCharacterType == 7) playerBlackZetsuNormalAttack();
    else if (playerCharacterType == 8) playerWandererNormalAttack();
    else if (playerCharacterType == 9) playerMinatoNormalAttack();
}
void playerSkill1() {
    if (playerCharacterType == 0) playerNarutoSkill1();
    else if (playerCharacterType == 1) playerPainSkill1();
    else if (playerCharacterType == 2) playerObitoSkill1();
    else if (playerCharacterType == 3) playerBorutoSkill1();
    else if (playerCharacterType == 4) playerHashiramaSkill1();
    else if (playerCharacterType == 5) playerSasukeSkill1();
    else if (playerCharacterType == 6) playerIzunaSkill1();
    else if (playerCharacterType == 7) return;
    else if (playerCharacterType == 8) playerWandererSkill1();
    else if (playerCharacterType == 9) playerMinatoSkill1();
}
void playerSkill2() {
    if (playerCharacterType == 0) playerNarutoSkill2();
    else if (playerCharacterType == 1) playerPainSkill2();
    else if (playerCharacterType == 2) playerObitoSkill2();
    else if (playerCharacterType == 3) playerBorutoSkill2();
    else if (playerCharacterType == 4) playerHashiramaSkill2();
    else if (playerCharacterType == 5) playerSasukeSkill2();
    else if (playerCharacterType == 6) playerIzunaSkill2();
    else if (playerCharacterType == 7) return;
    else if (playerCharacterType == 8) { if (playerWandererState == 0) playerWandererShortSkill2(); else playerWandererLongSkill2(); }
    else if (playerCharacterType == 9) playerMinatoSkill2();
}
void playerUltimate() {
    if (playerCharacterType == 0) playerNarutoUltimate();
    else if (playerCharacterType == 1) playerPainUltimate();
    else if (playerCharacterType == 2) playerObitoUltimate();
    else if (playerCharacterType == 3) playerBorutoUltimate();
    else if (playerCharacterType == 4) playerHashiramaUltimate();
    else if (playerCharacterType == 5) playerSasukeUltimate();
    else if (playerCharacterType == 6) playerIzunaUltimate();
    else if (playerCharacterType == 7) return;
    else if (playerCharacterType == 8) playerWandererUltimate();
    else if (playerCharacterType == 9) playerMinatoUltimate();
}

// ==================== 敌人技能函数 ====================

// ---------- 敌人鸣人 ----------
void enemyNarutoNormalAttack() {
    int d = abs(player.x - enemy.x);
    if (enemy.x > player.x && d >= 1 && d <= 3) {
        int dmg = reducePlayerDamage(rand() % 4 + 3);
        enemyNarutoTailActive = true; enemyNarutoTailEnd = chrono::steady_clock::now() + chrono::milliseconds(1500);
        for (int i = 0; i < 3; i++) { enemyNarutoTailX[i] = enemy.x - 1 - i; if (enemyNarutoTailX[i] <= player.x) { enemyNarutoTailX[i] = 0; break; } }
        player.hp -= dmg; if (player.hp < 0) player.hp = 0;
        enemyNormalAttackCount++;
    }
}
void enemyNarutoSkill1() {
    if (enemySkillInProgress || skillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < enemySkill1CDEnd) return;
    enemySkillInProgress = true; int tx = player.x + 1;
    while (enemy.x > tx) { enemy.x--; if (enemy.x <= player.x) { enemy.x = player.x + 1; break; } this_thread::sleep_for(chrono::milliseconds(50)); }
    int dmg = reducePlayerDamage(rand() % 8 + 8); player.hp -= dmg; if (player.hp < 0) player.hp = 0;
    enemySkill1CDEnd = now + chrono::seconds(8); enemySkillInProgress = false;
}
void enemyNarutoSkill2() {
    if (enemySkillInProgress || skillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < enemySkill2CDEnd) return;
    enemySkillInProgress = true; bool caught = false;
    for (int i = 0; i < 20; i++) { int cx = enemy.x - 1 - i; if (cx <= 0 || cx <= player.x) break; if (cx == player.x + 1) { caught = true; break; } }
    this_thread::sleep_for(chrono::milliseconds(500));
    if (caught) { int dmg = reducePlayerDamage(rand() % 6 + 20); player.hp -= dmg; if (player.hp < 0) player.hp = 0; enemySkill2CDEnd = now + chrono::seconds(15); }
    else { enemySkill2CDEnd = now + chrono::seconds(7); }
    enemySkillInProgress = false;
}
void enemyNarutoUltimate() {
    if (enemySkillInProgress || skillInProgress) return;
    if (player.hp > 35) return;
    enemySkillInProgress = true; player.hp -= reducePlayerDamage(35); if (player.hp < 0) player.hp = 0;
    this_thread::sleep_for(chrono::seconds(3)); enemySkillInProgress = false;
}

// ---------- 敌人佩恩 ----------
void enemyPainNormalAttack() {
    if (enemy.x <= player.x) return;
    int cy = MAP_START_Y + CHARACTER_ROW;
    if (enemyPainRodActive) { if (enemyPainRodX > 0 && enemyPainRodX < MAP_WIDTH && enemyPainRodX != player.x && enemyPainRodX != enemy.x) { gotoxy(MAP_START_X + enemyPainRodX, cy); cout << " "; } enemyPainRodActive = false; enemyRodHitting = false; }
    int rx = enemy.x - 3; if (rx <= player.x) rx = player.x + 1; if (rx >= enemy.x) return; if (rx == player.x) rx = player.x + 1;
    enemyPainRodActive = true; enemyPainRodX = rx; enemyPainRodEnd = chrono::steady_clock::now() + chrono::milliseconds(1500);
    int dmg = reducePlayerDamage(rand() % 3 + 4); player.hp -= dmg; if (player.hp < 0) player.hp = 0;
    if (rx == player.x + 1) { enemyRodHitting = true; enemyRodHitEnd = enemyPainRodEnd; }
    else { enemyRodHitting = false; }
    enemyNormalAttackCount++;
}
void enemyPainSkill1() {
    if (enemySkillInProgress || skillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < enemySkill1CDEnd) return;
    skillInProgress = true; enemySkillInProgress = true; int tx = enemy.x - 2;
    while (player.x < tx) { player.x++; if (player.x >= enemy.x) { player.x = enemy.x - 2; break; } this_thread::sleep_for(chrono::milliseconds(30)); }
    player.x = tx; enemyBanshoTeninActive = true; enemyBanshoTeninEnd = now + chrono::seconds(5);
    int dmg = reducePlayerDamage(rand() % 4 + 10); player.hp -= dmg; if (player.hp < 0) player.hp = 0;
    enemySkill1CDEnd = now + chrono::seconds(12); enemySkillInProgress = false; skillInProgress = false;
}
void enemyPainSkill2() {
    if (enemySkillInProgress || skillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < enemySkill2CDEnd) return;
    enemySkillInProgress = true; int dmg = reducePlayerDamage(rand() % 5 + 8);
    if (abs(player.x - enemy.x) <= 1) { player.hp -= dmg; if (player.hp < 0) player.hp = 0; }
    this_thread::sleep_for(chrono::seconds(1)); enemySkill2CDEnd = now + chrono::seconds(15); enemySkillInProgress = false;
}
void enemyPainUltimate() {
    if (enemySkillInProgress || skillInProgress) return;
    if (player.hp > 50) return;
    enemySkillInProgress = true; int tx = MAP_WIDTH / 2;
    while (enemy.x != tx) { if (enemy.x < tx) enemy.x++; else enemy.x--; this_thread::sleep_for(chrono::milliseconds(20)); }
    for (int s = 1; s <= 5; s++) { player.hp -= reducePlayerDamage(10); if (player.hp < 0) player.hp = 0; this_thread::sleep_for(chrono::seconds(1)); if (player.hp <= 0) break; }
    enemySkillInProgress = false;
}

// ---------- 敌人带土 ----------
void enemyObitoNormalAttack() {
    if (enemy.x <= player.x) return;
    int d = abs(player.x - enemy.x); if (d < 1 || d > 2) return;
    int kx = enemy.x - 1; if (kx <= player.x) kx = player.x + 1; if (kx >= enemy.x) return;
    enemyObitoKickActive = true; enemyObitoKickX = kx; enemyObitoKickEnd = chrono::steady_clock::now() + chrono::milliseconds(1000);
    int dmg = reducePlayerDamage(rand() % 3 + 6); player.hp -= dmg; if (player.hp < 0) player.hp = 0;
    enemyNormalAttackCount++;
}
void enemyObitoSkill1() {
    if (enemySkillInProgress || skillInProgress) return;
    auto now = chrono::steady_clock::now(); int cy = MAP_START_Y + CHARACTER_ROW;
    if (enemyObitoEnemyTrapped && !enemyObitoFireActive) {
        int sx = enemy.x, tx = player.x + 3; if (tx >= MAP_WIDTH - 2) tx = MAP_WIDTH - 3;
        enemySkillInProgress = true; enemyObitoFireActive = true; enemy.x = tx; drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(300));
        int fx = enemy.x - 1; for (int i = 0; i < 8; i++) { int px = fx - i; if (px > 0 && px != player.x && px != enemy.x) { gotoxy(MAP_START_X + px, cy); setColor(6); cout << "~"; } }
        int dmg = reducePlayerDamage(rand() % 5 + 14); player.hp -= dmg; if (player.hp < 0) player.hp = 0;
        this_thread::sleep_for(chrono::seconds(2)); for (int i = 0; i < 8; i++) { int px = fx - i; if (px > 0 && px != player.x && px != enemy.x) { gotoxy(MAP_START_X + px, cy); cout << " "; } }
        enemy.x = sx; enemyObitoFireActive = false; enemySkillInProgress = false; return;
    }
    if (now < enemySkill1CDEnd) return;
    enemySkillInProgress = true; enemyObitoWoodSpikeX = enemy.x - 1; enemyObitoWoodSpikeActive = true; enemyObitoWoodSpikeEnd = now + chrono::milliseconds(500);
    bool hit = false;
    for (int i = 0; i < 30; i++) { int cx = enemy.x - 1 - i; if (cx <= 0 || cx <= player.x) break; if (cx != player.x && cx != enemy.x) { gotoxy(MAP_START_X + cx, cy); setColor(2); cout << "-"; } if (cx == player.x + 1) { hit = true; break; } this_thread::sleep_for(chrono::milliseconds(20)); }
    if (hit) { enemyObitoEnemyTrapped = true; enemyObitoEnemyTrappedEnd = now + chrono::seconds(15); int dmg = reducePlayerDamage(rand() % 5 + 12); player.hp -= dmg; if (player.hp < 0) player.hp = 0; }
    else { enemyObitoWoodSpikeActive = false; }
    for (int i = 0; i < 30; i++) { int cx = enemy.x - 1 - i; if (cx <= 0 || cx <= player.x) break; if (cx != player.x && cx != enemy.x) { gotoxy(MAP_START_X + cx, cy); cout << " "; } }
    enemySkill1CDEnd = now + chrono::seconds(hit ? 20 : 10); enemySkillInProgress = false;
}
void enemyObitoSkill2() {
    if (enemySkillInProgress || skillInProgress) return;
    auto now = chrono::steady_clock::now(); int cy = MAP_START_Y + CHARACTER_ROW;
    if (enemyObitoKamuiActive && !enemyObitoKamuiSpaceActive) {
        enemyObitoKamuiActive = false; enemyObitoKamuiSpaceActive = true; enemyObitoSavedX = enemy.x;
        int tx = player.x + 1; if (tx >= MAP_WIDTH - 2) tx = MAP_WIDTH - 3; enemy.x = tx; enemyObitoPlayerInSpace = true; enemyObitoKamuiSpaceEnd = now + chrono::seconds(3);
        drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(500));
        for (int s = 0; s < 3; s++) { int dmg = reducePlayerDamage(rand() % 3 + 8); player.hp -= dmg; if (player.hp < 0) player.hp = 0; this_thread::sleep_for(chrono::seconds(1)); if (player.hp <= 0) break; }
        enemyObitoPlayerInSpace = false; enemyObitoKamuiSpaceActive = false; player.x = enemy.x - 3; if (player.x < 1) player.x = 1;
        enemySkill2CDEnd = now + chrono::seconds(10); return;
    }
    if (enemyObitoEnemyTrapped && !enemyObitoWoodStormActive) {
        enemySkillInProgress = true; enemyObitoWoodStormActive = true; int sx = enemy.x, tx = player.x - 5; if (tx < 2) tx = 2; enemy.x = tx;
        drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(300));
        for (int i = 0; i < 20; i++) { int bx = enemy.x + 1 + i; if (bx >= MAP_WIDTH || bx >= player.x) break; if (bx != player.x && bx != enemy.x) { gotoxy(MAP_START_X + bx, cy - 1); setColor(2); cout << "_"; gotoxy(MAP_START_X + bx, cy); setColor(2); cout << "-"; } }
        for (int s = 0; s < 6; s++) { if (abs(enemy.x - player.x) <= 20) { player.hp -= reducePlayerDamage(8); if (player.hp < 0) player.hp = 0; } this_thread::sleep_for(chrono::seconds(1)); if (player.hp <= 0) break; }
        for (int i = 0; i < 20; i++) { int bx = enemy.x + 1 + i; if (bx >= MAP_WIDTH) break; if (bx != player.x && bx != enemy.x) { gotoxy(MAP_START_X + bx, cy - 1); cout << " "; gotoxy(MAP_START_X + bx, cy); cout << " "; } }
        enemy.x = sx; enemyObitoWoodStormActive = false; enemySkillInProgress = false; return;
    }
    if (now < enemySkill2CDEnd) return;
    enemyObitoKamuiActive = true; enemyObitoKamuiEnd = now + chrono::seconds(5);
}
void enemyObitoUltimate() {
    if (enemySkillInProgress || skillInProgress) return;
    if (player.hp > 50) return;
    enemySkillInProgress = true; int cy = MAP_START_Y + CHARACTER_ROW, tby = cy - 5;
    for (int r = 0; r < 5; r++) for (int c = 0; c < 10; c++) { int x = enemy.x - 5 + c, y = tby - r; if (x > 0 && x < MAP_WIDTH && y > 0) { gotoxy(MAP_START_X + x, MAP_START_Y + y); setColor(8); cout << "*"; } }
    gotoxy(MAP_START_X + enemy.x, MAP_START_Y + tby - 5); setColor(12); cout << "&"; this_thread::sleep_for(chrono::seconds(2));
    player.hp -= reducePlayerDamage(50); if (player.hp < 0) player.hp = 0;
    for (int r = 0; r < 5; r++) for (int c = 0; c < 10; c++) { int x = enemy.x - 5 + c, y = tby - r; if (x > 0 && x < MAP_WIDTH && y > 0) { gotoxy(MAP_START_X + x, MAP_START_Y + y); cout << " "; } }
    gotoxy(MAP_START_X + enemy.x, MAP_START_Y + tby - 5); cout << " ";
    enemySkillInProgress = false;
}

// ---------- 敌人博人 ----------
void enemyBorutoNormalAttack() {
    if (enemy.x <= player.x) return;
    int d = abs(player.x - enemy.x); if (d < 1 || d > 4) return;
    if (playerObitoKamuiActive && !playerObitoKamuiSpaceActive) return;
    enemyBorutoSwordActive = true; enemyBorutoSwordSlashing = true; enemyBorutoSwordEnd = chrono::steady_clock::now() + chrono::milliseconds(2000); enemyBorutoSwordX = enemy.x - 1;
    int d1 = reducePlayerDamage(rand() % 3 + 7); player.hp -= d1; if (player.hp < 0) player.hp = 0;
    this_thread::sleep_for(chrono::milliseconds(400));
    if (enemyRodHitting || enemyBanshoTeninActive || enemyObitoEnemyTrapped || enemyHashiramaEnemyTrapped || enemySasukeAmaterasuHit || enemyIzunaCounterActive) { enemyBorutoSwordActive = false; enemyBorutoSwordSlashing = false; return; }
    int d2 = reducePlayerDamage(rand() % 4 + 7); player.hp -= d2; if (player.hp < 0) player.hp = 0;
    this_thread::sleep_for(chrono::milliseconds(400));
    if (enemyRodHitting || enemyBanshoTeninActive || enemyObitoEnemyTrapped || enemyHashiramaEnemyTrapped || enemySasukeAmaterasuHit || enemyIzunaCounterActive) { enemyBorutoSwordActive = false; enemyBorutoSwordSlashing = false; return; }
    int d3 = reducePlayerDamage(rand() % 5 + 8); player.hp -= d3; if (player.hp < 0) player.hp = 0;
    enemyBorutoSwordActive = false; enemyBorutoSwordSlashing = false; enemyNormalAttackCount++;
}
void enemyBorutoSkill1() {
    if (enemySkillInProgress || skillInProgress) return;
    auto now = chrono::steady_clock::now();
    if (enemyBorutoKarmaActive) { if (enemyBorutoFlying) return; if (now < enemySkill1CDEnd) return; enemyBorutoFlying = true; enemyBorutoFlyingEnd = now + chrono::seconds(10); enemyBorutoEnhancedAttackCount = 0; enemySkill1CDEnd = now + chrono::seconds(6); return; }
    if (now < enemySkill1CDEnd) return;
    enemySkillInProgress = true; int tx = player.x + 3; if (tx >= MAP_WIDTH - 2) tx = MAP_WIDTH - 3;
    while (enemy.x < tx) { enemy.x++; drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(30)); }
    while (enemy.x > tx) { enemy.x--; drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(30)); }
    enemyBorutoRasenganActive = true; enemyBorutoRasenganEnd = now + chrono::seconds(3); enemyBorutoRasenganHit = true;
    for (int s = 0; s < 3; s++) { int dmg = reducePlayerDamage(rand() % 5 + 8); player.hp -= dmg; if (player.hp < 0) player.hp = 0; this_thread::sleep_for(chrono::seconds(1)); if (player.hp <= 0) break; }
    enemyBorutoRasenganActive = false; tx = player.x + 8; if (tx >= MAP_WIDTH - 2) tx = MAP_WIDTH - 3; enemy.x = tx;
    enemyBorutoMarkActive = true; enemyBorutoMarkX = player.x; enemyBorutoMarkEnd = now + chrono::seconds(10);
    enemyBorutoTeleported = false; enemyBorutoTeleportBack = false;
    enemySkill1CDEnd = now + chrono::seconds(18); enemySkillInProgress = false;
}
void enemyBorutoSkill2() {
    if (enemySkillInProgress || skillInProgress) return;
    auto now = chrono::steady_clock::now();
    if (enemyBorutoKarmaActive) { if (enemyBorutoFlying) return; if (now < enemySkill2CDEnd) return; enemySkillInProgress = true; int bx = enemy.x - 1, cy = MAP_START_Y + CHARACTER_ROW; for (int s = 0; s < 20; s++) { int cx = bx - s; if (cx <= player.x) break; if (s > 0) { gotoxy(MAP_START_X + cx + 1, cy); cout << " "; } if (cx != player.x && cx != enemy.x) { gotoxy(MAP_START_X + cx, cy); setColor(11); cout << "O"; } this_thread::sleep_for(chrono::milliseconds(50)); } int dmg = reducePlayerDamage(rand() % 6 + 15); player.hp -= dmg; if (player.hp < 0) player.hp = 0; gotoxy(MAP_START_X + player.x + 1, cy); cout << " "; enemySkill2CDEnd = now + chrono::seconds(15); enemySkillInProgress = false; return; }
    if (enemyBorutoMarkActive && !enemyBorutoTeleported) { enemyBorutoTeleportSavedX = enemy.x; enemy.x = player.x + 3; if (enemy.x >= MAP_WIDTH - 2) enemy.x = MAP_WIDTH - 3; enemyBorutoTeleported = true; enemyBorutoTeleportTime = now; int dmg = reducePlayerDamage(rand() % 9 + 10); player.hp -= dmg; if (player.hp < 0) player.hp = 0; enemyBorutoTeleportBack = true; return; }
    if (enemyBorutoTeleported && enemyBorutoTeleportBack) { auto ts = chrono::duration_cast<chrono::seconds>(now - enemyBorutoTeleportTime).count(); if (ts <= 5) { enemy.x = enemyBorutoTeleportSavedX; enemyBorutoTeleported = false; enemyBorutoTeleportBack = false; enemySkill2CDEnd = now + chrono::seconds(8); return; } else { enemyBorutoTeleportBack = false; } }
    if (now < enemySkill2CDEnd) return;
}
void enemyBorutoUltimate() {
    if (enemySkillInProgress || skillInProgress) return; if (enemyBorutoKarmaActive) return;
    auto now = chrono::steady_clock::now(); if (now < enemySkill3CDEnd) return;
    enemySkillInProgress = true; enemyBorutoKarmaActive = true; enemyBorutoKarmaEnd = now + chrono::seconds(60);
    enemySkill3CDEnd = now + chrono::seconds(45); enemySkillInProgress = false;
}

// ---------- 敌人柱间 ----------
void enemyHashiramaNormalAttack() {
    if (enemy.x <= player.x) return;
    int d = abs(player.x - enemy.x); if (d < 1 || d > 5) return;
    enemyHashiramaStompActive = true; enemyHashiramaStompX = enemy.x - 1; enemyHashiramaStompEnd = chrono::steady_clock::now() + chrono::milliseconds(800);
    int dmg = reducePlayerDamage(rand() % 3 + 8); player.hp -= dmg; if (player.hp < 0) player.hp = 0;
    enemyNormalAttackCount++;
}
void enemyHashiramaSkill1() {
    if (enemySkillInProgress || skillInProgress) return;
    auto now = chrono::steady_clock::now();
    if (enemyHashiramaEnemyTrapped && !enemyHashiramaMyojinmonUsed) {
        enemySkillInProgress = true; enemyHashiramaMyojinmonActive = true; enemyHashiramaMyojinmonUsed = true;
        int dmg = reducePlayerDamage(rand() % 16 + 20); player.hp -= dmg; if (player.hp < 0) player.hp = 0;
        this_thread::sleep_for(chrono::seconds(2)); enemyHashiramaMyojinmonActive = false; enemyHashiramaEnemyTrapped = false; enemyHashiramaWoodDragonActive = false;
        enemySkillInProgress = false; return;
    }
    if (now < enemySkill1CDEnd) return;
    enemySkillInProgress = true; enemyHashiramaWoodDragonActive = true; enemyHashiramaWoodDragonEnd = now + chrono::milliseconds(1000);
    int sx = enemy.x - 1, cy = MAP_START_Y + CHARACTER_ROW; bool hit = false;
    for (int i = 0; i < 20; i++) { int dx = sx - i; if (dx <= 0 || dx <= player.x) break; if (dx != player.x && dx != enemy.x) { gotoxy(MAP_START_X + dx, cy); setColor(2); cout << "~"; } if (dx == player.x + 1) { hit = true; break; } this_thread::sleep_for(chrono::milliseconds(30)); }
    if (hit) { enemyHashiramaEnemyTrapped = true; enemyHashiramaWoodDragonTrapEnd = now + chrono::seconds(8); enemyHashiramaMyojinmonUsed = false; int dmg = reducePlayerDamage(rand() % 6 + 15); player.hp -= dmg; if (player.hp < 0) player.hp = 0; }
    else { enemyHashiramaWoodDragonActive = false; }
    enemySkill1CDEnd = now + chrono::seconds(15); enemySkillInProgress = false;
}
void enemyHashiramaSkill2() {
    if (enemySkillInProgress || skillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < enemySkill2CDEnd) return; if (enemyHashiramaWoodGolemActive) return;
    enemySkillInProgress = true; enemyHashiramaWoodGolemActive = true; enemyHashiramaWoodGolemEnd = now + chrono::seconds(5);
    enemyHashiramaWoodGolemAttackCount = 0; enemySkill2CDEnd = now + chrono::seconds(18); enemySkillInProgress = false;
}
void enemyHashiramaUltimate() {
    if (enemySkillInProgress || skillInProgress) return; if (player.hp > 80) return;
    enemySkillInProgress = true; int tx = MAP_WIDTH - 15;
    while (enemy.x < tx) { enemy.x++; drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(20)); }
    int cy = MAP_START_Y + CHARACTER_ROW; for (int r = 0; r < 3; r++) for (int c = 0; c < 4; c++) { int gx = enemy.x - 1 + c, gy = cy - 3 - r; if (gx > 0 && gx < MAP_WIDTH && gy > 0) { gotoxy(MAP_START_X + gx, MAP_START_Y + gy); setColor(6); cout << "¥"; } }
    for (int i = 0; i < 10; i++) { int ax = enemy.x - 4 - i; if (ax > 0 && ax != player.x) { gotoxy(MAP_START_X + ax, cy); setColor(6); cout << "\\"; } this_thread::sleep_for(chrono::milliseconds(100)); }
    player.hp -= reducePlayerDamage(80); if (player.hp < 0) player.hp = 0;
    this_thread::sleep_for(chrono::seconds(2)); for (int i = 0; i < 10; i++) { int ax = enemy.x - 4 - i; if (ax > 0) { gotoxy(MAP_START_X + ax, cy); cout << " "; } }
    for (int r = 0; r < 3; r++) for (int c = 0; c < 4; c++) { int gx = enemy.x - 1 + c, gy = cy - 3 - r; if (gx > 0 && gx < MAP_WIDTH && gy > 0) { gotoxy(MAP_START_X + gx, MAP_START_Y + gy); cout << " "; } }
    enemySkillInProgress = false;
}

// ---------- 敌人佐助 ----------
void enemySasukeNormalAttack() {
    if (enemy.x <= player.x) return;
    int d = abs(player.x - enemy.x); if (d < 1 || d > 10) return;
    auto now = chrono::steady_clock::now(); if (now < enemySasukeSlashCD) return;
    if (enemySasukeSusanooActive && enemySasukeSusanooSlashCount < 3) {
        enemySasukeSusanooSlashActive = true; enemySasukeSusanooSlashEnd = now + chrono::milliseconds(1500); enemySasukeSusanooSlashCount++;
        int sx = enemy.x - 3; for (int i = 0; i <= d; i++) { int cx = sx - i; if (cx <= player.x) break; if (i > 0) { int px = sx - (i - 1); for (int r = 0; r < 8; r++) { int sy = MAP_START_Y + CHARACTER_ROW - 2 - r; if (sy > 0) { gotoxy(MAP_START_X + px, MAP_START_Y + sy); cout << " "; } } } for (int r = 0; r < 8; r++) { int sy = MAP_START_Y + CHARACTER_ROW - 2 - r; if (sy > 0 && cx != player.x && cx != enemy.x) { gotoxy(MAP_START_X + cx, MAP_START_Y + sy); setColor(13); cout << "}"; } } this_thread::sleep_for(chrono::milliseconds(80)); }
        int lx = sx - d; if (lx <= player.x) lx = player.x + 1; for (int r = 0; r < 8; r++) { int sy = MAP_START_Y + CHARACTER_ROW - 2 - r; if (sy > 0) { gotoxy(MAP_START_X + lx, MAP_START_Y + sy); cout << " "; } }
        int dmg = reducePlayerDamage(rand() % 6 + 25); player.hp -= dmg; if (player.hp < 0) player.hp = 0;
        if (enemySasukeSusanooSlashCount >= 3) { enemySasukeSusanooActive = false; enemySasukeSusanooSlashCount = 0; }
        enemyNormalAttackCount++; return;
    }
    enemySasukeSlashActive = true; enemySasukeSlashEnd = now + chrono::milliseconds(500); enemySasukeSlashCD = now + chrono::milliseconds(1500);
    int sx = enemy.x - 1; for (int i = 0; i <= d; i++) { int cx = sx - i; if (cx <= player.x) break; if (i > 0) { int px = sx - (i - 1); if (px != player.x && px != enemy.x) { gotoxy(MAP_START_X + px, MAP_START_Y + CHARACTER_ROW); cout << " "; } } if (cx != player.x && cx != enemy.x) { gotoxy(MAP_START_X + cx, MAP_START_Y + CHARACTER_ROW); setColor(13); cout << ")"; } this_thread::sleep_for(chrono::milliseconds(30)); }
    int lx = sx - d; if (lx <= player.x) lx = player.x + 1; if (lx != player.x && lx != enemy.x) { gotoxy(MAP_START_X + lx, MAP_START_Y + CHARACTER_ROW); cout << " "; }
    int dmg = reducePlayerDamage(rand() % 3 + 8); player.hp -= dmg; if (player.hp < 0) player.hp = 0;
    enemyNormalAttackCount++;
}
void enemySasukeSkill1() {
    if (enemySkillInProgress || skillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < enemySkill1CDEnd) return; int d = abs(player.x - enemy.x); if (d > 8) return;
    enemySkillInProgress = true; enemySasukeAmaterasuActive = true; enemySasukeAmaterasuEnd = now + chrono::seconds(5);
    enemySasukeAmaterasuTick = now + chrono::milliseconds(500); enemySasukeAmaterasuHit = true;
    enemySkill1CDEnd = now + chrono::seconds(10); enemySkillInProgress = false;
}
void enemySasukeSkill2() {
    if (enemySkillInProgress || skillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < enemySkill2CDEnd) return;
    enemySkillInProgress = true; int tx = player.x + 5; if (tx >= MAP_WIDTH - 2) tx = MAP_WIDTH - 3; enemy.x = tx;
    int dmg = reducePlayerDamage(rand() % 7 + 12); player.hp -= dmg; if (player.hp < 0) player.hp = 0;
    enemySkill2CDEnd = now + chrono::seconds(8); enemySkillInProgress = false;
}
void enemySasukeUltimate() {
    if (enemySkillInProgress || skillInProgress) return; if (!enemySasukeSusanooActive) return; if (player.hp > 65) return;
    enemySkillInProgress = true; int tx = MAP_WIDTH - 5;
    while (enemy.x < tx) { enemy.x++; drawBattleMap(); this_thread::sleep_for(chrono::milliseconds(20)); }
    int d1 = reducePlayerDamage(rand() % 16 + 20); player.hp -= d1; if (player.hp < 0) player.hp = 0;
    this_thread::sleep_for(chrono::seconds(2)); player.hp -= reducePlayerDamage(45); if (player.hp < 0) player.hp = 0;
    enemySasukeSusanooActive = false; enemySasukeSusanooSlashCount = 0; enemySkillInProgress = false;
}

// ---------- 敌人泉奈 ----------
void enemyIzunaNormalAttack() {
    if (enemy.x <= player.x) return;
    auto now = chrono::steady_clock::now(); if (now < enemyIzunaSlashCD) return;
    enemyIzunaSlashActive = true; enemyIzunaSlashEnd = now + chrono::milliseconds(2000); enemyIzunaSlashCD = now + chrono::milliseconds(1500);
    int sx = enemy.x - 1, d = abs(player.x - enemy.x);
    for (int i = 0; i <= d; i++) { int cx = sx - i; if (cx <= player.x) break; if (i > 0) { int px = sx - (i - 1); if (px != player.x && px != enemy.x) { gotoxy(MAP_START_X + px, MAP_START_Y + CHARACTER_ROW); cout << " "; } } if (cx != player.x && cx != enemy.x) { gotoxy(MAP_START_X + cx, MAP_START_Y + CHARACTER_ROW); setColor(9); cout << ")"; } this_thread::sleep_for(chrono::milliseconds(30)); }
    int lx = sx - d; if (lx <= player.x) lx = player.x + 1; if (lx != player.x && lx != enemy.x) { gotoxy(MAP_START_X + lx, MAP_START_Y + CHARACTER_ROW); cout << " "; }
    int dmg = reducePlayerDamage(rand() % 3 + 8); player.hp -= dmg; if (player.hp < 0) player.hp = 0;
    enemyNormalAttackCount++;
}
void enemyIzunaSkill1() {
    if (enemySkillInProgress || skillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < enemySkill1CDEnd) return; int d = abs(player.x - enemy.x); if (d > 8) return;
    enemySkillInProgress = true; enemyIzunaFireballActive = true; enemyIzunaFireballEnd = now + chrono::milliseconds(1500);
    int cy = MAP_START_Y + CHARACTER_ROW;
    for (int i = 0; i < 8; i++) { int fx = enemy.x - 1 - i; if (fx > 0 && fx != player.x && fx != enemy.x) { gotoxy(MAP_START_X + fx, cy); setColor(12); cout << "-"; } this_thread::sleep_for(chrono::milliseconds(30)); }
    if (enemy.x - 7 > 0) { gotoxy(MAP_START_X + enemy.x - 7, cy); setColor(14); cout << "*"; }
    int dmg = reducePlayerDamage(rand() % 4 + 18); player.hp -= dmg; if (player.hp < 0) player.hp = 0;
    this_thread::sleep_for(chrono::milliseconds(500)); for (int i = 0; i < 8; i++) { int fx = enemy.x - 1 - i; if (fx > 0 && fx != player.x && fx != enemy.x) { gotoxy(MAP_START_X + fx, cy); cout << " "; } }
    enemyIzunaFireballActive = false; enemySkill1CDEnd = now + chrono::seconds(18); enemySkillInProgress = false;
}
void enemyIzunaSkill2() {
    if (enemySkillInProgress || skillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < enemySkill2CDEnd) return;
    enemySkillInProgress = true; int cy = MAP_START_Y + CHARACTER_ROW;
    enemyIzunaSwordActive = true; enemyIzunaSwordEnd = now + chrono::milliseconds(1000);
    for (int i = 0; i < 3; i++) { int sx = enemy.x - 1 - i; if (sx > 0 && sx != player.x && sx != enemy.x) { gotoxy(MAP_START_X + sx, cy); setColor(9); cout << "-"; } }
    int dmg = reducePlayerDamage(rand() % 5 + 20); player.hp -= dmg; if (player.hp < 0) player.hp = 0;
    enemySkill2CDEnd = now + chrono::seconds(20); enemySkillInProgress = false;
}
void enemyIzunaUltimate() {
    if (enemySkillInProgress || skillInProgress) return; if (player.hp > 70) return;
    enemySkillInProgress = true; int mx = MAP_WIDTH / 2; player.x = mx; int cy = MAP_START_Y + CHARACTER_ROW;
    for (int s = 0; s < 15; s++) { int ry = MAP_START_Y + s; for (int c = 0; c < MAP_WIDTH; c += 3) { if (c != enemy.x) { gotoxy(MAP_START_X + c, ry); setColor(12); cout << "|"; } if (c + 1 != enemy.x) { gotoxy(MAP_START_X + c + 1, ry); setColor(14); cout << "*"; } } this_thread::sleep_for(chrono::milliseconds(100)); if (s > 0) { int py = MAP_START_Y + s - 1; for (int c = 0; c < MAP_WIDTH; c += 3) { gotoxy(MAP_START_X + c, py); cout << " "; gotoxy(MAP_START_X + c + 1, py); cout << " "; } } }
    player.hp -= reducePlayerDamage(40); if (player.hp < 0) player.hp = 0;
    for (int i = 0; i < 3; i++) { int sx = enemy.x - 1 - i; if (sx > 0) { gotoxy(MAP_START_X + sx, cy); setColor(9); cout << "-"; } } this_thread::sleep_for(chrono::seconds(1));
    player.hp -= reducePlayerDamage(30); if (player.hp < 0) player.hp = 0;
    for (int i = 0; i < 3; i++) { int sx = enemy.x - 1 - i; if (sx > 0) { gotoxy(MAP_START_X + sx, cy); cout << " "; } }
    enemySkillInProgress = false;
}

// ---------- 敌人漂泊浪客(修改后) ----------
void enemyWandererNormalAttack() {
    if (skillInProgress || enemySkillInProgress || enemyWandererSpinActive || enemyWandererShockActive) return;
    auto now = chrono::steady_clock::now(); if (now < enemyWandererNormalCDEnd) return;
    for (int i = enemy.x - 1; i > player.x; i--) {
        gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); setColor(13); cout << ")";
        this_thread::sleep_for(chrono::milliseconds(15));
        if (i != player.x + 1) { gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); cout << " "; }
    }
    int dmg = reducePlayerDamage(rand() % 3 + 10); player.hp -= dmg; if (player.hp < 0) player.hp = 0;
    enemyWandererNormalCDEnd = now + chrono::milliseconds(300);
}
void enemyWandererSkill1() {
    if (enemyWandererShockActive) { enemyWandererShockActive = false; skillInProgress = false; }
    if (skillInProgress || enemySkillInProgress || enemyWandererSpinActive || enemyWandererShockActive) return;
    auto now = chrono::steady_clock::now(); if (now < enemyWandererSkill1CDEnd) return;
    enemySkillInProgress = true;
    for (int i = enemy.x - 1; i > player.x; i--) { gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); setColor(13); cout << "]"; this_thread::sleep_for(chrono::milliseconds(20)); if (i != player.x + 1) { gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); cout << " "; } }
    int dmg1 = reducePlayerDamage(rand() % 3 + 8); player.hp -= dmg1; if (player.hp < 0) player.hp = 0;
    this_thread::sleep_for(chrono::milliseconds(500));
    for (int i = enemy.x - 1; i > player.x; i--) { gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); setColor(13); cout << "}"; this_thread::sleep_for(chrono::milliseconds(20)); if (i != player.x + 1) { gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); cout << " "; } }
    int dmg2 = reducePlayerDamage(rand() % 4 + 12); player.hp -= dmg2; if (player.hp < 0) player.hp = 0;
    enemyWandererSkill1CDEnd = now + chrono::milliseconds(500);
    enemyWandererStateSwitchWindow = now + chrono::seconds(1);
    enemySkillInProgress = false;
}
void enemyWandererShortSkill2() {
    if (enemyWandererShockActive) { enemyWandererShockActive = false; skillInProgress = false; }
    if (skillInProgress || enemySkillInProgress || enemyWandererSpinActive || enemyWandererShockActive) return;
    if (enemyWandererShortSkill2Used || enemyWandererState != 0) return;
    enemySkillInProgress = true;
    for (int j = 0; j < 3; j++) {
        for (int i = enemy.x - 1; i > player.x; i--) { gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); setColor(13); cout << "]"; this_thread::sleep_for(chrono::milliseconds(10)); if (i != player.x + 1) { gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); cout << " "; } }
        int dmg = reducePlayerDamage(rand() % 5 + 12); player.hp -= dmg; if (player.hp < 0) player.hp = 0;
    }
    enemyWandererShortSkill2Used = true;
    enemyWandererShortSubSkillCDEnd = chrono::steady_clock::now() + chrono::seconds(5);
    enemySkillInProgress = false;
}
void enemyWandererShortSubSkill() {
    if (skillInProgress || enemySkillInProgress || !enemyWandererShortSkill2Used || enemyWandererState != 0) return;
    if (enemyWandererSpinActive) return;
    auto now = chrono::steady_clock::now();
    if (now < enemyWandererShortSubSkillCDEnd) return;
    enemyWandererSpinActive = true;
    enemyWandererSpinEnd = now + chrono::seconds(15);
    skillInProgress = true;
    // 传送玩家至正上方2格
    enemyWandererSpinEnemySavedX = player.x;
    enemyWandererSpinEnemyTransferred = true;
    player.x = enemy.x;
}
void enemyWandererLongSkill2() {
    if (enemyWandererShockActive) { enemyWandererShockActive = false; skillInProgress = false; }
    if (skillInProgress || enemySkillInProgress || enemyWandererSpinActive || enemyWandererShockActive) return;
    if (enemyWandererState != 1 || enemyWandererLongSkill2Count <= 0) return;
    auto now = chrono::steady_clock::now();
    if (now < enemyWandererLongSkill2CDEnd) return;
    enemyObitoKamuiActive = true; enemyObitoKamuiEnd = now + chrono::seconds(5);
    enemyWandererLongSkill2Count--;
    enemyWandererLongSkill2CDEnd = now + chrono::seconds(8);
}
void enemyWandererLongSubSkill() {
    if (skillInProgress || enemySkillInProgress || enemyWandererSpinActive || enemyWandererShockActive) return;
    if (enemyWandererState != 1) return;
    // 震刀距离判断
    int dist = player.x - enemy.x;
    if (dist < 1 || dist > 8) return;
    enemyWandererShockActive = true;
    enemyWandererShockEnemyY = CHARACTER_ROW - 5;
    skillInProgress = true;
    int dmg = reducePlayerDamage(rand() % 6 + 25);
    player.hp -= dmg; if (player.hp < 0) player.hp = 0;
    enemyWandererShockDropTime = chrono::steady_clock::now();
}
void enemyWandererUltimate() {
    if (enemyWandererShockActive) { enemyWandererShockActive = false; skillInProgress = false; }
    if (skillInProgress || enemySkillInProgress || enemyWandererSpinActive || enemyWandererShockActive) return;
    if (player.hp > 80) return;
    enemySkillInProgress = true; skillInProgress = true;
    int targetX = MAP_WIDTH / 2;
    while (enemy.x > targetX) enemy.x--;
    drawBattleMap();
    gotoxy(MAP_START_X + enemy.x - 3, MAP_START_Y + CHARACTER_ROW); setColor(13); cout << "------";
    this_thread::sleep_for(chrono::seconds(1));
    player.hp -= reducePlayerDamage(80); if (player.hp < 0) player.hp = 0;
    gotoxy(MAP_START_X + enemy.x - 3, MAP_START_Y + CHARACTER_ROW); cout << "  ";
    skillInProgress = false; enemySkillInProgress = false;
}
void enemyWandererSwitchState() {
    if (enemyWandererState == 0) enemyWandererState = 1;
    else enemyWandererState = 0;
}

// ---------- 敌人水门(修改后) ----------
void enemyMinatoNormalAttack() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now();
    if (now < enemyMinatoNormalCDEnd) return;
    for (int i = enemy.x - 1; i > player.x; i--) {
        gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); setColor(14); cout << "-";
        this_thread::sleep_for(chrono::milliseconds(20));
        gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); cout << " ";
    }
    int dmg = reducePlayerDamage(rand() % 3 + 8); // 8-10
    player.hp -= dmg; if (player.hp < 0) player.hp = 0;
    enemyMinatoNormalCDEnd = now + chrono::milliseconds(500);
}
void enemyMinatoSkill1() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < enemyMinatoSkill1CDEnd) return;
    enemySkillInProgress = true;
    enemy.x = player.x + 2; if (enemy.x > MAP_WIDTH - 2) enemy.x = MAP_WIDTH - 2;
    drawBattleMap();
    gotoxy(MAP_START_X + enemy.x - 1, MAP_START_Y + CHARACTER_ROW); setColor(14); cout << "〇";
    this_thread::sleep_for(chrono::milliseconds(800));
    int dmg = reducePlayerDamage(rand() % 7 + 18); player.hp -= dmg; if (player.hp < 0) player.hp = 0;
    gotoxy(MAP_START_X + enemy.x - 1, MAP_START_Y + CHARACTER_ROW); cout << " ";
    enemyMinatoSkill1CDEnd = now + chrono::seconds(15);
    enemySkillInProgress = false;
}
void enemyMinatoSkill2() {
    if (skillInProgress || enemySkillInProgress) return;
    auto now = chrono::steady_clock::now(); if (now < enemyMinatoSkill2CDEnd) return;
    if (!enemyMinatoMarkActive) {
        enemySkillInProgress = true;
        for (int i = enemy.x - 1; i > player.x; i--) {
            gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); setColor(14); cout << "-";
            this_thread::sleep_for(chrono::milliseconds(10));
            gotoxy(MAP_START_X + i, MAP_START_Y + CHARACTER_ROW); cout << " ";
        }
        enemyMinatoMarkActive = true; enemyMinatoMarkX = player.x; enemyMinatoMarkEnd = now + chrono::seconds(10);
        enemyMinatoCounterReady = true;
        enemySkillInProgress = false;
    }
    else if (enemyMinatoCounterReady) {
        skillInProgress = true;
        enemyMinatoSkill1();
        enemyMinatoCounterReady = false;
        enemyMinatoMarkActive = false;
    }
    enemyMinatoSkill2CDEnd = now + chrono::seconds(10);
}
void enemyMinatoUltimate() {
    if (skillInProgress || enemySkillInProgress) return;
    if (player.hp > 75) return;
    enemySkillInProgress = true; skillInProgress = true;
    gotoxy(MAP_START_X + player.x + 1, MAP_START_Y + CHARACTER_ROW); setColor(14); cout << "(0)";
    this_thread::sleep_for(chrono::seconds(2));
    int dmg = reducePlayerDamage(rand() % 6 + 75);
    player.hp -= dmg; if (player.hp < 0) player.hp = 0;
    gotoxy(MAP_START_X + player.x + 1, MAP_START_Y + CHARACTER_ROW); cout << "   ";
    skillInProgress = false; enemySkillInProgress = false;
}

// ==================== 敌人动作分发 ====================
void enemyNormalAttack() {
    if (enemyCharacterType == 0) enemyNarutoNormalAttack();
    else if (enemyCharacterType == 1) enemyPainNormalAttack();
    else if (enemyCharacterType == 2) enemyObitoNormalAttack();
    else if (enemyCharacterType == 3) enemyBorutoNormalAttack();
    else if (enemyCharacterType == 4) enemyHashiramaNormalAttack();
    else if (enemyCharacterType == 5) enemySasukeNormalAttack();
    else if (enemyCharacterType == 6) enemyIzunaNormalAttack();
    else if (enemyCharacterType == 8) enemyWandererNormalAttack();
    else if (enemyCharacterType == 9) enemyMinatoNormalAttack();
}
void enemySkill1() {
    if (enemyCharacterType == 0) enemyNarutoSkill1();
    else if (enemyCharacterType == 1) enemyPainSkill1();
    else if (enemyCharacterType == 2) enemyObitoSkill1();
    else if (enemyCharacterType == 3) enemyBorutoSkill1();
    else if (enemyCharacterType == 4) enemyHashiramaSkill1();
    else if (enemyCharacterType == 5) enemySasukeSkill1();
    else if (enemyCharacterType == 6) enemyIzunaSkill1();
    else if (enemyCharacterType == 8) enemyWandererSkill1();
    else if (enemyCharacterType == 9) enemyMinatoSkill1();
}
void enemySkill2() {
    if (enemyCharacterType == 0) enemyNarutoSkill2();
    else if (enemyCharacterType == 1) enemyPainSkill2();
    else if (enemyCharacterType == 2) enemyObitoSkill2();
    else if (enemyCharacterType == 3) enemyBorutoSkill2();
    else if (enemyCharacterType == 4) enemyHashiramaSkill2();
    else if (enemyCharacterType == 5) enemySasukeSkill2();
    else if (enemyCharacterType == 6) enemyIzunaSkill2();
    else if (enemyCharacterType == 8) { if (enemyWandererState == 0) enemyWandererShortSkill2(); else enemyWandererLongSkill2(); }
    else if (enemyCharacterType == 9) enemyMinatoSkill2();
}
void enemyUltimate() {
    if (enemyCharacterType == 0) enemyNarutoUltimate();
    else if (enemyCharacterType == 1) enemyPainUltimate();
    else if (enemyCharacterType == 2) enemyObitoUltimate();
    else if (enemyCharacterType == 3) enemyBorutoUltimate();
    else if (enemyCharacterType == 4) enemyHashiramaUltimate();
    else if (enemyCharacterType == 5) enemySasukeUltimate();
    else if (enemyCharacterType == 6) enemyIzunaUltimate();
    else if (enemyCharacterType == 8) enemyWandererUltimate();
    else if (enemyCharacterType == 9) enemyMinatoUltimate();
}

// ==================== AI ====================
void enemyAI() {
    if (playerRodHitting) { auto now = chrono::steady_clock::now(); if (now < playerRodHitEnd) return; else playerRodHitting = false; }
    if (playerBanshoTeninActive) { auto now = chrono::steady_clock::now(); if (now < playerBanshoTeninEnd) return; else playerBanshoTeninActive = false; }
    if (playerObitoEnemyTrapped) { auto now = chrono::steady_clock::now(); if (now < playerObitoEnemyTrappedEnd) return; else playerObitoEnemyTrapped = false; }
    if (playerHashiramaEnemyTrapped) { auto now = chrono::steady_clock::now(); if (now < playerHashiramaWoodDragonTrapEnd) return; else playerHashiramaEnemyTrapped = false; }
    if (playerSasukeAmaterasuHit) { auto now = chrono::steady_clock::now(); if (now < playerSasukeAmaterasuEnd) return; else playerSasukeAmaterasuHit = false; }
    if (playerIzunaCounterActive) { auto now = chrono::steady_clock::now(); if (now < playerIzunaCounterEnd) return; else playerIzunaCounterActive = false; }
    if (playerObitoEnemyInSpace) return;
    if (enemyObitoPlayerInSpace) return;
    if (enemyObitoEnemyTrapped) { auto now = chrono::steady_clock::now(); if (now < enemyObitoEnemyTrappedEnd) return; else enemyObitoEnemyTrapped = false; }
    if (enemyHashiramaEnemyTrapped) { auto now = chrono::steady_clock::now(); if (now < enemyHashiramaWoodDragonTrapEnd) return; else enemyHashiramaEnemyTrapped = false; }
    if (enemySasukeAmaterasuHit) { auto now = chrono::steady_clock::now(); if (now < enemySasukeAmaterasuEnd) return; else enemySasukeAmaterasuHit = false; }
    if (enemyIzunaCounterActive) { auto now = chrono::steady_clock::now(); if (now < enemyIzunaCounterEnd) return; else enemyIzunaCounterActive = false; }
    if (enemySkillInProgress || skillInProgress) return;
    if (playerShinraTenseiActive || enemyShinraTenseiActive) return;
    if (playerObitoKamuiActive && !playerObitoKamuiSpaceActive) return;
    if (playerWandererSpinActive) return;
    if (playerWandererShockActive) return;
    if (enemyWandererSpinActive || enemyWandererShockActive) return;
    auto now = chrono::steady_clock::now();
    int d = abs(player.x - enemy.x);
    double hr = (double)enemy.hp / enemy.maxHp;
    if (hr > 0.7) enemyAIMood = 0; else if (hr > 0.35) enemyAIMood = 1; else enemyAIMood = 2;
    bool s1 = (now >= enemySkill1CDEnd), s2 = (now >= enemySkill2CDEnd);
    int roll = rand() % 100;
    if (d <= 3) {
        if (s1 && roll < 30) { enemySkill1(); enemyConsecutiveSkills++; }
        else if (s2 && roll < 55) { enemySkill2(); enemyConsecutiveSkills++; }
        else if (roll < 80) { enemyNormalAttack(); enemyConsecutiveSkills = 0; }
        else { if (enemyAIMood == 0 && enemy.x < MAP_WIDTH - 3) enemy.x++; else if (enemyAIMood == 2 && enemy.x > player.x + 1) enemy.x--; enemyConsecutiveSkills = 0; }
    }
    else if (d <= 6) {
        if (s1 && roll < 40) { enemySkill1(); }
        else if (s2 && roll < 30) { enemySkill2(); }
        else if (enemy.x > player.x + 2) { enemy.x--; }
        enemyConsecutiveSkills = 0;
    }
    else {
        if (enemy.x > player.x + 3) { enemy.x--; }
        enemyConsecutiveSkills = 0;
    }
}

// ==================== 战斗主循环 ====================
bool battleLoop() {
    player.x = 10; enemy.x = MAP_WIDTH - 10;
    gameRunning = true; skillInProgress = false; enemySkillInProgress = false;
    playerShinraTenseiActive = false; playerShinraTenseiStack = 0; playerBanshoTeninActive = false;
    enemyShinraTenseiActive = false; enemyBanshoTeninActive = false;
    playerNarutoTailActive = false; enemyNarutoTailActive = false;
    playerPainRodActive = false; enemyPainRodActive = false; playerRodHitting = false; enemyRodHitting = false;
    playerObitoKickActive = false; playerObitoWoodSpikeActive = false; playerObitoEnemyTrapped = false;
    playerObitoKamuiActive = false; playerObitoKamuiSpaceActive = false; playerObitoEnemyInSpace = false;
    playerObitoFireActive = false; playerObitoWoodStormActive = false; playerObitoUltimateActive = false;
    enemyObitoKickActive = false; enemyObitoWoodSpikeActive = false; enemyObitoEnemyTrapped = false;
    enemyObitoKamuiActive = false; enemyObitoKamuiSpaceActive = false; enemyObitoPlayerInSpace = false;
    enemyObitoFireActive = false; enemyObitoWoodStormActive = false; enemyObitoUltimateActive = false;
    playerBorutoSwordActive = false; playerBorutoRasenganActive = false; playerBorutoMarkActive = false;
    playerBorutoTeleported = false; playerBorutoTeleportBack = false; playerBorutoKarmaActive = false; playerBorutoFlying = false;
    playerBorutoBigRasenganHit = false; playerBorutoEnhancedAttackCount = 0;
    enemyBorutoSwordActive = false; enemyBorutoRasenganActive = false; enemyBorutoMarkActive = false;
    enemyBorutoTeleported = false; enemyBorutoTeleportBack = false; enemyBorutoKarmaActive = false; enemyBorutoFlying = false;
    enemyBorutoEnhancedAttackCount = 0;
    playerHashiramaStompActive = false; playerHashiramaWoodDragonActive = false; playerHashiramaEnemyTrapped = false;
    playerHashiramaMyojinmonActive = false; playerHashiramaMyojinmonUsed = false;
    playerHashiramaWoodGolemActive = false; playerHashiramaWoodGolemAttackCount = 0;
    enemyHashiramaStompActive = false; enemyHashiramaWoodDragonActive = false; enemyHashiramaEnemyTrapped = false;
    enemyHashiramaMyojinmonActive = false; enemyHashiramaMyojinmonUsed = false;
    enemyHashiramaWoodGolemActive = false; enemyHashiramaWoodGolemAttackCount = 0;
    playerSasukeSlashActive = false; playerSasukeAmaterasuActive = false; playerSasukeAmaterasuHit = false;
    playerSasukeSusanooActive = false; playerSasukeSusanooSlashCount = 0; playerSasukeSusanooSlashActive = false;
    enemySasukeSlashActive = false; enemySasukeAmaterasuActive = false; enemySasukeAmaterasuHit = false;
    enemySasukeSusanooActive = false; enemySasukeSusanooSlashCount = 0; enemySasukeSusanooSlashActive = false;
    playerIzunaSlashActive = false; playerIzunaFireballActive = false; playerIzunaCounterActive = false; playerIzunaCounterTriggered = false;
    playerIzunaSwordActive = false; playerIzunaSword2ndUsed = false;
    enemyIzunaSlashActive = false; enemyIzunaFireballActive = false; enemyIzunaCounterActive = false; enemyIzunaCounterTriggered = false;
    enemyIzunaSwordActive = false;
    playerWandererState = 0; playerWandererShortSkill2Used = false; playerWandererLongSkill2Count = 2;
    playerWandererSpinActive = false; playerWandererShockActive = false;
    playerWandererSpinEnemyTransferred = false; playerWandererSpinEnemySavedX = 0;
    enemyWandererState = 0; enemyWandererShortSkill2Used = false; enemyWandererLongSkill2Count = 2;
    enemyWandererSpinActive = false; enemyWandererShockActive = false;
    enemyWandererSpinEnemyTransferred = false; enemyWandererSpinEnemySavedX = 0;
    playerMinatoKunaiActive = false; playerMinatoMarkActive = false; playerMinatoCounterReady = false;
    enemyMinatoKunaiActive = false; enemyMinatoMarkActive = false; enemyMinatoCounterReady = false;
    enemyPhase = 0; enemyNormalAttackCount = 0; enemyUltimateReady = false; enemyAIMood = 0; enemyConsecutiveSkills = 0;
    enemyStuckCounter = 0; enemyLastActionType = -1; enemyJustMoved = false;
    auto now = chrono::steady_clock::now();
    playerSkill1CDEnd = now; playerSkill2CDEnd = now; playerSkill3CDEnd = now;
    enemySkill1CDEnd = now; enemySkill2CDEnd = now; enemySkill3CDEnd = now;
    lastEnemyAction = now; enemyLastSkillTime = now;
    playerIzunaSlashCD = now; playerIzunaSword2ndWindow = now; playerSasukeSlashCD = now; playerSasukeSubSkillCD = now;
    enemyIzunaSlashCD = now; enemySasukeSlashCD = now; enemySasukeSubSkillCD = now;
    playerBlackZetsuNormalCDEnd = now;
    playerWandererNormalCDEnd = now; playerWandererSkill1CDEnd = now;
    playerWandererShortSubSkillCDEnd = now; playerWandererLongSkill2CDEnd = now; playerWandererLongSubSkillCDEnd = now;
    enemyWandererNormalCDEnd = now; enemyWandererSkill1CDEnd = now;
    enemyWandererShortSubSkillCDEnd = now; enemyWandererLongSkill2CDEnd = now; enemyWandererLongSubSkillCDEnd = now;
    playerMinatoNormalCDEnd = now; playerMinatoSkill1CDEnd = now; playerMinatoSkill2CDEnd = now; playerMinatoUltimateCDEnd = now;
    enemyMinatoNormalCDEnd = now; enemyMinatoSkill1CDEnd = now; enemyMinatoSkill2CDEnd = now; enemyMinatoUltimateCDEnd = now;

    while (gameRunning) {
        drawBattleMap();
        auto curTime = chrono::steady_clock::now();
        // 转刀持续伤害与结束处理
        if (playerWandererSpinActive) {
            if (curTime >= playerWandererSpinEnd) {
                playerWandererSpinActive = false;
                enemySkillInProgress = false;
                if (playerWandererSpinEnemyTransferred) {
                    enemy.x = player.x + 3;
                    if (enemy.x >= MAP_WIDTH - 2) enemy.x = MAP_WIDTH - 3;
                    playerWandererSpinEnemyTransferred = false;
                }
            }
            else {
                static chrono::steady_clock::time_point spinTick = curTime;
                if (chrono::duration_cast<chrono::milliseconds>(curTime - spinTick).count() >= 500) {
                    enemy.hp -= increasePlayerDamage(1); if (enemy.hp < 0) enemy.hp = 0;
                    spinTick = curTime;
                }
            }
        }
        if (enemyWandererSpinActive) {
            if (curTime >= enemyWandererSpinEnd) {
                enemyWandererSpinActive = false;
                skillInProgress = false;
                if (enemyWandererSpinEnemyTransferred) {
                    player.x = enemy.x - 3;
                    if (player.x < 2) player.x = 2;
                    enemyWandererSpinEnemyTransferred = false;
                }
            }
            else {
                static chrono::steady_clock::time_point eSpinTick = curTime;
                if (chrono::duration_cast<chrono::milliseconds>(curTime - eSpinTick).count() >= 500) {
                    player.hp -= reducePlayerDamage(1); if (player.hp < 0) player.hp = 0;
                    eSpinTick = curTime;
                }
            }
        }
        // 震刀下落处理
        if (playerWandererShockActive) {
            if (curTime >= playerWandererShockDropTime) {
                playerWandererShockDropTime = curTime + chrono::seconds(3);
                if (playerWandererShockEnemyY < CHARACTER_ROW) {
                    playerWandererShockEnemyY++;
                    if (playerWandererShockEnemyY >= CHARACTER_ROW) {
                        playerWandererShockActive = false;
                        enemySkillInProgress = false;
                    }
                }
            }
        }
        if (enemyWandererShockActive) {
            if (curTime >= enemyWandererShockDropTime) {
                enemyWandererShockDropTime = curTime + chrono::seconds(3);
                if (enemyWandererShockEnemyY < CHARACTER_ROW) {
                    enemyWandererShockEnemyY++;
                    if (enemyWandererShockEnemyY >= CHARACTER_ROW) {
                        enemyWandererShockActive = false;
                        skillInProgress = false;
                    }
                }
            }
        }
        // 神威虚化计时
        if (playerObitoKamuiActive && curTime >= playerObitoKamuiEnd) playerObitoKamuiActive = false;
        if (enemyObitoKamuiActive && curTime >= enemyObitoKamuiEnd) enemyObitoKamuiActive = false;
        // 飞雷神标记到期
        if (playerMinatoMarkActive && curTime >= playerMinatoMarkEnd) { playerMinatoMarkActive = false; playerMinatoCounterReady = false; }
        if (enemyMinatoMarkActive && curTime >= enemyMinatoMarkEnd) { enemyMinatoMarkActive = false; enemyMinatoCounterReady = false; }
        // 防反窗口检查
        if (playerIzunaCounterActive && !playerIzunaCounterTriggered && curTime >= playerIzunaCounterEnd) {
            playerIzunaCounterActive = false; playerSkill3CDEnd = curTime + chrono::seconds(25);
        }

        if (_kbhit()) {
            char key = _getch(); key = tolower(key);
            bool canMove = !skillInProgress && !playerShinraTenseiActive && !enemySkillInProgress && !playerIzunaCounterActive
                && !playerWandererSpinActive && !playerWandererShockActive && !enemyWandererSpinActive && !enemyWandererShockActive;
            bool canAct = (!skillInProgress && !enemySkillInProgress && !playerIzunaCounterActive) || playerBanshoTeninActive;
            if (canAct || (playerShinraTenseiActive && key == 'i') || (playerObitoKamuiActive && key == 'i')) {
                switch (key) {
                case 'a': if (canMove && player.x > 2 && player.x < enemy.x) player.x--; break;
                case 'd': if (canMove && player.x < MAP_WIDTH - 2 && player.x < enemy.x - 1) player.x++; break;
                case 'k':
                    if (!playerShinraTenseiActive && !playerObitoKamuiActive && !playerObitoKamuiSpaceActive) {
                        if (playerCharacterType == 8 && chrono::steady_clock::now() < playerWandererStateSwitchWindow) {
                            playerWandererSwitchState();
                        }
                        else {
                            playerNormalAttack();
                        }
                    }
                    break;
                case 'j': if (!playerShinraTenseiActive && !playerObitoKamuiSpaceActive) playerSkill1(); break;
                case 'i': if (!playerObitoKamuiSpaceActive) playerSkill2(); break;
                case 'o': if (!playerShinraTenseiActive && !playerObitoKamuiSpaceActive) playerUltimate(); break;
                case 'u': if (!playerShinraTenseiActive && !playerObitoKamuiSpaceActive) {
                    if (playerCharacterType == 5) playerSasukeSubSkill();
                    else if (playerCharacterType == 6) playerIzunaSubSkill();
                    else if (playerCharacterType == 8) {
                        if (playerWandererState == 0) playerWandererShortSubSkill();
                        else playerWandererLongSubSkill();
                    }
                } break;
                }
            }
            if (enemy.hp <= 0) { gameRunning = false; clearScreen(); gotoxy(35, 10); setColor(10); cout << "胜利!按任意键返回..."; _getch(); return true; }
            if (player.hp <= 0) {
                if (playerBlackZetsuCarrier) {
                    playerBlackZetsuCarrier = false;
                    player.name = "黑绝"; player.hp = 150; player.maxHp = 150;
                    player.characterType = 7;
                    playerSkill1CDEnd = playerSkill2CDEnd = playerSkill3CDEnd = chrono::steady_clock::now();
                    playerBlackZetsuNormalCDEnd = chrono::steady_clock::now();
                    continue;
                }
                gameRunning = false; clearScreen(); gotoxy(35, 10); setColor(12); cout << "失败!按任意键返回..."; _getch(); return false;
            }
        }
        auto ct = chrono::steady_clock::now();
        if (chrono::duration_cast<chrono::milliseconds>(ct - lastEnemyAction).count() >= 1500) {
            enemyAI(); lastEnemyAction = ct;
            if (player.hp <= 0) {
                if (playerBlackZetsuCarrier) {
                    playerBlackZetsuCarrier = false;
                    player.name = "黑绝"; player.hp = 150; player.maxHp = 150;
                    player.characterType = 7;
                    continue;
                }
                gameRunning = false; clearScreen(); gotoxy(35, 10); setColor(12); cout << "失败!按任意键返回..."; _getch(); return false;
            }
        }
        this_thread::sleep_for(chrono::milliseconds(30));
    }
    return false;
}

// ==================== 载体选择(黑绝载体界面改为普通选择界面) ====================
void selectCarrier() {
    vector<Character> chars = getAllCharacters();
    int selectedIndex = 0; bool selecting = true;
    while (selecting) {
        clearScreen(); hideCursor(); setColor(6);
        gotoxy(35, 2); cout << "=== 选择黑绝载体 ===";
        int row = 0, col = 0;
        for (int i = 0; i < chars.size(); i++) {
            if (!chars[i].available || chars[i].characterType == 7) continue;
            int x = 2 + col * 24; int y = 5 + row * 3;
            gotoxy(x, y);
            if (i == selectedIndex) { setColor(10); cout << "> "; }
            else { cout << "  "; }
            setColor(10); cout << chars[i].name;
            col++; if (col >= 5) { col = 0; row++; }
        }
        char key = _getch(); key = tolower(key);
        switch (key) {
        case 'w': if (selectedIndex >= 5) selectedIndex -= 5; break;
        case 's': if (selectedIndex + 5 < chars.size()) selectedIndex += 5; break;
        case 'a': if (selectedIndex > 0) selectedIndex--; break;
        case 'd': if (selectedIndex < chars.size() - 1) selectedIndex++; break;
        case 13:
            if (chars[selectedIndex].available && chars[selectedIndex].characterType != 7) {
                player = chars[selectedIndex]; player.maxHp = 300; player.hp = 300;
                playerCharacterType = player.characterType; playerBlackZetsuCarrier = true;
                selecting = false;
                vector<int> av; for (int i = 0; i < chars.size(); i++) if (chars[i].available) av.push_back(i);
                int ei; do { ei = av[rand() % av.size()]; } while (chars[ei].characterType == 7 && av.size() > 1);
                enemy = chars[ei]; enemy.maxHp = 300; enemy.hp = 300; enemyCharacterType = enemy.characterType;
                battleLoop();
            }
            break;
        }
    }
}

// ==================== 角色选择 ====================
void selectCharacter() {
    vector<Character> chars = getAllCharacters();
    int selectedIndex = 0; bool selecting = true;
    while (selecting) {
        drawSelectScreen(selectedIndex);
        char key = _getch(); key = tolower(key);
        switch (key) {
        case 'w': if (selectedIndex >= 5) selectedIndex -= 5; break;
        case 's': if (selectedIndex + 5 < chars.size()) selectedIndex += 5; break;
        case 'a': if (selectedIndex > 0) selectedIndex--; break;
        case 'd': if (selectedIndex < chars.size() - 1) selectedIndex++; break;
        case 13:
            if (chars[selectedIndex].available) {
                if (chars[selectedIndex].characterType == 7) { selectCarrier(); return; }
                player = chars[selectedIndex]; player.maxHp = 300; player.hp = 300;
                playerCharacterType = player.characterType; playerBlackZetsuCarrier = false;
                vector<int> av; for (int i = 0; i < chars.size(); i++) if (chars[i].available) av.push_back(i);
                int ei; do { ei = av[rand() % av.size()]; } while (ei == selectedIndex && av.size() > 1);
                enemy = chars[ei]; enemy.maxHp = 300; enemy.hp = 300; enemyCharacterType = enemy.characterType;
                selecting = false; battleLoop();
            }
            break;
        }
    }
}

// ==================== 启动界面 ====================
void launchScreen() {
    int selectedIndex = 0; bool launching = true;
    while (launching) {
        drawLaunchScreen(selectedIndex);
        char key = _getch(); key = tolower(key);
        switch (key) {
        case 'w': if (selectedIndex > 0) selectedIndex--; break;
        case 's': if (selectedIndex < 3) selectedIndex++; break;
        case 13:
            switch (selectedIndex) {
            case 0: launching = false; selectCharacter(); break;
            case 1: clearScreen(); gotoxy(35, 12); setColor(14); cout << "该模式暂未开启!"; _getch(); break;
            case 2: system("start https://blog.csdn.net/zhaozirui8290?spm=1000.2115.3001.5343"); break;
            case 3: clearScreen(); gotoxy(40, 12); setColor(12); cout << "感谢游玩!"; _getch(); exit(0);
            }
            break;
        }
    }
}

// ==================== 主函数 ====================
int main() {
    srand(time(nullptr)); hideCursor();
    system("mode con cols=120 lines=36");
    system("title 火影忍者");
    while (true) {
        drawStartScreen();
        while (true) { if (_kbhit()) { char key = _getch(); if (key == 13) { launchScreen(); break; } } }
    }
    return 0;
}
相关推荐
Sunsets_Red1 小时前
ABC462D 题解
c++·数学·编程·比赛·atcoder·信息学竞赛·信息学
keykey6.1 小时前
逻辑回归:从回归到分类
开发语言·人工智能·机器学习
shchojj1 小时前
ChatGPT Prompt Engineering for Developers - Expanding
开发语言·python·prompt
凡人叶枫1 小时前
Effective C++ 条款26:尽可能延后变量定义式的出现时间
linux·开发语言·c++·effective c++
加油码1 小时前
位图 BitMap:用一个 bit 管一个状态,空间直接省到位
c++·算法
四代水门1 小时前
LeetCode刷算法题(C++)
c++·算法·leetcode
problc2 小时前
用 JavaScript 打开中国的版式文档:@sharp9/ofdjs 诞生记
开发语言·javascript·ecmascript
devilnumber9 小时前
Java 递归算法 详解 + 核心要点 + 实战运用 + 避坑指南
java·开发语言·算法
unicrom_深圳市由你创科技10 小时前
哪些控制逻辑应该放在 PLC,哪些放在上位机?
c++