-
个人简介
surf dinosaur
发福利
错误
王子睿 孙孝轩 仇子辰 马致远 王侸 白先一 管理员 陈锡澍 高铭泽 王若霖
点开
你不配打开
一定要听到01:05
书
逐梦信奥
米
哪吒之魔童闹海影评:火焰披风与小海螺朋友
💖💖 💖💖 💖💖💖💖 💖💖💖💖 💖💖💖💖💖💖 💖💖💖💖💖💖 💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖 💖💖💖💖💖💖 💖💖💖💖 💖💖 💖禁盗!禁盗!禁盗!禁盗!禁盗! #include <iostream> #include <windows.h> #include <conio.h> #include <cmath> #include <cstdlib> #include <ctime> #include <cstring> using namespace std; // ================= 全局常量配置 ================= const int MAP_WIDTH = 40; // 地图宽 const int MAP_HEIGHT = 25; // 地图高 const int MAX_BULLETS = 500; // 最大子弹数量 // ================= 结构体定义 ================= struct Bullet { float x, y; // 坐标 float vx, vy; // 速度 int type; // 类型: 1=玩家子弹, 2=BOSS子弹 bool active; // 是否激活 }; struct Player { float x, y; int hp, maxHp; }; struct Boss { float x, y; int hp, maxHp; int pattern; // 当前攻击模式 int timer; // 攻击计时器 }; // ================= 全局变量 ================= Player player; Boss boss; Bullet bullets[MAX_BULLETS]; int bulletCount = 0; // 当前活跃子弹索引计数(简化管理,实际使用循环数组更好,这里用简单线性查找清理) // 游戏状态 bool isGameOver = false; bool isWin = false; int frameCount = 0; // ================= 辅助函数 ================= // 设置光标位置 void gotoxy(int x, int y) { COORD coord; coord.X = x; coord.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); } // 隐藏光标 void hideCursor() { CONSOLE_CURSOR_INFO cursorInfo; GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursorInfo); cursorInfo.bVisible = false; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursorInfo); } // 设置颜色 void setColor(int color) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color); } // 初始化游戏数据 void initGame() { // 初始化玩家 player.x = MAP_WIDTH / 2; player.y = MAP_HEIGHT - 2; player.hp = 100; player.maxHp = 100; // 初始化BOSS boss.x = MAP_WIDTH / 2; boss.y = 5; boss.hp = 500; boss.maxHp = 500; boss.pattern = 0; boss.timer = 0; // 初始化子弹 memset(bullets, 0, sizeof(bullets)); bulletCount = 0; // 这里我们用一个简单的列表管理,active为true表示存在 // 重置状态 isGameOver = false; isWin = false; frameCount = 0; // 设置窗口大小和标题 system("title Simple Console Shooter"); // 注意:mode命令可能在某些IDE中无效,但不影响运行 system("mode con cols=80 lines=30"); srand(time(0)); hideCursor(); } // ================= 核心逻辑 ================= // 生成子弹 void spawnBullet(float x, float y, float vx, float vy, int type) { // 寻找一个空闲位置 for (int i = 0; i < MAX_BULLETS; i++) { if (!bullets[i].active) { bullets[i].x = x; bullets[i].y = y; bullets[i].vx = vx; bullets[i].vy = vy; bullets[i].type = type; bullets[i].active = true; return; } } } // 更新玩家输入 void updatePlayerInput() { if (_kbhit()) { char key = _getch(); if (key == 'a' || key == 'A') player.x -= 1.5; if (key == 'd' || key == 'D') player.x += 1.5; if (key == 'w' || key == 'W') player.y -= 1.5; if (key == 's' || key == 'S') player.y += 1.5; if (key == ' ') { // 玩家射击 spawnBullet(player.x, player.y - 1, 0, -2.0, 1); } if (key == 27) { // ESC exit(0); } } // 边界限制 if (player.x < 1) player.x = 1; if (player.x > MAP_WIDTH - 2) player.x = MAP_WIDTH - 2; if (player.y < 1) player.y = 1; if (player.y > MAP_HEIGHT - 2) player.y = MAP_HEIGHT - 2; } // 更新BOSS逻辑 void updateBoss() { boss.timer++; // BOSS 简单移动 if (frameCount % 60 == 0) { boss.x += (rand() % 5 - 2); // 随机左右微动 if (boss.x < 5) boss.x = 5; if (boss.x > MAP_WIDTH - 5) boss.x = MAP_WIDTH - 5; } // BOSS 攻击模式 if (boss.timer > 30) { // 每30帧攻击一次 boss.timer = 0; int attackType = rand() % 3; if (attackType == 0) { // 直线向下 spawnBullet(boss.x, boss.y + 1, 0, 1.5, 2); } else if (attackType == 1) { // 散射 spawnBullet(boss.x, boss.y + 1, -0.5, 1.2, 2); spawnBullet(boss.x, boss.y + 1, 0, 1.5, 2); spawnBullet(boss.x, boss.y + 1, 0.5, 1.2, 2); } else { // 追踪弹 (简单计算方向) float dx = player.x - boss.x; float dy = player.y - boss.y; float dist = sqrt(dx*dx + dy*dy); if (dist > 0) { spawnBullet(boss.x, boss.y + 1, (dx/dist)*1.0, (dy/dist)*1.0, 2); } } } } // 更新子弹并检测碰撞 void updateBullets() { for (int i = 0; i < MAX_BULLETS; i++) { if (!bullets[i].active) continue; // 移动 bullets[i].x += bullets[i].vx; bullets[i].y += bullets[i].vy; // 边界检查:出界则销毁 if (bullets[i].x < 0 || bullets[i].x > MAP_WIDTH || bullets[i].y < 0 || bullets[i].y > MAP_HEIGHT) { bullets[i].active = false; continue; } // 碰撞检测 if (bullets[i].type == 1) { // 玩家子弹 -> 打BOSS float dx = bullets[i].x - boss.x; float dy = bullets[i].y - boss.y; if (sqrt(dx*dx + dy*dy) < 1.5) { boss.hp -= 10; bullets[i].active = false; // 子弹消失 if (boss.hp <= 0) { boss.hp = 0; isWin = true; } } } else if (bullets[i].type == 2) { // BOSS子弹 -> 打玩家 float dx = bullets[i].x - player.x; float dy = bullets[i].y - player.y; if (sqrt(dx*dx + dy*dy) < 1.0) { player.hp -= 10; bullets[i].active = false; // 子弹消失 if (player.hp <= 0) { player.hp = 0; isGameOver = true; } } } } } // 渲染画面 void render() { system("cls"); // 清屏 // 绘制边框 setColor(7); for (int i = 0; i <= MAP_WIDTH; i+=2) { gotoxy(i, 0); cout << "="; gotoxy(i, MAP_HEIGHT); cout << "="; } for (int i = 0; i <= MAP_HEIGHT; i++) { gotoxy(0, i); cout << "|"; gotoxy(MAP_WIDTH, i); cout << "|"; } // 绘制玩家 gotoxy((int)player.x * 2, (int)player.y); // X坐标乘2因为字符宽高比 setColor(10); // 绿色 cout << "A"; // 绘制BOSS if (boss.hp > 0) { gotoxy((int)boss.x * 2, (int)boss.y); setColor(12); // 红色 cout << "B"; } // 绘制子弹 for (int i = 0; i < MAX_BULLETS; i++) { if (bullets[i].active) { gotoxy((int)bullets[i].x * 2, (int)bullets[i].y); if (bullets[i].type == 1) { setColor(14); // 黄色 cout << "*"; } else { setColor(12); // 红色 cout << "o"; } } } // 绘制UI信息 gotoxy(0, MAP_HEIGHT + 2); setColor(7); cout << "Player HP: "; setColor(player.hp > 30 ? 10 : 12); for(int i=0; i<10; i++) { if(i < player.hp/10) cout << "|"; else cout << "."; } gotoxy(0, MAP_HEIGHT + 3); setColor(7); cout << "Boss HP: "; setColor(boss.hp > 0 ? 12 : 8); for(int i=0; i<10; i++) { if(i < boss.hp/50) cout << "|"; else cout << "."; } gotoxy(0, MAP_HEIGHT + 5); setColor(7); cout << "Controls: WASD Move, SPACE Shoot, ESC Exit"; } // ================= 主循环 ================= int main() { initGame(); while (!isGameOver && !isWin) { frameCount++; updatePlayerInput(); updateBoss(); updateBullets(); render(); Sleep(30); // 控制帧率,约30FPS } // 游戏结束画面 system("cls"); gotoxy(MAP_WIDTH/2 * 2 - 5, MAP_HEIGHT/2); if (isWin) { setColor(10); cout << "VICTORY! YOU WIN!"; } else { setColor(12); cout << "GAME OVER..."; } gotoxy(MAP_WIDTH/2 * 2 - 8, MAP_HEIGHT/2 + 2); setColor(7); cout << "Press any key to exit..."; _getch(); return 0; }非正版 禁盗!禁盗!禁盗!禁盗!禁盗! #include <iostream> #include <vector> #include <string> #include <cstdlib> #include <ctime> #include <windows.h> #include <conio.h> #include <algorithm> using namespace std; // 控制台工具函数 void SetColor(int color) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color); } void ClearScreen() { system("cls"); } void Pause(string msg = "按任意键继续...") { SetColor(7); cout << msg; _getch(); } // 卡牌结构体 struct Card { string name; string desc; int hpBonus; int atkBonus; int defBonus; int cdReduce; bool isExclusive; Card(string n, string d, int h=0, int a=0, int df=0, int c=0, bool ex=false) : name(n), desc(d), hpBonus(h), atkBonus(a), defBonus(df), cdReduce(c), isExclusive(ex) {} }; // 神符结构体 struct Rune { string name; string effect; int duration; Rune(string n, string e, int d) : name(n), effect(e), duration(d) {} }; // 英雄结构体 struct Hero { string name; int maxHp; int currentHp; int attack; int defense; string skillName; string skillDesc; int skillCdMax; int currentCd; bool isInBush; bool isOnBouncer; bool isStunned; bool isCritReady; // AI 难度参数 int aiAggression; // 攻击倾向 (0-100) int aiIntelligence; // 智能倾向 (0-100),决定是否会保留技能应对关键情况 Hero(string n, int mh, int atk, int def, string sn, string sd, int cd, int agg=50, int intel=50) : name(n), maxHp(mh), currentHp(mh), attack(atk), defense(def), skillName(sn), skillDesc(sd), skillCdMax(cd), currentCd(0), isInBush(false), isOnBouncer(false), isStunned(false), isCritReady(false), aiAggression(agg), aiIntelligence(intel) {} Hero() : maxHp(0), currentHp(0), attack(0), defense(0), skillCdMax(0), currentCd(0), isInBush(false), isOnBouncer(false), isStunned(false), isCritReady(false), aiAggression(50), aiIntelligence(50) {} int takeDamage(int dmg) { if (isStunned) return 0; if (isInBush) dmg = (int)(dmg * 0.8); int actualDmg = max(1, dmg - defense / 2); currentHp -= actualDmg; if (currentHp < 0) currentHp = 0; return actualDmg; } void heal(int amount) { currentHp += amount; if (currentHp > maxHp) currentHp = maxHp; } bool isAlive() const { return currentHp > 0; } double getHpPercent() const { if (maxHp == 0) return 0; return (double)currentHp / maxHp; } }; // 游戏主类 class FinalEggArena { private: Hero player; vector<Hero> bots; vector<Card> allCards; vector<Rune> allRunes; int roundCount; bool gameEnd; public: FinalEggArena() : roundCount(1), gameEnd(false) { srand(time(0)); initCards(); initRunes(); } void initCards() { allCards.push_back(Card("巨人之怒", "体型变大,生命值+20%,攻击力+10%", 20, 5, 0, 0)); allCards.push_back(Card("隐形鞋", "进入隐身状态,首次攻击必定暴击", 0, 5, 0, -1)); allCards.push_back(Card("急救包", "立即恢复30%最大生命值", 30, 0, 0, 0)); allCards.push_back(Card("冷却鞋", "技能冷却时间减少20%", 0, 0, 0, -2)); allCards.push_back(Card("荆棘甲", "受到攻击时反弹10%伤害", 10, 0, 5, 0)); allCards.push_back(Card("自然之友", "在草丛中每回合自动回复5点生命", 10, 0, 0, 0)); allCards.push_back(Card("草里藏刀", "草丛中暴击率提升至100%", 0, 8, 0, 0)); allCards.push_back(Card("渐入佳境", "普攻15次后伤害提升50%", 0, 10, 0, 0)); allCards.push_back(Card("殊死一搏", "生命值越低伤害越高", 0, 12, -5, 0)); allCards.push_back(Card("隆重谢幕", "生命值低于30%时原地爆炸", 0, 0, 0, 0)); allCards.push_back(Card("逆境求生", "生命值低于50%时获得20%吸血", 5, 5, 5, 0)); allCards.push_back(Card("引力炸弹", "吸附范围内敌人并造成范围伤害", 0, 12, 0, 0, true)); allCards.push_back(Card("高能激光", "穿透性直线范围伤害", 0, 18, -2, 0, true)); allCards.push_back(Card("律动节拍", "释放音波使敌人失控眩晕", 0, 10, 0, 0, true)); allCards.push_back(Card("咸鱼突刺", "手持咸鱼造成高额物理伤害", 0, 10, 0, 0, true)); } void initRunes() { allRunes.push_back(Rune("热血神符", "立即恢复20点生命值", 1)); allRunes.push_back(Rune("力量神符", "永久增加5点攻击力", 999)); allRunes.push_back(Rune("迅捷神符", "本回合技能无冷却", 1)); allRunes.push_back(Rune("隐身神符", "获得隐身效果,受击3次后破隐", 3)); allRunes.push_back(Rune("巨人体型神符", "体型变大,受击9次解除增益", 9)); allRunes.push_back(Rune("冷却缩减神符", "技能冷却大幅缩减,受击12次解除", 12)); } void selectHero() { ClearScreen(); SetColor(14); cout << "========================================" << endl; cout << " 蛋仔派对 超燃竞技场 " << endl; cout << "========================================" << endl; SetColor(7); cout << "\n请选择你的出战英雄:\n" << endl; cout << "1. 仔仔熊 HP:120 ATK:10 DEF:8 | 技能: 爱的抱抱" << endl; cout << "2. 失心熊 HP:100 ATK:14 DEF:4 | 技能: 失心索要" << endl; cout << "3. 小黄 HP:90 ATK:16 DEF:2 | 技能: 滚动" << endl; cout << "4. 小黑 HP:95 ATK:15 DEF:3 | 技能: 隐身" << endl; cout << "5. 魔鬼蛋 HP:105 ATK:13 DEF:5 | 技能: 过肩摔" << endl; cout << "6. 小红 HP:95 ATK:15 DEF:2 | 技能: 破刀式" << endl; cout << "7. 黑拳 HP:85 ATK:18 DEF:1 | 技能: 钢铁格挡&撼地重击" << endl; int choice; cout << "\n输入选择(1-7): "; cin >> choice; switch(choice) { case 1: player = Hero("仔仔熊", 120, 10, 8, "爱的抱抱", "给自己恢复生命值", 4); break; case 2: player = Hero("失心熊", 100, 14, 4, "失心索要", "控制敌人并在原地持续造成伤害", 3); break; case 3: player = Hero("小黄", 90, 16, 2, "滚动", "撞击敌人使其击退并造成伤害", 2); break; case 4: player = Hero("小黑", 95, 15, 3, "隐身", "进入隐身,下次普攻造成额外伤害", 3); break; case 5: player = Hero("魔鬼蛋", 105, 13, 5, "过肩摔", "眩晕敌人并造成高额伤害", 3); break; case 6: player = Hero("小红", 95, 15, 2, "破刀式", "发动强力的普通攻击", 3); break; case 7: player = Hero("黑拳", 85, 18, 1, "钢铁格挡&撼地重击", "免疫一次伤害并反击造成伤害", 2); break; default: player = Hero("仔仔熊", 120, 10, 8, "爱的抱抱", "给自己恢复生命值", 4); } // 初始化单个对手,增加难度:高攻击性,高智能 bots.clear(); bots.push_back(Hero("人机", 120, 14, 5, "致命连击", "连续攻击造成多段伤害", 3, 80, 90)); Pause("欢迎进入超燃竞技场!"); } void showBattleStatus() { ClearScreen(); SetColor(11); cout << "================ 第 " << roundCount << " 回合 ================" << endl; SetColor(7); SetColor(10); cout << "[玩家] " << player.name; if(player.isInBush) cout << " ??草丛中"; if(player.isOnBouncer) cout << " ??弹板上"; if(player.isStunned) cout << " ?眩晕中"; cout << endl; cout << "HP: " << player.currentHp << "/" << player.maxHp; cout << " | ATK: " << player.attack; cout << " | 技能CD: " << (player.currentCd > 0 ? to_string(player.currentCd) : "就绪") << endl; cout << "\n--- 敌方单位 ---" << endl; for(int i=0; i<bots.size(); i++) { if(bots[i].isAlive()) { SetColor(12); cout << "[敌人] " << bots[i].name; if(bots[i].isInBush) cout << " ??草丛中"; if(bots[i].isOnBouncer) cout << " ??弹板上"; if(bots[i].isStunned) cout << " ?眩晕中"; cout << " HP: " << bots[i].currentHp << "/" << bots[i].maxHp; cout << " | 技能CD: " << (bots[i].currentCd > 0 ? to_string(bots[i].currentCd) : "就绪") << endl; } else { SetColor(8); cout << "[敌人] " << bots[i].name << " 已淘汰" << endl; } } SetColor(7); } void playerAction() { showBattleStatus(); SetColor(14); cout << "\n>>> 行动选项 <<<" << endl; SetColor(7); cout << "1. 普通攻击" << endl; cout << "2. 使用技能: " << player.skillName << " (" << player.skillDesc << ")" << (player.currentCd > 0 ? " [冷却中]" : "") << endl; cout << "3. 进入草丛(减伤20%,下次攻击必定暴击)" << endl; cout << "4. 踩弹板(位移躲避,本回合免疫远程伤害)" << endl; int opt; cout << "请选择: "; cin >> opt; player.isInBush = false; player.isOnBouncer = false; if(opt == 3) { player.isInBush = true; player.isCritReady = true; cout << "你躲进了草丛,身形隐蔽,下次攻击必定暴击!" << endl; } else if(opt == 4) { player.isOnBouncer = true; cout << "你踩上弹板腾空而起,躲避所有远程攻击!" << endl; } else if(opt == 2 && player.currentCd <= 0 && !player.isStunned) { cout << "你释放了技能【" << player.skillName << "】!" << endl; if (player.name == "仔仔熊") { int healAmount = 30 + player.maxHp * 0.1; // 技能随成长增强 player.heal(healAmount); cout << "你使用了【爱的抱抱】,恢复了 " << healAmount << " 点生命值!" << endl; } else if (player.name == "失心熊") { for(auto& bot : bots) { if(bot.isAlive()) { bot.isStunned = true; int dmg = player.attack * 1.2; int actual = bot.takeDamage(dmg); cout << "对" << bot.name << "施加【失心索要】,造成" << actual << "点伤害并眩晕!" << endl; break; } } } else if (player.name == "小黄") { for(auto& bot : bots) { if(bot.isAlive()) { int dmg = player.attack * 1.5; int actual = bot.takeDamage(dmg); cout << "你使用【滚动】撞飞了" << bot.name << ",造成" << actual << "点伤害!" << endl; break; } } } else if (player.name == "小黑") { player.isCritReady = true; player.attack += 10; cout << "你进入【隐身】状态,下次攻击将造成额外伤害!" << endl; } else if (player.name == "魔鬼蛋") { for(auto& bot : bots) { if(bot.isAlive()) { bot.isStunned = true; int dmg = player.attack * 2; int actual = bot.takeDamage(dmg); cout << "你对" << bot.name << "使用【过肩摔】,造成" << actual << "点伤害并眩晕!" << endl; break; } } } else if (player.name == "小红") { for(auto& bot : bots) { if(bot.isAlive()) { int dmg = player.attack * 1.2; int actual = bot.takeDamage(dmg); cout << "你使用【破刀式】攻击" << bot.name << ",造成" << actual << "点伤害!" << endl; break; } } } else if (player.name == "黑拳") { player.defense += 20; for(auto& bot : bots) { if(bot.isAlive()) { int dmg = player.attack; int actual = bot.takeDamage(dmg); cout << "你使用【钢铁格挡&撼地重击】反击" << bot.name << ",造成" << actual << "点伤害!" << endl; break; } } } else { for(auto& bot : bots) { if(bot.isAlive()) { int skillDmg = (int)(player.attack * 1.5); int actual = bot.takeDamage(skillDmg); cout << "对" << bot.name << "造成" << actual << "点技能伤害!" << endl; break; } } } player.currentCd = player.skillCdMax + 1; } else { if(player.isStunned) { cout << "你处于眩晕状态,无法行动!" << endl; } else { for(auto& bot : bots) { if(bot.isAlive()) { int atkDmg = player.attack + rand()%3; if(player.isCritReady) { atkDmg *= 2; player.isCritReady = false; cout << "草丛暴击!"; } int actual = bot.takeDamage(atkDmg); cout << "你攻击了" << bot.name << ",造成" << actual << "点伤害!" << endl; break; } } } } Sleep(1500); } // 增强的AI逻辑 void botAction() { for(auto& bot : bots) { if(!bot.isAlive()) continue; // 状态检查 if(bot.isStunned) { bot.isStunned = false; cout << bot.name << "眩晕解除,恢复行动!" << endl; continue; } // AI 决策变量 bool willUseSkill = false; bool willDefend = false; bool willAttack = true; // 1. 防御决策 (智能倾向高时更倾向于保命) if (bot.getHpPercent() < 0.3 && bot.aiIntelligence > 60) { // 低血量尝试防御或躲避 if (rand() % 100 < bot.aiIntelligence) { if (rand() % 2 == 0) { bot.isInBush = true; bot.isCritReady = true; cout << bot.name << " 机智地躲入草丛寻求庇护!" << endl; willAttack = false; // 躲起来通常不攻击 } else { bot.isOnBouncer = true; cout << bot.name << " 踩上弹板规避伤害!" << endl; willAttack = false; } willDefend = true; } } // 2. 技能决策 if (bot.currentCd <= 0 && willAttack) { // 计算技能收益 bool isHealSkill = (bot.name.find("仔仔熊") != string::npos); bool isControlSkill = (bot.name.find("失心熊") != string::npos || bot.name.find("魔鬼蛋") != string::npos); // 高智能AI会根据局势判断 if (bot.aiIntelligence > 70) { if (isHealSkill && bot.getHpPercent() < 0.6) { willUseSkill = true; // 血少必奶 } else if (isControlSkill && player.getHpPercent() < 0.5) { willUseSkill = true; // 敌人血少必控杀 } else if (bot.aiAggression > 70) { willUseSkill = true; // 高攻击性,有技能就用 } } else { // 低智能AI随机使用 if (rand() % 100 < bot.aiAggression) { willUseSkill = true; } } } // 执行动作 if (willUseSkill && !willDefend) { cout << bot.name << " 释放了技能【" << bot.skillName << "】!" << endl; if (bot.name == "仔仔熊") { int healAmount = 30 + bot.maxHp * 0.1; bot.heal(healAmount); cout << bot.name << " 恢复了 " << healAmount << " 点生命值!" << endl; } else if (bot.name == "失心熊") { player.isStunned = true; int dmg = bot.attack; int actual = player.takeDamage(dmg); cout << "对你施加【失心索要】,造成" << actual << "点伤害并眩晕!" << endl; } else if (bot.name == "小黄") { int dmg = bot.attack * 1.5; int actual = player.takeDamage(dmg); cout << bot.name << " 使用【滚动】撞飞了你,造成" << actual << "点伤害!" << endl; } else if (bot.name == "小黑") { bot.isCritReady = true; bot.attack += 10; cout << bot.name << " 进入【隐身】状态!" << endl; } else if (bot.name == "魔鬼蛋") { player.isStunned = true; int dmg = bot.attack * 2; int actual = player.takeDamage(dmg); cout << bot.name << " 对你使用【过肩摔】,造成" << actual << "点伤害并眩晕!" << endl; } else if (bot.name == "小红") { int dmg = bot.attack * 1.2; int actual = player.takeDamage(dmg); cout << bot.name << " 使用【破刀式】攻击你,造成" << actual << "点伤害!" << endl; } else if (bot.name == "黑拳") { bot.defense += 20; int dmg = bot.attack; int actual = player.takeDamage(dmg); cout << bot.name << " 使用【钢铁格挡&撼地重击】反击,造成" << actual << "点伤害!" << endl; } else { // 默认技能 int skillDmg = (int)(bot.attack * 1.5); int actual = player.takeDamage(skillDmg); cout << bot.name << " 对你造成" << actual << "点技能伤害!" << endl; } bot.currentCd = bot.skillCdMax + 1; } else if (willAttack && !willDefend) { // 普通攻击 int dmg = bot.attack; // 暴击判定 if (bot.isCritReady) { dmg *= 2; bot.isCritReady = false; cout << bot.name << " 发动了暴击!"; } if (player.isOnBouncer && rand() % 3 == 0) { cout << bot.name << " 的攻击被你弹板躲避!" << endl; } else { int actual = player.takeDamage(dmg); cout << bot.name << " 普通攻击,造成" << actual << "点伤害!" << endl; } } else { cout << bot.name << " 采取了守势。" << endl; } // 清理临时状态 bot.isInBush = false; // 回合结束出草 bot.isOnBouncer = false; // 回合结束下板 bot.currentCd = max(0, bot.currentCd - 1); Sleep(800); } } void cardPick() { ClearScreen(); SetColor(13); cout << "\n>>> 卡牌补给站 <<<" << endl; SetColor(7); cout << "从3张卡牌中选择一张强化:\n" << endl; vector<Card> options; for(int i=0; i<3; i++) { options.push_back(allCards[rand() % allCards.size()]); } for(int i=0; i<3; i++) { cout << i+1 << ". 【" << options[i].name << "】" << endl; cout << " 效果: " << options[i].desc << endl; } int pick; cout << "\n选择卡牌(1-3): "; cin >> pick; if(pick <1 || pick>3) pick =1; Card selected = options[pick-1]; player.maxHp += selected.hpBonus; player.currentHp += selected.hpBonus; player.attack += selected.atkBonus; player.defense += selected.defBonus; player.skillCdMax = max(1, player.skillCdMax + selected.cdReduce); cout << "获得卡牌【" << selected.name << "】,强化完成!" << endl; Sleep(1000); } void runeEvent() { if(rand()%10 < 3) { Rune r = allRunes[rand() % allRunes.size()]; ClearScreen(); SetColor(13); cout << "\n? 神符刷新: 【" << r.name << "】" << endl; SetColor(7); cout << "效果: " << r.effect << endl; char opt; cout << "是否拾取(y/n): "; cin >> opt; if(opt == 'y' || opt == 'Y') { if(r.name == "热血神符") player.heal(20); if(r.name == "力量神符") player.attack +=5; if(r.name == "迅捷神符") player.currentCd =0; cout << "成功拾取神符【" << r.name << "】!" << endl; } Pause(); } } void checkWinLose() { bool allBotDead = true; for(auto& bot : bots) { if(bot.isAlive()) allBotDead = false; } if(!player.isAlive()) { gameEnd = true; ClearScreen(); SetColor(12); cout << "\n========================================" << endl; cout << " 你被淘汰了,本局结束! " << endl; cout << "========================================" << endl; } else if(allBotDead) { gameEnd = true; ClearScreen(); SetColor(10); cout << "\n========================================" << endl; cout << " 恭喜你获得超燃竞技场胜利! " << endl; cout << "========================================" << endl; } } void runGame() { selectHero(); while(!gameEnd) { runeEvent(); cardPick(); playerAction(); checkWinLose(); if(gameEnd) break; botAction(); player.currentCd = max(0, player.currentCd - 1); roundCount++; } Pause("游戏结束,感谢游玩!"); } }; int main() { FinalEggArena game; game.runGame(); return 0; }禁盗!禁盗!禁盗!禁盗!禁盗! #include<bits/stdc++.h> #include <windows.h> using namespace std; struct IDname { int cnt; string name; } roleCfg[100]; struct Player { int id; bool alive; string role; int know; int dieReason; } player[21]; struct Vote { int voteCnt; int id; bool canVote; } voteArr[13]; int n; int mySelf; int killWolf; int killPoison; char op; bool hasCure = true; bool hasPoison = true; int hunterId = 0; int guardId = 0; int guardTarget = 0; bool hunterShot = false; int randSeedArr[10] = {7,4,6,43,35,1,2,8,20,19}; void initRoleBase(); void setRoleCount(int num); void randomAssignRole(int idx); bool cmpVoteDesc(Vote a, Vote b); bool cmpVoteIdAsc(Vote a, Vote b); void printGameUI(int day, bool isNight); void guardSleep(int day, bool isNight); void voteProcess(int day, bool isNight); bool checkGameOver(); void nightFirstRound(); void nightLoop(int day, bool isNight); void hunterShoot(); void printDeadNotice(); void showGameResult(); void initRoleBase() { roleCfg[1].name = "村民 "; roleCfg[2].name = "狼人 "; roleCfg[3].name = "女巫 "; roleCfg[4].name = "预言家 "; roleCfg[5].name = "猎人 "; roleCfg[6].name = "守卫 "; } void setRoleCount(int num) { for(int i = 1; i <= 6; i++) roleCfg[i].cnt = 0; switch(num) { case 6: roleCfg[1].cnt = 3; roleCfg[2].cnt = 2; break; case 7: roleCfg[1].cnt = 3; roleCfg[2].cnt = 2; roleCfg[3].cnt = 1; roleCfg[4].cnt = 1; break; case 8: roleCfg[1].cnt = 3; roleCfg[2].cnt = 3; roleCfg[3].cnt = 1; roleCfg[4].cnt = 1; break; case 9: roleCfg[1].cnt = 3; roleCfg[2].cnt = 3; roleCfg[3].cnt = 1; roleCfg[4].cnt = 1; roleCfg[5].cnt = 1; break; case 10: roleCfg[1].cnt = 4; roleCfg[2].cnt = 3; roleCfg[3].cnt = 1; roleCfg[4].cnt = 1; roleCfg[5].cnt = 1; break; case 11: roleCfg[1].cnt = 4; roleCfg[2].cnt = 4; roleCfg[3].cnt = 1; roleCfg[4].cnt = 1; roleCfg[5].cnt = 1; break; case 12: roleCfg[1].cnt = 4; roleCfg[2].cnt = 4; roleCfg[3].cnt = 1; roleCfg[4].cnt = 1; roleCfg[5].cnt = 1; roleCfg[6].cnt = 1; break; default: cout << "人数输入错误,程序退出!" << endl; system("pause"); exit(0); } } void randomAssignRole(int idx) { srand((unsigned)time(0)); Sleep(rand() % 44); int base = 10000; int t = rand(); int y = randSeedArr[(rand() % 100 + t) % 10]; int selRole; if(n <= 6) selRole = abs(base * 6 / y) % 3 + 1; else if(n <= 8) selRole = abs(base * 7 / y) % 4 + 1; else if(n <= 11) selRole = abs(base * 8 / y) % 5 + 1; else selRole = abs(base * 9 / y) % 6 + 1; while(true) { if(n <= 6) selRole = selRole % 3 + 1; else if(n <= 8) selRole = selRole % 4 + 1; else if(n <= 11) selRole = selRole % 5 + 1; else selRole = selRole % 6 + 1; if(roleCfg[selRole].cnt > 0) break; } player[idx].role = roleCfg[selRole].name; player[idx].alive = true; player[idx].id = idx; player[idx].know = 0; player[idx].dieReason = 0; roleCfg[selRole].cnt--; if(player[idx].role == "猎人 ") hunterId = idx; if(player[idx].role == "守卫 ") guardId = idx; } bool cmpVoteDesc(Vote a, Vote b) { if(a.voteCnt != b.voteCnt) return a.voteCnt > b.voteCnt; return a.id < b.id; } bool cmpVoteIdAsc(Vote a, Vote b) { return a.id < b.id; } void printGameUI(int day, bool isNight) { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); if(isNight) SetConsoleTextAttribute(hConsole, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY); else SetConsoleTextAttribute(hConsole, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); cout << "\t\t\t\t第" << day << "天 "; if(isNight) cout << "夜晚" << endl; else cout << "白天" << endl; cout << "你的座位:" << mySelf << "号" << endl << endl; // 1~6号玩家 cout << "1-6号位:"; for(int i = 1; i <= 6; i++) cout << player[i].id << "号\t"; cout << "\n存活状态:"; for(int i = 1; i <= 6; i++) { if(player[i].alive) SetConsoleTextAttribute(hConsole, isNight ? (BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|FOREGROUND_INTENSITY|FOREGROUND_GREEN) : (FOREGROUND_INTENSITY|FOREGROUND_GREEN)); else SetConsoleTextAttribute(hConsole, isNight ? (BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|FOREGROUND_INTENSITY|FOREGROUND_RED) : (FOREGROUND_INTENSITY|FOREGROUND_RED)); cout << (player[i].alive ? "存活\t" : "死亡\t"); } SetConsoleTextAttribute(hConsole, isNight ? (BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|FOREGROUND_INTENSITY) : (FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE)); cout << "\n身份信息:"; for(int i = 1; i <= 6; i++) { if(player[i].know == 0) cout << "未知\t"; else if(player[i].know == 1) cout << (player[i].role == "狼人 " ? "狼人\t" : "好人\t"); else cout << player[i].role << "\t"; } cout << "\n\n"; // 7~n号玩家 if(n >= 7) { cout << "7-" << n << "号位:"; for(int i = 7; i <= n; i++) cout << player[i].id << "号\t"; cout << "\n存活状态:"; for(int i = 7; i <= n; i++) { if(player[i].alive) SetConsoleTextAttribute(hConsole, isNight ? (BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|FOREGROUND_INTENSITY|FOREGROUND_GREEN) : (FOREGROUND_INTENSITY|FOREGROUND_GREEN)); else SetConsoleTextAttribute(hConsole, isNight ? (BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|FOREGROUND_INTENSITY|FOREGROUND_RED) : (FOREGROUND_INTENSITY|FOREGROUND_RED)); cout << (player[i].alive ? "存活\t" : "死亡\t"); } SetConsoleTextAttribute(hConsole, isNight ? (BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|FOREGROUND_INTENSITY) : (FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE)); cout << "\n身份信息:"; for(int i = 7; i <= n; i++) { if(player[i].know == 0) cout << "未知\t"; else if(player[i].know == 1) cout << (player[i].role == "狼人 " ? "狼人\t" : "好人\t"); else cout << player[i].role << "\t"; } cout << "\n\n"; } } // ====================== 守卫夜间守护流程 ====================== void guardSleep(int day, bool isNight) { Sleep(3000); system("cls"); printGameUI(day, isNight); cout << "守~卫~请~睁~眼~~~\n"; Sleep(3000); system("cls"); printGameUI(day, isNight); int tar; // 玩家自己是守卫 if(mySelf == guardId && player[mySelf].alive) { cout << "请输入今晚要守护的玩家编号:"; cin >> tar; while(tar == guardTarget || tar < 1 || tar > n || !player[tar].alive) { cout << "输入非法,请重新输入:"; cin >> tar; } guardTarget = tar; } // AI守卫 else if(player[guardId].alive) { do { srand((unsigned)time(0)); tar = rand() % n + 1; } while(tar == guardTarget || !player[tar].alive); guardTarget = tar; } // 无守卫/守卫已死 else guardTarget = -1; Sleep(3000); system("cls"); printGameUI(day, isNight); cout << "守~卫~请~闭~眼~~~\n"; } // ====================== 白天投票流程(最多三轮平票) ====================== void voteProcess(int day, bool isNight) { Sleep(2000); system("cls"); printGameUI(day, isNight); cout << "开始投票"; for(int i = 1; i <= 3; i++) { cout << "."; Sleep(500); } cout << endl; // 初始化投票数据 for(int i = 1; i <= n; i++) { voteArr[i].id = i; voteArr[i].canVote = true; voteArr[i].voteCnt = 0; } // ========== 第一轮投票 ========== for(int i = 1; i <= n; i++) { if(!player[i].alive) continue; Sleep(3000); int tar; if(i == mySelf) { cout << "请投票(输入0弃权):"; cin >> tar; while(tar != 0 && !player[tar].alive) cin >> tar; if(tar == 0) cout << mySelf << "号弃权\n"; else { cout << mySelf << "投给" << tar << "号\n"; voteArr[tar].voteCnt++; } } else { srand((unsigned)time(0)); // 狼人优先投好人 if(player[i].role == "狼人 ") { do { tar = rand() % (n + 1); } while(tar != 0 && (!player[tar].alive || player[tar].role == "狼人 " || tar == i)); } // 预言家优先投狼 else if(player[i].role == "预言家 ") { do { tar = rand() % (n + 1); } while(tar != 0 && (!player[tar].alive || player[tar].role != "狼人 " || tar == i)); } // 村民随机投 else { do { tar = rand() % (n + 1); } while(tar != 0 && (!player[tar].alive || tar == i)); } if(tar == 0) cout << i << "号弃权\n"; else { cout << i << "投给" << tar << "号\n"; voteArr[tar].voteCnt++; } } } Sleep(3000); sort(voteArr + 1, voteArr + n + 1, cmpVoteDesc); // 无平票直接出局 if(voteArr[1].voteCnt > voteArr[2].voteCnt) { int out = voteArr[1].id; cout << "投票结束," << out << "号被投票出局!\n"; player[out].alive = false; player[out].dieReason = 2; Sleep(3000); return; } // 标记平票玩家本轮无投票权 int maxVote = voteArr[1].voteCnt; for(int i = 1; i <= n; i++) { if(voteArr[i].voteCnt == maxVote) voteArr[i].canVote = false; else break; } system("cls"); printGameUI(day, isNight); cout << "平票!进入第二轮投票\n"; // ========== 第二轮投票 ========== sort(voteArr + 1, voteArr + n + 1, cmpVoteIdAsc); cout << "二次投票"; for(int i = 1; i <= 3; i++) { cout << "."; Sleep(500); } cout << endl; for(int i = 1; i <= n; i++) { if(!player[i].alive || !voteArr[i].canVote) continue; Sleep(3000); int tar; if(i == mySelf) { cout << "请投票(0弃权):"; cin >> tar; while(tar != 0 && (!player[tar].alive || !voteArr[tar].canVote)) cin >> tar; if(tar != 0) voteArr[tar].voteCnt++; } else { srand((unsigned)time(0)); if(player[i].role == "狼人 ") { do { tar = rand() % (n + 1); } while(tar != 0 && (!player[tar].alive || player[tar].role == "狼人 " || tar == i || !voteArr[tar].canVote)); } else if(player[i].role == "预言家 ") { do { tar = rand() % (n + 1); } while(tar != 0 && (!player[tar].alive || player[tar].role != "狼人 " || tar == i || !voteArr[tar].canVote)); } else { do { tar = rand() % (n + 1); } while(tar != 0 && (!player[tar].alive || tar == i || !voteArr[tar].canVote)); } if(tar != 0) voteArr[tar].voteCnt++; } } Sleep(3000); sort(voteArr + 1, voteArr + n + 1, cmpVoteDesc); if(voteArr[1].voteCnt > voteArr[2].voteCnt) { int out = voteArr[1].id; cout << "投票结束," << out << "号被投票出局!\n"; player[out].alive = false; player[out].dieReason = 2; Sleep(3000); return; } // 再次标记平票 maxVote = voteArr[1].voteCnt; for(int i = 1; i <= n; i++) { if(voteArr[i].voteCnt == maxVote) voteArr[i].canVote = false; else break; } system("cls"); printGameUI(day, isNight); cout << "再次平票!第三轮投票\n"; // ========== 第三轮投票 ========== sort(voteArr + 1, voteArr + n + 1, cmpVoteIdAsc); cout << "最终投票"; for(int i = 1; i <= 3; i++) { cout << "."; Sleep(500); } cout << endl; for(int i = 1; i <= n; i++) { if(!player[i].alive || !voteArr[i].canVote) continue; Sleep(3000); int tar; if(i == mySelf) { cout << "请投票(0弃权):"; cin >> tar; while(tar != 0 && (!player[tar].alive || !voteArr[tar].canVote)) cin >> tar; if(tar != 0) voteArr[tar].voteCnt++; } else { srand((unsigned)time(0)); if(player[i].role == "狼人 ") { do { tar = rand() % (n + 1); } while(tar != 0 && (!player[tar].alive || player[tar].role == "狼人 " || tar == i || !voteArr[tar].canVote)); } else if(player[i].role == "预言家 " || player[i].role == "猎人 ") { do { tar = rand() % (n + 1); } while(tar != 0 && (!player[tar].alive || player[tar].role != "狼人 " || tar == i || !voteArr[tar].canVote)); } else { do { tar = rand() % (n + 1); } while(tar != 0 && (!player[tar].alive || tar == i || !voteArr[tar].canVote)); } if(tar != 0) voteArr[tar].voteCnt++; } } Sleep(3000); sort(voteArr + 1, voteArr + n + 1, cmpVoteDesc); if(voteArr[1].voteCnt > voteArr[2].voteCnt) { int out = voteArr[1].id; cout << "投票结束," << out << "号被投票出局!\n"; player[out].alive = false; player[out].dieReason = 2; } else { cout << "三轮投票全部平票,无人出局\n"; } Sleep(5000); } // ====================== 判断游戏是否结束 ====================== bool checkGameOver() { int villager = 0; // 存活村民 int wolf = 0; // 存活狼人 int god = 0; // 存活神(女巫/预言/猎人/守卫) for(int i = 1; i <= n; i++) { if(!player[i].alive) continue; if(player[i].role == "狼人 ") wolf++; else if(player[i].role == "村民 ") villager++; else god++; } // 好人全灭 / 狼人数量>=好人直接胜利 if(god == 0 || wolf == 0 || wolf >= villager + god) return true; return false; } // ====================== 第一晚夜晚流程(无前日数据) ====================== void nightFirstRound() { system("cls"); system("color 0f"); printGameUI(1, true); cout << "天~黑~请~闭~眼~~~\n"; guardTarget = 0; if(n >= 12) guardSleep(1, true); Sleep(3000); // 狼人行动 system("cls"); printGameUI(1, true); cout << "狼~人~请~睁~眼~~~\n"; if(player[mySelf].role == "狼人 ") { Sleep(1000); cout << "你的狼队友:"; for(int i = 1; i <= n; i++) { if(i == mySelf) continue; if(player[i].role == "狼人 ") { cout << i << "号 "; player[i].know = 2; } } Sleep(3000); cout << "\n输入今晚刀人目标:"; cin >> killWolf; system("cls"); printGameUI(1, true); cout << "今晚击杀目标:" << killWolf << "号\n"; } else { Sleep(4000); // AI狼人随机刀好人 do { srand((unsigned)time(0)); killWolf = rand() % n + 1; } while(player[killWolf].role == "狼人 " || !player[killWolf].alive); Sleep(5000); } Sleep(3000); system("cls"); printGameUI(1, true); cout << "狼~人~请~闭~眼~~~\n"; Sleep(2000); // 女巫行动 system("cls"); printGameUI(1, true); cout << "女~巫~请~睁~眼~~~\n"; Sleep(2000); system("cls"); printGameUI(1, true); killPoison = 0; int witchId = 0; for(int i = 1; i <= n; i++) if(player[i].role == "女巫 ") witchId = i; if(player[mySelf].role == "女巫 " && player[mySelf].alive) { Sleep(1000); if(hasCure) { cout << "今晚" << killWolf << "号中刀\n是否使用解药?A救/B不救:"; cin >> op; if(op == 'A') { cout << "你解救了" << killWolf << "号\n"; hasCure = false; if(guardTarget != killWolf) killWolf = 0; // 询问毒药 Sleep(2000); system("cls"); printGameUI(1, true); cout << "是否使用毒药?A毒/B不毒:"; cin >> op; if(op == 'A' && hasPoison) { cout << "输入毒杀目标:"; cin >> killPoison; while(!player[killPoison].alive) { cin >> killPoison; } hasPoison = false; } } else { if(guardTarget == killWolf) killWolf = 0; Sleep(2000); system("cls"); printGameUI(1, true); cout << "是否使用毒药?A毒/B不毒:"; cin >> op; if(op == 'A' && hasPoison) { cout << "输入毒杀目标:"; cin >> killPoison; while(!player[killPoison].alive) { cin >> killPoison; } hasPoison = false; } } } else { if(guardTarget == killWolf) killWolf = 0; Sleep(2000); system("cls"); printGameUI(1, true); cout << "是否使用毒药?A毒/B不毒:"; cin >> op; if(op == 'A' && hasPoison) { cout << "输入毒杀目标:"; cin >> killPoison; while(!player[killPoison].alive) { cin >> killPoison; } hasPoison = false; } } } else { // AI女巫逻辑 bool useCure = false; if(hasCure && player[witchId].alive) { // 优先救神 if(player[killWolf].role == "预言家 " || player[killWolf].role == "女巫 " || player[killWolf].role == "猎人 ") { if(guardTarget != killWolf) { killWolf = 0; hasCure = false; useCure = true; } } } // 有药随机毒好人 if(!useCure && hasPoison && player[witchId].alive) { srand((unsigned)time(0)); if(rand() % 2 == 1) { do { killPoison = rand() % n + 1; } while(player[killPoison].role == "女巫 " || player[killPoison].role == "预言家 " || killPoison == killWolf || !player[killPoison].alive); hasPoison = false; } } } Sleep(3000); system("cls"); printGameUI(1, true); cout << "女~巫~请~闭~眼~~~\n"; // 预言家行动(6人局无预言家) if(n > 6) { Sleep(3000); system("cls"); printGameUI(1, true); cout << "预~言~家~请~睁~眼~~~\n"; if(player[mySelf].role == "预言家 ") { Sleep(3000); int check; cout << "输入查验玩家编号:"; cin >> check; player[check].know = 1; Sleep(2000); system("cls"); printGameUI(1, true); cout << "该玩家身份:" << (player[check].role == "狼人 " ? "狼人" : "好人") << "\n"; } else { Sleep(3000); cout << "AI预言家查验中...\n"; } Sleep(3000); system("cls"); printGameUI(1, true); cout << "预~言~家~请~闭~眼~~~\n"; } Sleep(3000); // 结算死亡 if(killWolf != 0) { player[killWolf].alive = false; player[killWolf].dieReason = 1; } if(killPoison != 0) { player[killPoison].alive = false; player[killPoison].dieReason = 3; } system("cls"); system("color F0"); printGameUI(2, false); } // ====================== 通用夜晚流程(第二晚及以后) ====================== void nightLoop(int day, bool isNight) { system("cls"); system("color 0f"); printGameUI(day, true); cout << "天~黑~请~闭~眼~~~\n"; guardTarget = 0; if(n >= 12) guardSleep(day, true); Sleep(3000); // 狼人刀人 system("cls"); printGameUI(day, true); cout << "狼~人~请~睁~眼~~~\n"; if(player[mySelf].role == "狼人 " && player[mySelf].alive) { Sleep(3000); cout << "输入刀人目标:"; cin >> killWolf; system("cls"); printGameUI(day, true); cout << "今晚击杀:" << killWolf << "号\n"; } else { do { srand((unsigned)time(0)); killWolf = rand() % n + 1; } while(player[killWolf].role == "狼人 " || !player[killWolf].alive); Sleep(5000); } Sleep(3000); system("cls"); printGameUI(day, true); cout << "狼~人~请~闭~眼~~~\n"; Sleep(2000); // 女巫 system("cls"); printGameUI(day, true); cout << "女~巫~请~睁~眼~~~\n"; Sleep(2000); system("cls"); printGameUI(day, true); killPoison = 0; int witchId = 0; for(int i = 1; i <= n; i++) if(player[i].role == "女巫 ") witchId = i; if(player[mySelf].role == "女巫 " && player[mySelf].alive) { if(hasCure) { cout << killWolf << "号中刀,解药A救/B不救:"; cin >> op; if(op == 'A') { hasCure = false; if(guardTarget != killWolf) killWolf = 0; } else { if(guardTarget == killWolf) killWolf = 0; } } else { if(guardTarget == killWolf) killWolf = 0; } if(hasPoison) { cout << "是否毒人?A毒/B不毒:"; cin >> op; if(op == 'A') { cout << "输入毒目标:"; cin >> killPoison; while(!player[killPoison].alive) cin >> killPoison; hasPoison = false; } } } else { bool useCure = false; if(hasCure && player[witchId].alive) { if(player[killWolf].role == "预言家 " || player[killWolf].role == "猎人 ") { if(guardTarget != killWolf) { killWolf = 0; hasCure = false; useCure = true; } } } if(!useCure && hasPoison && player[witchId].alive) { srand((unsigned)time(0)); if(rand() % 2 == 1) { do { killPoison = rand() % n + 1; } while(player[killPoison].role == "女巫 " || player[killPoison].role == "预言家 " || killPoison == killWolf || !player[killPoison].alive); hasPoison = false; } } } Sleep(3000); system("cls"); printGameUI(day, true); cout << "女~巫~请~闭~眼~~~\n"; if(n > 6) { Sleep(3000); system("cls"); printGameUI(day, true); cout << "预~言~家~请~睁~眼~~~\n"; if(player[mySelf].role == "预言家 " && player[mySelf].alive) { int check; cout << "查验编号:"; cin >> check; player[check].know = 1; cout << "身份:" << (player[check].role == "狼人 " ? "狼人" : "好人") << "\n"; } else { cout << "AI预言家查验\n"; } Sleep(3000); system("cls"); printGameUI(day, true); cout << "预~言~家~请~闭~眼~~~\n"; } Sleep(3000); if(killWolf != 0) { player[killWolf].alive = false; player[killWolf].dieReason = 1; } if(killPoison != 0) { player[killPoison].alive = false; player[killPoison].dieReason = 3; } system("cls"); system("color F0"); printGameUI(day + 1, false); } void hunterShoot() { if(hunterShot) return; hunterShot = true; int shootTar; if(mySelf == hunterId) { cout << "你被淘汰,请选择开枪带走一人:"; cin >> shootTar; while(!player[shootTar].alive) { cin >> shootTar; } } else { srand((unsigned)time(0)); do { shootTar = rand() % n + 1; } while(!player[shootTar].alive); } cout << hunterId << "号猎人开枪带走" << shootTar << "号\n"; player[shootTar].alive = false; player[shootTar].dieReason = 4; Sleep(1000); } void printDeadNotice() { cout << "天亮了!昨晚"; if(killWolf == 0 && killPoison == 0) { cout << "平安夜\n"; return; } if(killWolf != 0) cout << killWolf << "号"; if(killPoison != 0) cout << "," << killPoison << "号"; cout << "玩家死亡\n"; killPoison = 0; } void showGameResult() { int villager = 0, wolf = 0, god = 0; for(int i = 1; i <= n; i++) { if(!player[i].alive) continue; if(player[i].role == "狼人 ") wolf++; else if(player[i].role == "村民 ") villager++; else god++; } if(wolf >= villager + god || god == 0) cout << "===== 狼人阵营胜利 =====" << endl; else cout << "===== 好人阵营胜利 =====" << endl; cout << "\n全部玩家身份详情:\n"; cout << left << setw(4) << "座位" << setw(8) << "身份" << setw(6) << "状态" << "死亡原因\n"; for(int i = 1; i <= n; i++) { cout << left << setw(4) << player[i].id << setw(8) << player[i].role; if(player[i].alive) cout << setw(6) << "存活" << "全程存活\n"; else { cout << setw(6) << "死亡"; switch(player[i].dieReason) { case 1: cout << "狼人刀杀\n"; break; case 2: cout << "投票放逐\n"; break; case 3: cout << "女巫毒杀\n"; break; case 4: cout << "猎人枪杀\n"; break; } } } system("pause"); system("pause"); } int main() { system("cls"); cout << "========== 控制台狼人杀 ==========\n"; cout << "请输入游玩人数(6~12):"; cin >> n; cout << "身份分配加载中,请稍候"; initRoleBase(); setRoleCount(n); for(int i = 1; i <= n; i++) { randomAssignRole(i); cout << "."; Sleep(17); } system("cls"); system("color F0"); cout << "游戏即将开始"; for(int i = 1; i <= 6; i++) { cout << "."; Sleep(500); } Sleep(1500); cout << "\n\n查看你的身份牌......\n"; srand((unsigned)time(0)); mySelf = rand() % n + 1; cout << "你的身份:" << player[mySelf].role << "\n座位:" << mySelf << "号\n"; system("pause"); system("cls"); player[mySelf].know = 2; printGameUI(1, false); cout << "即将进入第一个夜晚"; for(int i = 1; i <= 6; i++) { cout << "."; Sleep(500); } nightFirstRound(); printDeadNotice(); if(checkGameOver()) { Sleep(1000); system("cls"); showGameResult(); return 0; } if(!player[hunterId].alive && !hunterShot) hunterShoot(); if(checkGameOver()) { Sleep(1000); system("cls"); showGameResult(); return 0; } voteProcess(2, false); system("cls"); printGameUI(2, false); if(checkGameOver()) { Sleep(1000); system("cls"); showGameResult(); return 0; } if(!player[hunterId].alive && !hunterShot) hunterShoot(); for(int day = 2; day <= 7; day++) { cout << "即将进入夜晚"; for(int i = 1; i <= 6; i++) { cout << "."; Sleep(500); } nightLoop(day, true); printDeadNotice(); if(checkGameOver()) { Sleep(1000); system("cls"); showGameResult(); return 0; } if(!player[hunterId].alive && !hunterShot) hunterShoot(); if(checkGameOver()) { Sleep(1000); system("cls"); showGameResult(); return 0; } voteProcess(day + 1, false); system("cls"); printGameUI(day + 1, false); if(checkGameOver()) { Sleep(1000); system("cls"); showGameResult(); return 0; } if(!player[hunterId].alive && !hunterShot) hunterShoot(); if(checkGameOver()) { Sleep(1000); system("cls"); showGameResult(); return 0; } } system("pause"); return 0; }
-
通过的题目
- B1001
- B1005
- B1007
- B1008
- B1022
- B1023
- B1031
- B1036
- B1037
- B1038
- B1039
- B1041
- B1046
- B1049
- B1054
- B1055
- B1062
- B1072
- B1089
- B1094
- B1099
- dxc00003
- B1107
- B1110
- B1117
- B1124
- B1126
- B1147
- B1151
- B1155
- B1156
- B1163
- B1179
- B1180
- B1182
- B1183
- B1184
- B1189
- B1199
- B1204
- B1207
- B1208
- B1210
- B1240
- B1241
- B1244
- B1252
- B1254
- B1263
- B1265
- B1267
- B1268
- B1274
- B1276
- B1281
- B1285
- B1286
- B1290
- B1293
- B1294
- B1310
- B1312
- B1319
- B1321
- B1323
- B1329
- B1331
- B1332
- B1333
- B1336
- B1339
- B1353
- B1354
- B1369
- B1401
- B1414
- B1416
- CSPJ2019B
- CSPJ2020B
- CSPJ2021A
- CSPJ2021B
- NOIPS2013D
- NOIPS2015A
- 485
- NOIPS2016A
- CSPJ2022A
- CSPJ2023A
- P515
- NOIPJ2016B
- NOIPJ2015A
- NOIPJ2015B
- P538
- P539
- P540
- 541
- 542
- 544
- 545
- P546
- P547
- P548
- 549
- P550
- 552
- 555
- W1049
- W1051
- W1052
- hm2001
- hm3201
- hm3801
- xwj001
- G1039
- G1040
- 784
- 785
- 793
- 795
- 796
- 797
- 798
- 799
- P1
- P122
- P174
- P183
- P242
- P270
- P348
- P416
- P454
- 1286
- 1308
- GESP202312C42
- 1321
- 1324
- 1336
- T1541
- T1542
- T1552
- GESP202403C42
- 1393
- 1396
- 1397
- 1402
- 1440
- 1448
- 1449
- 1461
- 1530
- 1535
- 1555
- GESP202403C41
- GESP202309C42
- 1578
- GESP202403C32
- GESP202403C31
- 1601
- 1602
- 1603
- 1605
- 1609
- GESP202306C31
- GESP202412C31
- GESP202412C32
- GESP202503C32
- GESP202409C42
- GESP202503C42
- G1048
- 1706
- 1716
- 1717
- 1721
- 1722
- GESP202403C51
- 1746
- 1753
- 1754
- 1755
- 1756
- B472
- 1762
- 1766
- 1795
- 1801
- 1803
- 1933
- 1954
- 1968
- 1984
- GESP202506C42
- CSPJ2024B
- GESP202509C31
- GESP202509C42
- CSES1158
- CSES1634
- CSES1635
- 2570
- CSES1084
- GESP202603C52
- 2693
- abc451c
- CSES1094
- CSES1621
- CSES1646
- CSES1650
- CSES2422
- 3169
- CSES1620
- 3181
- 3182
- 3185
- 3186
- 3188
- 3198
- 3202
- 3214
- 3242
- 3247
- CSPJ26D01
- CSPJ26D02
- CSPJ26D03
- CSPJ26D04
- CSES1074
- CSES1660
- CSES1661
- CSES1631
- CSES2216
- CSES1630
- study
- CSPJ2026JH01
- CSPJ2026JH03
-
最近活动
- 20260917 建华实验 CSPJ初赛模拟五讲解 作业
- 20260916 建华实验 CSPJ初赛模拟四讲解 作业
- 20260909 建华实验 CSPJ初赛模拟三讲解 作业
- 秋季周六上午C++作业 作业
- 20260903 建华实验 CSPJ初赛模拟二讲解 作业
- 20260902 建华实验 CSPJ初赛模拟一讲解 作业
- 26建华暑期集训 初赛模拟赛(01) OI
- 26建华暑期集训 Day14:背包和区间 DP 作业
- 26建华暑期集训 Day13:线性DP 作业
- 26建华暑期集训 CSP-J 模拟赛(8/11) OI
- 26建华暑期集训 Day12:树和图 作业
- 26建华暑期集训 Day11:搜索(DFS/BFS) 作业
- 26建华暑期集训 CSP-J 模拟赛(8/7) OI
- 26建华暑期集训 Day9:常用STL 作业
- 26建华暑期集训 Day8:队列和栈 作业
- 26建华暑期集训 Day7:二分法和链表 作业
- 26建华暑期集训 Day7模拟赛 第一套 OI
- 26建华暑期集训 Day6:二分法 作业
- 26建华暑期集训 Day5 阶段测评模拟赛 OI
- 26建华暑期集训 Day4:贪心 作业
- 26建华暑期集训 Day3 模拟赛:排序与双指针 OI
- 26建华暑期集训 Day3:排序与双指针 作业
- 26建华暑期集训 Day2:前缀和与差分 作业
- 26建华暑期集训 Day1:枚举与模拟 作业
- 2025.06.18 背包问题 作业
- 2025.06.18 线性dp 作业
- 2025.06.17 BFS 作业
- 2025.06.12 DFS 作业
- 2025.06.11 栈 作业
- 2025.06.10 队列 作业
- 2025.06.05 贪心综合练习 作业
- 2025.06.04 贪心法强化 作业
- 2025.06.03 贪心法入门 作业
- 2025.05.29 插入排序 作业
- 2025.05.28 选择排序 作业
- 2025.05.27 快排和计数 作业
- 2025.05.22 排序算法 作业
- 2025.05.21 文件读写和异常处理 作业
- 2025.05.20 GESP三级2412 作业
- 2025.05.14 比赛模拟练习 作业
- 2025.05.13 比赛模拟练习 作业
- 2025.05.08 递推练习 作业
- 2025.05.07 位运算和递推 作业
- 2025.05.06 原码反码补码 作业
- 建华实验信奥班 2025.04月测 OI
- 2025.04.23 位运算 作业
- 2025.04.22 进制转换2 作业
- 4月18日周五北京小学通州分校课后练习 作业
- 2025.04.17 进制转换 作业
- 2025.04.10 建华实验信奥社团 二分答案强化 作业
- 2025.04.09 建华实验信奥社团 二分答案练习 作业
- 2025.04.08 建华实验信奥社团 二分答案 作业
- 2025.04.03 建华实验信奥社团 二分查找练习 作业
- 2025.04.02 建华实验信奥社团 二分查找进阶 作业
- 2025.04.01 建华实验信奥社团 二分查找 作业
- 建华实验信奥班 2025.03月测 OI
- 2025.03.26 建华实验信奥社团 模拟法强化 作业
- 2025.03.25 建华实验信奥社团 模拟法 作业
- 2025.03.20 建华实验信奥社团 时间复杂度 作业
- 2025.03.19 建华实验信奥社团 枚举强化 作业
- 2025.03.18 建华实验信奥社团 枚举法 作业
- 2025.03.13 建华实验信奥社团 GCD和LCM 作业
- 2025.03.12 建华实验信奥社团 数学训练营 作业
- 2025.03.11 建华实验信奥社团 数位分离练习 作业
- 2025.03.06 建华实验信奥社团 递归函数进阶 作业
- 2025.03.05 建华实验信奥社团 递归函数 作业
- 2025.03.04 建华实验信奥社团 结构体排序练习 作业
- 3月1日周六马驹桥小学2025C++线下B班 作业
- 2025.02.27 建华实验信奥社团 结构体排序 作业
- 2025.02.26 建华实验信奥社团 二维数组 作业
- 2025.02.25 建华实验信奥社团 谁是小学霸 作业
题目标签
- 模拟
- 85
- 排序
- 31
- 动态规划
- 28
- 贪心
- 19
- 数学
- 15
- 数组
- 12
- 顺序结构
- 10
- 循环结构
- 10
- 前缀和
- 10
- 字符串
- 9
- 二分
- 9
- 递归
- 8
- 基础知识
- 8
- GESP4级
- 8
- 分支结构
- 7
- 枚举
- 7
- 差分
- 7
- 搜索
- 7
- GESP3级
- 7
- 队列
- 6






