#include<iostream> #include<string> #include<vector> #include<algorithm> #include<cctype> #include<sstream> #include<cmath> #include<ctime> #include<iomanip> #include<map> #include<cstdlib> #include<limits> #include<bits/stdc++.h> #include<windows.h> #include<time.h> #include<conio.h> #include<bits/stdtr1c++.h> #include<alg.h> #include<qedit.h> #include<stdio.h> #include<cstdio> #include<cstring> #define Nor if(B[b].x<5) B[b].x=5; #define Out1 Bx1-Bvx1<=6||Bx1-Bvx1>=28||By1-Bvy1<=7||By1-Bvy1>=27 #define Out2 Bx2-Bvx2<=6||Bx2-Bvx2>=28||By2-Bvy2<=7||By2-Bvy2>=27 #define Chang1 {Bwhat1=0;Bvx1=Bvy1=0;memset(Bgo1,0,sizeof(Bgo1));} #define Chang2 {Bwhat2=0;Bvx2=Bvy2=0;memset(Bgo2,0,sizeof(Bgo2));} #define Chang3 {Bwhat3=0;Bvx3=Bvy3=0;memset(Bgo3,0,sizeof(Bgo3));} using namespace std; const string VERSION = "v3.0.0"; const string ADMIN_USER = "admin"; const string ADMIN_PWD = "admin123"; const string USER_FILE = "users.txt"; const string CALC_HISTORY_FILE = "calc_history.txt"; const string GOBANG_HISTORY_FILE = "gobang_history.txt"; const string NOTE_FILE = "notes.txt"; const string ANNOUNCEMENT_FILE = "announcement.txt"; enum class LanguageType { CHINESE, ENGLISH }; LanguageType currentLang = LanguageType::CHINESE; enum class ConsoleColor { BLACK = 0, RED = 1, GREEN = 2, YELLOW = 3, BLUE = 4, PURPLE = 5, CYAN = 6, WHITE = 7, GRAY = 8, LIGHT_RED = 9, LIGHT_GREEN = 10, LIGHT_YELLOW = 11, LIGHT_BLUE = 12, LIGHT_PURPLE = 13, LIGHT_CYAN = 14, LIGHT_WHITE = 15 }; struct AppState { string loginUsername; bool isAdmin = false; bool isRunning = true; } appState; void setConsoleColor(ConsoleColor textColor, ConsoleColor bgColor = ConsoleColor::BLACK) { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); if (hConsole == INVALID_HANDLE_VALUE) return; SetConsoleTextAttribute(hConsole, ((int)bgColor << 4) | (int)textColor); } void resetConsoleColor() { setConsoleColor(ConsoleColor::LIGHT_WHITE, ConsoleColor::BLACK); } void flushConsoleOutput() { cout << flush; HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); if (hConsole != INVALID_HANDLE_VALUE) FlushConsoleInputBuffer(hConsole); } void clearConsole() { #ifdef _WIN32 system("cls"); #else system("clear"); #endif } string simpleEncrypt(const string& input) { unsigned long long hash = 14695981039346656037ULL; for (char c : input) { hash ^= (unsigned char)c; hash *= 1099511628211ULL; } stringstream ss; ss << hex << hash; string result = ss.str(); if (result.size() < 16) result = string(16 - result.size(), '0') + result; return result.substr(0, 16); } string getCurrentTime() { time_t now = time(nullptr); tm localTime = *localtime(&now); stringstream ss; ss << put_time(&localTime, "%Y-%m-%d %H:%M:%S"); return ss.str(); } void clearInputBuffer() { cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); } string getLocalText(const string& key) { if (currentLang == LanguageType::CHINESE) { if (key == "lang_choice") return "请选择语言:"; if (key == "lang_cn") return "1. 中文"; if (key == "lang_en") return "2. 英文"; if (key == "login") return "登录"; if (key == "register") return "注册"; if (key == "username") return "用户名"; if (key == "password") return "密码"; if (key == "confirm_pwd") return "确认密码"; if (key == "user_exist") return "错误:用户名已存在!"; if (key == "pwd_not_match") return "错误:两次密码不一致!"; if (key == "register_success") return "注册成功!"; if (key == "user_not_exist") return "错误:用户名不存在!"; if (key == "pwd_error") return "错误:密码错误!"; if (key == "login_success") return "登录成功!"; if (key == "choice") return "请选择"; if (key == "invalid_choice") return "错误:无效的选择!"; if (key == "goodbye") return "感谢使用,再见!"; if (key == "exit") return "退出"; if (key == "main_menu") return "===== 主菜单 ====="; if (key == "calculator") return "大数计算器"; if (key == "gobang") return "五子棋游戏"; if (key == "notepad") return "记事本"; if (key == "mini_games") return "小游戏合集"; if (key == "tools") return "代码小工具"; if (key == "calc_input") return "请输入计算式(exit退出):"; if (key == "calc_result") return "计算结果:"; if (key == "gobang_black") return "黑棋"; if (key == "gobang_white") return "白棋"; if (key == "gobang_win") return "获胜!"; if (key == "gobang_draw") return "平局!"; if (key == "coord_error") return "错误:坐标无效!"; if (key == "chess_exist") return "错误:该位置已有棋子!"; if (key == "note_edit") return "编辑记事本"; if (key == "note_view") return "查看记事本"; if (key == "guess_num") return "猜数字游戏"; if (key == "minesweeper") return "简易扫雷"; if (key == "random_num") return "随机数生成"; if (key == "base_convert") return "进制转换"; if (key == "string_tool") return "字符串处理"; if (key == "stopwatch") return "秒表工具"; if (key == "announcement_title") return "===== 系统公告 ====="; if (key == "announcement_default") return "欢迎使用C++中心 v2.0.0!\n1. 默认管理员账号:admin,密码:admin123\n2. 所有操作记录将保存在本地文件中\n3. 如有问题请检查文件读写权限"; if (key == "announcement_load_fail") return "提示:未找到公告文件,显示默认公告"; if (key == "announcement_continue") return "按回车继续..."; if (key == "calc_tip") return "支持:加减乘(乘法仅支持单个数字乘数),输入exit退出"; if (key == "gobang_tip") return "黑棋(X) 先行,白棋(O) 后行"; if (key == "note_edit_tip") return "请输入内容(按Ctrl+Z结束输入):"; if (key == "note_save_success") return "保存成功!"; if (key == "note_open_fail") return "错误:无法打开文件!"; if (key == "note_empty") return "记事本为空!"; if (key == "guess_num_tip") return "我想了一个1-100的数字,你来猜猜!"; if (key == "guess_num_small") return "太小了!"; if (key == "guess_num_big") return "太大了!"; if (key == "guess_num_success") return "恭喜!你用了%d次猜对了!"; if (key == "minesweeper_tip") return "5x5扫雷,共5个地雷"; if (key == "minesweeper_win") return "恭喜!你赢了!"; if (key == "minesweeper_lose") return "踩雷了!游戏结束!"; if (key == "minesweeper_revealed") return "该位置已揭开!"; if (key == "random_num_min") return "输入最小值:"; if (key == "random_num_max") return "输入最大值:"; if (key == "random_num_result") return "随机数:%d"; if (key == "random_num_max_error") return "最大值必须大于最小值!"; if (key == "base_convert_num") return "输入十进制数:"; if (key == "base_convert_type") return "转换为(2/8/16)进制:"; if (key == "base_convert_result") return "转换结果:%s"; if (key == "base_convert_error") return "请输入2/8/16!"; if (key == "string_tool_input") return "输入字符串:"; if (key == "string_tool_upper") return "1. 转大写:%s"; if (key == "string_tool_lower") return "2. 转小写:%s"; if (key == "string_tool_reverse") return "3. 反转:%s"; if (key == "string_tool_length") return "4. 长度:%d"; if (key == "stopwatch_start") return "按回车开始计时..."; if (key == "stopwatch_running") return "计时中... 按回车结束!"; if (key == "stopwatch_result") return "耗时:%.0f 秒"; if (key == "input_number_error") return "请输入数字!"; if (key == "input_range_error") return "请输入1-100之间的数字!"; if (key == "minesweeper_input") return "输入要揭开的位置(行 列):"; if (key == "continue_tip") return "按回车继续..."; return "未知文本"; } else { if (key == "lang_choice") return "Please select language:"; if (key == "lang_cn") return "1. Chinese"; if (key == "lang_en") return "2. English"; if (key == "login") return "Login"; if (key == "register") return "Register"; if (key == "username") return "Username"; if (key == "password") return "Password"; if (key == "confirm_pwd") return "Confirm Password"; if (key == "user_exist") return "Error: Username already exists!"; if (key == "pwd_not_match") return "Error: Passwords do not match!"; if (key == "register_success") return "Registration successful!"; if (key == "user_not_exist") return "Error: Username does not exist!"; if (key == "pwd_error") return "Error: Wrong password!"; if (key == "login_success") return "Login successful!"; if (key == "choice") return "Please choose"; if (key == "invalid_choice") return "Error: Invalid choice!"; if (key == "goodbye") return "Thanks for using, goodbye!"; if (key == "exit") return "Exit"; if (key == "main_menu") return "===== Main Menu ====="; if (key == "calculator") return "Big Number Calculator"; if (key == "gobang") return "Gobang Game"; if (key == "notepad") return "Notepad"; if (key == "mini_games") return "Mini Games"; if (key == "tools") return "Code Tools"; if (key == "calc_input") return "Enter calculation (exit to quit): "; if (key == "calc_result") return "Result: "; if (key == "gobang_black") return "Black Chess"; if (key == "gobang_white") return "White Chess"; if (key == "gobang_win") return "Win!"; if (key == "gobang_draw") return "Draw!"; if (key == "coord_error") return "Error: Invalid coordinates!"; if (key == "chess_exist") return "Error: Chess already exists here!"; if (key == "note_edit") return "Edit Notepad"; if (key == "note_view") return "View Notepad"; if (key == "guess_num") return "Guess Number Game"; if (key == "minesweeper") return "Simple Minesweeper"; if (key == "random_num") return "Random Number Generator"; if (key == "base_convert") return "Base Conversion"; if (key == "string_tool") return "String Tools"; if (key == "stopwatch") return "Stopwatch Tool"; if (key == "announcement_title") return "===== System Announcement ====="; if (key == "announcement_default") return "Welcome to C++ Center v2.0.0!\n1. Default admin account: admin, password: admin123\n2. All operation records are saved in local files\n3. Check file read/write permissions if there are issues"; if (key == "announcement_load_fail") return "Tip: Announcement file not found, showing default announcement"; if (key == "announcement_continue") return "Press Enter to continue..."; if (key == "calc_tip") return "Supported: +-* (multiplication only supports single-digit multiplier), enter exit to quit"; if (key == "gobang_tip") return "Black Chess(X) first move, White Chess(O) second move"; if (key == "note_edit_tip") return "Enter content (Ctrl+Z to end input): "; if (key == "note_save_success") return "Saved successfully!"; if (key == "note_open_fail") return "Error: Cannot open file!"; if (key == "note_empty") return "Notepad is empty!"; if (key == "guess_num_tip") return "I thought of a number between 1-100, guess it!"; if (key == "guess_num_small") return "Too small!"; if (key == "guess_num_big") return "Too big!"; if (key == "guess_num_success") return "Congratulations! You guessed it in %d tries!"; if (key == "minesweeper_tip") return "5x5 Minesweeper with 5 mines"; if (key == "minesweeper_win") return "Congratulations! You win!"; if (key == "minesweeper_lose") return "Stepped on a mine! Game over!"; if (key == "minesweeper_revealed") return "Position already revealed!"; if (key == "random_num_min") return "Enter min: "; if (key == "random_num_max") return "Enter max: "; if (key == "random_num_result") return "Random number: %d"; if (key == "random_num_max_error") return "Max must be greater than min!"; if (key == "base_convert_num") return "Enter decimal number: "; if (key == "base_convert_type") return "Convert to (2/8/16) base: "; if (key == "base_convert_result") return "Result: %s"; if (key == "base_convert_error") return "Please enter 2/8/16!"; if (key == "string_tool_input") return "Enter string: "; if (key == "string_tool_upper") return "1. To upper: %s"; if (key == "string_tool_lower") return "2. To lower: %s"; if (key == "string_tool_reverse") return "3. Reverse: %s"; if (key == "string_tool_length") return "4. Length: %d"; if (key == "stopwatch_start") return "Press Enter to start timing..."; if (key == "stopwatch_running") return "Timing... Press Enter to stop!"; if (key == "stopwatch_result") return "Elapsed time: %.0f seconds"; if (key == "input_number_error") return "Please enter a number!"; if (key == "input_range_error") return "Please enter a number between 1-100!"; if (key == "minesweeper_input") return "Enter position to reveal (row col): "; if (key == "continue_tip") return "Press Enter to continue..."; return "Unknown Text"; } } // ===================== 公告模块 ===================== void showAnnouncement() { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << getLocalText("announcement_title") << endl; resetConsoleColor(); cout << endl; ifstream annFile(ANNOUNCEMENT_FILE); if (annFile.is_open()) { string line; while (getline(annFile, line)) { setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << line << endl; resetConsoleColor(); } annFile.close(); } else { setConsoleColor(ConsoleColor::LIGHT_BLUE); cout << getLocalText("announcement_load_fail") << endl; resetConsoleColor(); setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << getLocalText("announcement_default") << endl; resetConsoleColor(); } cout << endl; setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << getLocalText("announcement_continue"); resetConsoleColor(); flushConsoleOutput(); clearInputBuffer(); cin.get(); } // ===================== 登录注册核心功能 ===================== void initAdminUser() { ifstream file(USER_FILE); if (!file.is_open()) { ofstream newFile(USER_FILE); if (newFile.is_open()) { newFile << ADMIN_USER << " " << simpleEncrypt(ADMIN_PWD) << endl; newFile.close(); } } file.close(); } bool checkUserExists(const string& username) { ifstream file(USER_FILE); if (!file.is_open()) return false; string user, pwd; while (file >> user >> pwd) { if (user == username) { file.close(); return true; } } file.close(); return false; } void registerNewUser() { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << "===== " << getLocalText("register") << " =====" << endl; resetConsoleColor(); string username, password, confirmPwd; setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << getLocalText("username") << ":"; resetConsoleColor(); cin >> username; if (checkUserExists(username)) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("user_exist") << endl; resetConsoleColor(); Sleep(1000); return; } setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << getLocalText("password") << ":"; resetConsoleColor(); cin >> password; setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << getLocalText("confirm_pwd") << ":"; resetConsoleColor(); cin >> confirmPwd; if (password != confirmPwd) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("pwd_not_match") << endl; resetConsoleColor(); Sleep(1000); return; } ofstream file(USER_FILE, ios::app); if (file.is_open()) { file << username << " " << simpleEncrypt(password) << endl; file.close(); setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << getLocalText("register_success") << endl; resetConsoleColor(); } else { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("note_open_fail") << endl; resetConsoleColor(); } Sleep(1000); } bool userLogin() { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << "===== " << getLocalText("login") << " =====" << endl; resetConsoleColor(); string username, password; setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << getLocalText("username") << ":"; resetConsoleColor(); cin >> username; setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << getLocalText("password") << ":"; resetConsoleColor(); cin >> password; if (!checkUserExists(username)) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("user_not_exist") << endl; resetConsoleColor(); Sleep(1000); return false; } ifstream file(USER_FILE); string user, encryptedPwd; while (file >> user >> encryptedPwd) { if (user == username) { file.close(); if (simpleEncrypt(password) == encryptedPwd) { appState.loginUsername = username; appState.isAdmin = (username == ADMIN_USER); return true; } else { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("pwd_error") << endl; resetConsoleColor(); Sleep(1000); return false; } } } file.close(); return false; } // ===================== 语言选择 ===================== void selectLanguage() { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_BLUE); cout << "===== C++ Center " << VERSION << " =====" << endl; resetConsoleColor(); cout << endl; int langChoice = 0; setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << getLocalText("lang_choice") << endl; resetConsoleColor(); setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << getLocalText("lang_cn") << endl; resetConsoleColor(); setConsoleColor(ConsoleColor::LIGHT_PURPLE); cout << getLocalText("lang_en") << endl; resetConsoleColor(); setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << getLocalText("choice") << "(1/2):"; resetConsoleColor(); flushConsoleOutput(); while (!(cin >> langChoice) || (langChoice != 1 && langChoice != 2)) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("invalid_choice") << "," << getLocalText("choice") << ":"; resetConsoleColor(); clearInputBuffer(); flushConsoleOutput(); } switch (langChoice) { case 1: currentLang = LanguageType::CHINESE; break; case 2: currentLang = LanguageType::ENGLISH; break; default: currentLang = LanguageType::CHINESE; break; } setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << "\n" << (currentLang == LanguageType::CHINESE ? "语言选择完成!" : "Language selected!") << endl; resetConsoleColor(); Sleep(800); } // ===================== 大数计算器 ===================== string bigNumberAdd(const string& num1, const string& num2) { string result; int carry = 0; int i = num1.size() - 1, j = num2.size() - 1; while (i >= 0 || j >= 0 || carry > 0) { int digit1 = (i >= 0) ? (num1[i--] - '0') : 0; int digit2 = (j >= 0) ? (num2[j--] - '0') : 0; int sum = digit1 + digit2 + carry; carry = sum / 10; result.push_back((sum % 10) + '0'); } reverse(result.begin(), result.end()); return result; } string bigNumberSub(const string& num1, const string& num2) { string result; int borrow = 0; int i = num1.size() - 1, j = num2.size() - 1; while (i >= 0) { int digit1 = num1[i--] - '0' - borrow; int digit2 = (j >= 0) ? (num2[j--] - '0') : 0; borrow = 0; if (digit1 < digit2) { digit1 += 10; borrow = 1; } result.push_back((digit1 - digit2) + '0'); } reverse(result.begin(), result.end()); size_t start = result.find_first_not_of('0'); return (start == string::npos) ? "0" : result.substr(start); } string bigNumberMul(const string& num1, int num2) { string result; int carry = 0; for (int i = num1.size() - 1; i >= 0; --i) { int product = (num1[i] - '0') * num2 + carry; carry = product / 10; result.push_back((product % 10) + '0'); } if (carry > 0) result.push_back(carry + '0'); reverse(result.begin(), result.end()); size_t start = result.find_first_not_of('0'); return (start == string::npos) ? "0" : result.substr(start); } void saveCalcHistory(const string& expr, const string& result) { ofstream file(CALC_HISTORY_FILE, ios::app); if (file.is_open()) { file << getCurrentTime() << " | " << appState.loginUsername << " | " << expr << " = " << result << endl; file.close(); } } void runCalculator() { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << "===== " << getLocalText("calculator") << " =====" << endl; resetConsoleColor(); setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << getLocalText("calc_tip") << endl; resetConsoleColor(); string input; while (true) { setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << "\n" << getLocalText("calc_input"); resetConsoleColor(); flushConsoleOutput(); cin >> input; if (input == "exit") break; if (input.empty()) continue; size_t opPos = input.find_first_of("+-*"); if (opPos == string::npos) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("invalid_choice") << endl; resetConsoleColor(); continue; } string num1 = input.substr(0, opPos); char op = input[opPos]; string num2 = input.substr(opPos + 1); if (num1.find_first_not_of("0123456789") != string::npos || num2.find_first_not_of("0123456789") != string::npos) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("input_number_error") << endl; resetConsoleColor(); continue; } string result; try { switch (op) { case '+': result = bigNumberAdd(num1, num2); break; case '-': result = bigNumberSub(num1, num2); break; case '*': if (num2.size() > 1) throw runtime_error(""); result = bigNumberMul(num1, stoi(num2)); break; default: throw runtime_error(""); } setConsoleColor(ConsoleColor::LIGHT_PURPLE); cout << getLocalText("calc_result") << result << endl; resetConsoleColor(); saveCalcHistory(input, result); } catch (...) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("invalid_choice") << endl; resetConsoleColor(); } } } // ===================== 五子棋 ===================== const int BOARD_SIZE = 15; typedef char GobangBoard[BOARD_SIZE][BOARD_SIZE]; void initGobangBoard(GobangBoard board) { for (int i = 0; i < BOARD_SIZE; ++i) for (int j = 0; j < BOARD_SIZE; ++j) board[i][j] = '+'; } void printGobangBoard(GobangBoard board) { cout << " "; for (int i = 0; i < BOARD_SIZE; ++i) { setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << setw(2) << i; resetConsoleColor(); } cout << endl; for (int i = 0; i < BOARD_SIZE; ++i) { setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << setw(2) << i; resetConsoleColor(); for (int j = 0; j < BOARD_SIZE; ++j) { if (board[i][j] == 'X') setConsoleColor(ConsoleColor::BLACK, ConsoleColor::LIGHT_WHITE); else if (board[i][j] == 'O') setConsoleColor(ConsoleColor::LIGHT_WHITE, ConsoleColor::BLACK); else setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << setw(2) << board[i][j]; resetConsoleColor(); } cout << endl; } } bool checkGobangWin(GobangBoard board, int x, int y, char chess) { const int dirs[4][2] = {{0, 1}, {1, 0}, {1, 1}, {1, -1}}; for (auto& dir : dirs) { int count = 1; for (int i = 1; i < 5; ++i) { int nx = x + dir[0] * i; int ny = y + dir[1] * i; if (nx < 0 || nx >= BOARD_SIZE || ny < 0 || ny >= BOARD_SIZE || board[nx][ny] != chess) break; count++; } for (int i = 1; i < 5; ++i) { int nx = x - dir[0] * i; int ny = y - dir[1] * i; if (nx < 0 || nx >= BOARD_SIZE || ny < 0 || ny >= BOARD_SIZE || board[nx][ny] != chess) break; count++; } if (count >= 5) return true; } return false; } void saveGobangHistory(const string& winner) { ofstream file(GOBANG_HISTORY_FILE, ios::app); if (file.is_open()) { file << getCurrentTime() << " | " << appState.loginUsername << " | Winner:" << winner << endl; file.close(); } } void runGobang() { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << "===== " << getLocalText("gobang") << " =====" << endl; resetConsoleColor(); setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << getLocalText("gobang_tip") << endl; resetConsoleColor(); Sleep(500); GobangBoard board; initGobangBoard(board); bool isBlackTurn = true; int stepCount = 0; printGobangBoard(board); while (true) { char chess = isBlackTurn ? 'X' : 'O'; string chessName = isBlackTurn ? getLocalText("gobang_black") : getLocalText("gobang_white"); setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << "\n" << chessName << "(" << chess << ")" << getLocalText("choice") << "(行 列):"; resetConsoleColor(); flushConsoleOutput(); int x, y; while (!(cin >> x >> y) || x < 0 || x >= BOARD_SIZE || y < 0 || y >= BOARD_SIZE) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("coord_error") << "," << getLocalText("choice") << ":"; resetConsoleColor(); clearInputBuffer(); flushConsoleOutput(); } if (board[x][y] != '+') { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("chess_exist") << endl; resetConsoleColor(); Sleep(800); continue; } board[x][y] = chess; stepCount++; clearConsole(); printGobangBoard(board); if (checkGobangWin(board, x, y, chess)) { setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << chessName << getLocalText("gobang_win") << endl; resetConsoleColor(); saveGobangHistory(chessName); break; } if (stepCount >= BOARD_SIZE * BOARD_SIZE) { setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << getLocalText("gobang_draw") << endl; resetConsoleColor(); saveGobangHistory(getLocalText("gobang_draw")); break; } isBlackTurn = !isBlackTurn; } Sleep(1500); } // ===================== 记事本 ===================== void runNotepad() { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_BLUE); cout << "===== " << getLocalText("notepad") << " =====" << endl; resetConsoleColor(); int choice = 0; setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << "1. " << getLocalText("note_edit") << endl; cout << "2. " << getLocalText("note_view") << endl; resetConsoleColor(); setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << getLocalText("choice") << "(1/2):"; resetConsoleColor(); flushConsoleOutput(); while (!(cin >> choice) || (choice != 1 && choice != 2)) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("invalid_choice") << "," << getLocalText("choice") << ":"; resetConsoleColor(); clearInputBuffer(); flushConsoleOutput(); } clearInputBuffer(); if (choice == 1) { ofstream file(NOTE_FILE); if (!file.is_open()) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("note_open_fail") << endl; resetConsoleColor(); Sleep(1000); return; } setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << "\n" << getLocalText("note_edit_tip") << endl; resetConsoleColor(); string line; while (getline(cin, line)) file << line << endl; file.close(); setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << getLocalText("note_save_success") << endl; resetConsoleColor(); } else { ifstream file(NOTE_FILE); if (!file.is_open()) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("note_empty") << endl; resetConsoleColor(); Sleep(1000); return; } setConsoleColor(ConsoleColor::LIGHT_PURPLE); cout << "\n===== " << getLocalText("notepad") << " =====" << endl; resetConsoleColor(); string line; while (getline(file, line)) { setConsoleColor(ConsoleColor::LIGHT_WHITE); cout << line << endl; resetConsoleColor(); } file.close(); } Sleep(1500); } // ===================== 小游戏合集 ===================== void runGuessNumber() { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << "===== " << getLocalText("guess_num") << " =====" << endl; resetConsoleColor(); srand(time(nullptr)); int target = rand() % 100 + 1; int guess, tries = 0; setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << getLocalText("guess_num_tip") << endl; resetConsoleColor(); while (true) { setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << "\n" << getLocalText("choice") << ":"; resetConsoleColor(); flushConsoleOutput(); while (!(cin >> guess) || guess < 1 || guess > 100) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("input_range_error") << endl; resetConsoleColor(); clearInputBuffer(); flushConsoleOutput(); } tries++; if (guess < target) { setConsoleColor(ConsoleColor::LIGHT_BLUE); cout << getLocalText("guess_num_small") << endl; resetConsoleColor(); } else if (guess > target) { setConsoleColor(ConsoleColor::LIGHT_PURPLE); cout << getLocalText("guess_num_big") << endl; resetConsoleColor(); } else { setConsoleColor(ConsoleColor::LIGHT_GREEN); printf(getLocalText("guess_num_success").c_str(), tries); cout << endl; resetConsoleColor(); break; } } Sleep(1500); } void runMinesweeper() { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << "===== " << getLocalText("minesweeper") << " =====" << endl; resetConsoleColor(); setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << getLocalText("minesweeper_tip") << endl; resetConsoleColor(); Sleep(800); const int MS_SIZE = 5; bool mines[MS_SIZE][MS_SIZE] = {false}; bool revealed[MS_SIZE][MS_SIZE] = {false}; int mineCount = 0; int safeCount = 0; srand(time(nullptr)); while (mineCount < 5) { int x = rand() % MS_SIZE; int y = rand() % MS_SIZE; if (!mines[x][y]) { mines[x][y] = true; mineCount++; } } while (true) { clearConsole(); cout << " "; for (int i = 0; i < MS_SIZE; ++i) { setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << setw(2) << i; resetConsoleColor(); } cout << endl; for (int i = 0; i < MS_SIZE; ++i) { setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << setw(2) << i; resetConsoleColor(); for (int j = 0; j < MS_SIZE; ++j) { if (revealed[i][j]) { if (mines[i][j]) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << setw(2) << "*"; } else { int count = 0; for (int dx = -1; dx <= 1; ++dx) for (int dy = -1; dy <= 1; ++dy) { int nx = i + dx; int ny = j + dy; if (nx >= 0 && nx < MS_SIZE && ny >= 0 && ny < MS_SIZE && mines[nx][ny]) count++; } switch(count) { case 1: setConsoleColor(ConsoleColor::LIGHT_BLUE); break; case 2: setConsoleColor(ConsoleColor::LIGHT_GREEN); break; case 3: setConsoleColor(ConsoleColor::LIGHT_RED); break; case 4: setConsoleColor(ConsoleColor::LIGHT_PURPLE); break; default: setConsoleColor(ConsoleColor::LIGHT_YELLOW); break; } cout << setw(2) << count; } } else { setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << setw(2) << "#"; } resetConsoleColor(); } cout << endl; } if (safeCount == MS_SIZE * MS_SIZE - 5) { setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << "\n" << getLocalText("minesweeper_win") << endl; resetConsoleColor(); break; } int x, y; setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << "\n" << getLocalText("minesweeper_input") << endl; resetConsoleColor(); flushConsoleOutput(); while (!(cin >> x >> y) || x < 0 || x >= MS_SIZE || y < 0 || y >= MS_SIZE) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("coord_error") << "," << getLocalText("choice") << ":"; resetConsoleColor(); clearInputBuffer(); flushConsoleOutput(); } if (revealed[x][y]) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("minesweeper_revealed") << endl; resetConsoleColor(); Sleep(800); continue; } if (mines[x][y]) { revealed[x][y] = true; clearConsole(); for (int i = 0; i < MS_SIZE; ++i) for (int j = 0; j < MS_SIZE; ++j) if (mines[i][j]) revealed[i][j] = true; cout << " "; for (int i = 0; i < MS_SIZE; ++i) { setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << setw(2) << i; resetConsoleColor(); } cout << endl; for (int i = 0; i < MS_SIZE; ++i) { setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << setw(2) << i; resetConsoleColor(); for (int j = 0; j < MS_SIZE; ++j) { if (mines[i][j]) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << setw(2) << "*"; } else { setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << setw(2) << "#"; } resetConsoleColor(); } cout << endl; } setConsoleColor(ConsoleColor::LIGHT_RED); cout << "\n" << getLocalText("minesweeper_lose") << endl; resetConsoleColor(); break; } revealed[x][y] = true; safeCount++; } Sleep(1500); } void runMiniGames() { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_PURPLE); cout << "===== " << getLocalText("mini_games") << " =====" << endl; resetConsoleColor(); int choice = 0; setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << "1. " << getLocalText("guess_num") << endl; cout << "2. " << getLocalText("minesweeper") << endl; resetConsoleColor(); setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << getLocalText("choice") << "(1/2):"; resetConsoleColor(); flushConsoleOutput(); while (!(cin >> choice) || (choice != 1 && choice != 2)) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("invalid_choice") << "," << getLocalText("choice") << ":"; resetConsoleColor(); clearInputBuffer(); flushConsoleOutput(); } switch (choice) { case 1: runGuessNumber(); break; case 2: runMinesweeper(); break; default: break; } } // ===================== 代码小工具 ===================== void runRandomNumber() { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_BLUE); cout << "===== " << getLocalText("random_num") << " =====" << endl; resetConsoleColor(); int min, max; setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << getLocalText("random_num_min"); resetConsoleColor(); while (!(cin >> min)) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("input_number_error") << endl; resetConsoleColor(); clearInputBuffer(); } setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << getLocalText("random_num_max"); resetConsoleColor(); while (!(cin >> max) || max < min) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("random_num_max_error") << endl; resetConsoleColor(); clearInputBuffer(); } srand(time(nullptr)); int num = rand() % (max - min + 1) + min; setConsoleColor(ConsoleColor::LIGHT_GREEN); printf(getLocalText("random_num_result").c_str(), num); cout << endl; resetConsoleColor(); Sleep(1000); } void runBaseConversion() { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_BLUE); cout << "===== " << getLocalText("base_convert") << " =====" << endl; resetConsoleColor(); int num, base; setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << getLocalText("base_convert_num"); resetConsoleColor(); while (!(cin >> num) || num < 0) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("input_number_error") << endl; resetConsoleColor(); clearInputBuffer(); } setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << getLocalText("base_convert_type"); resetConsoleColor(); while (!(cin >> base) || (base != 2 && base != 8 && base != 16)) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("base_convert_error") << endl; resetConsoleColor(); clearInputBuffer(); } const string digits = "0123456789ABCDEF"; string result; int temp = num; if (temp == 0) result = "0"; else { while (temp > 0) { result = digits[temp % base] + result; temp /= base; } } setConsoleColor(ConsoleColor::LIGHT_GREEN); printf(getLocalText("base_convert_result").c_str(), result.c_str()); cout << endl; resetConsoleColor(); Sleep(1000); } void runStringTools() { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_BLUE); cout << "===== " << getLocalText("string_tool") << " =====" << endl; resetConsoleColor(); clearInputBuffer(); string str, strOrig; setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << getLocalText("string_tool_input"); resetConsoleColor(); getline(cin, str); strOrig = str; string strUpper = str; transform(strUpper.begin(), strUpper.end(), strUpper.begin(), ::toupper); setConsoleColor(ConsoleColor::LIGHT_GREEN); printf(getLocalText("string_tool_upper").c_str(), strUpper.c_str()); cout << endl; resetConsoleColor(); string strLower = str; transform(strLower.begin(), strLower.end(), strLower.begin(), ::tolower); setConsoleColor(ConsoleColor::LIGHT_BLUE); printf(getLocalText("string_tool_lower").c_str(), strLower.c_str()); cout << endl; resetConsoleColor(); reverse(str.begin(), str.end()); setConsoleColor(ConsoleColor::LIGHT_PURPLE); printf(getLocalText("string_tool_reverse").c_str(), str.c_str()); cout << endl; resetConsoleColor(); setConsoleColor(ConsoleColor::LIGHT_YELLOW); printf(getLocalText("string_tool_length").c_str(), (int)strOrig.size()); cout << endl; resetConsoleColor(); Sleep(1500); } void runStopwatch() { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_BLUE); cout << "===== " << getLocalText("stopwatch") << " =====" << endl; resetConsoleColor(); setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << getLocalText("stopwatch_start"); resetConsoleColor(); flushConsoleOutput(); clearInputBuffer(); cin.get(); time_t start = time(nullptr); setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << getLocalText("stopwatch_running") << endl; resetConsoleColor(); cin.get(); time_t end = time(nullptr); setConsoleColor(ConsoleColor::LIGHT_GREEN); printf(getLocalText("stopwatch_result").c_str(), difftime(end, start)); cout << endl; resetConsoleColor(); Sleep(1000); } void runCodeTools() { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << "===== " << getLocalText("tools") << " =====" << endl; resetConsoleColor(); int choice = 0; setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << "1. " << getLocalText("random_num") << endl; cout << "2. " << getLocalText("base_convert") << endl; cout << "3. " << getLocalText("string_tool") << endl; cout << "4. " << getLocalText("stopwatch") << endl; resetConsoleColor(); setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << getLocalText("choice") << "(1-4):"; resetConsoleColor(); flushConsoleOutput(); while (!(cin >> choice) || choice < 1 || choice > 4) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("invalid_choice") << "," << getLocalText("choice") << ":"; resetConsoleColor(); clearInputBuffer(); flushConsoleOutput(); } switch (choice) { case 1: runRandomNumber(); break; case 2: runBaseConversion(); break; case 3: runStringTools(); break; case 4: runStopwatch(); break; default: break; } } // ===================== 主菜单 ===================== void showMainMenu() { while (appState.isRunning) { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << getLocalText("main_menu") << " - " << appState.loginUsername << endl; resetConsoleColor(); setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << "1. " << getLocalText("calculator") << endl; cout << "2. " << getLocalText("gobang") << endl; cout << "3. " << getLocalText("notepad") << endl; cout << "4. " << getLocalText("mini_games") << endl; cout << "5. " << getLocalText("tools") << endl; cout << "6. " << getLocalText("exit") << endl; resetConsoleColor(); setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << getLocalText("choice") << "(1-6):"; resetConsoleColor(); flushConsoleOutput(); int choice = 0; while (!(cin >> choice) || choice < 1 || choice > 6) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("invalid_choice") << "," << getLocalText("choice") << ":"; resetConsoleColor(); clearInputBuffer(); flushConsoleOutput(); } switch (choice) { case 1: runCalculator(); break; case 2: runGobang(); break; case 3: runNotepad(); break; case 4: runMiniGames(); break; case 5: runCodeTools(); break; case 6: appState.isRunning = false; setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << getLocalText("goodbye") << endl; resetConsoleColor(); Sleep(800); exit(0); break; default: break; } setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << "\n" << getLocalText("continue_tip"); resetConsoleColor(); flushConsoleOutput(); clearInputBuffer(); cin.get(); } } // ===================== 登录注册菜单 ===================== void showLoginRegisterMenu() { while (true) { clearConsole(); setConsoleColor(ConsoleColor::LIGHT_BLUE); cout << "===== C++ Center " << VERSION << " =====" << endl; resetConsoleColor(); int choice = 0; setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << "1. " << getLocalText("login") << endl; cout << "2. " << getLocalText("register") << endl; resetConsoleColor(); setConsoleColor(ConsoleColor::LIGHT_YELLOW); cout << getLocalText("choice") << "(1/2):"; resetConsoleColor(); flushConsoleOutput(); while (!(cin >> choice) || (choice != 1 && choice != 2)) { setConsoleColor(ConsoleColor::LIGHT_RED); cout << getLocalText("invalid_choice") << "," << getLocalText("choice") << ":"; resetConsoleColor(); clearInputBuffer(); flushConsoleOutput(); } if (choice == 1) { if (userLogin()) { setConsoleColor(ConsoleColor::LIGHT_GREEN); cout << getLocalText("login_success") << endl; resetConsoleColor(); Sleep(800); showMainMenu(); break; } } else registerNewUser(); setConsoleColor(ConsoleColor::LIGHT_CYAN); cout << "\n" << getLocalText("continue_tip"); resetConsoleColor(); flushConsoleOutput(); clearInputBuffer(); cin.get(); } } const int n=809; struct Point {int x,y;}; int dali; int fx[4]={-1,27,1,-27}; int fxfx[4][2]={{0,-1},{1,0},{0,1},{-1,0}}; int dis[1000][1000]; //0:墙 1:有分的路 2:没分的路 3:怪物的家 int changdi[30][27]={ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0}, {0,1,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0}, {0,1,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0}, {0,1,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0}, {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0}, {0,1,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0}, {0,1,1,1,1,1,1,0,0,1,1,1,1,0,1,1,1,1,0,0,1,1,1,1,1,1,0}, {0,0,0,0,0,0,1,0,0,0,0,0,2,0,2,0,0,0,0,0,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,0,0,0,0,0,2,0,2,0,0,0,0,0,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,0,0,2,2,2,2,2,2,2,2,2,0,0,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,0,0,2,0,0,0,3,0,0,0,2,0,0,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,0,0,2,0,3,3,3,3,3,0,2,0,0,1,0,0,0,0,0,0}, {2,2,2,2,2,2,1,2,2,2,0,3,3,3,3,3,0,2,2,2,1,2,2,2,2,2,2}, {0,0,0,0,0,0,1,0,0,2,0,3,3,3,3,3,0,2,0,0,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,0,0,2,0,0,0,0,0,0,0,2,0,0,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,0,0,2,2,2,2,2,2,2,2,2,0,0,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,0,0,2,0,0,0,0,0,0,0,2,0,0,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,0,0,2,0,0,0,0,0,0,0,2,0,0,1,0,0,0,0,0,0}, {0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0}, {0,1,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0}, {0,1,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0}, {0,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0}, {0,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0}, {0,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0}, {0,1,1,1,1,1,1,0,0,1,1,1,1,0,1,1,1,1,0,0,1,1,1,1,1,1,0}, {0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0}, {0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0}, {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; int x, px1, px2, px3, px4; int y, py1, py2, py3, py4; int now, now1, now2, now3, now4; int g1, g2, g3, g4; int fangx, nextfx, last1, last2, last3, last4; int fenshu, guozi, guaitimer; int T1, T2, t1, t2, stopped; int f = 0; int beichi; void color(int a)//颜色函数 { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a); } void gotoxy(int x,int y)//位置函数(行为x 列为y) { COORD pos; pos.X=2*y; pos.Y=x; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos); } void begin(){ system("cls"); color(11); printf(" ★"); color(10); printf("吃豆人"); color(11); printf("★\n\n"); color(7); printf(" 请将窗口开至"); color(11); printf("全屏\n"); color(7); printf(" 正在初始化,请耐心等待"); for (int i=0; i<=n; i++) for (int j=1; j<=n; j++) dis[i][j]=900; for (int i=0; i<=n; i++){ for (int j=0; j<=3; j++){ if (i+fx[j]>=0 && i+fx[j]<=n){ int k=i+fx[j],xx=k/27,yy=k%27,kk; if (changdi[i/27][i%27] && changdi[xx][yy]) dis[i][k]=kk=1; } } } for (int k=0; k<=n; k++)if(changdi[k]){ for (int i=0; i<=n; i++)if(changdi[i]) for (int j=0; j<=n; j++)if(changdi[j]) if (dis[i][j]>dis[i][k]+dis[k][j]) dis[i][j]=dis[i][k]+dis[k][j]; if (k%80==0){color (13); gotoxy(3,12); printf("│");} if (k%80==20){color(13); gotoxy(3,12); printf("╱");} if (k%80==40){color(13); gotoxy(3,12); printf("─");} if (k%80==60){color(13); gotoxy(3,12); printf("╲");} if (k%60==0){color(11); gotoxy(5,k/60); printf("●");} } } void shuru(){ char ch=getch(); if (ch=='1' | ch=='j') if (changdi[x+fxfx[0][0]][y+fxfx[0][1]]==1|changdi[x+fxfx[0][0]][y+fxfx[0][1]]==2) fangx=nextfx=0; else nextfx=0; else if (ch=='2' | ch=='k') if (changdi[x+fxfx[1][0]][y+fxfx[1][1]]==1|changdi[x+fxfx[1][0]][y+fxfx[1][1]]==2) fangx=nextfx=1; else nextfx=1; else if (ch=='3' | ch=='l') if (changdi[x+fxfx[2][0]][y+fxfx[2][1]]==1|changdi[x+fxfx[2][0]][y+fxfx[2][1]]==2) fangx=nextfx=2; else nextfx=2; else if (ch=='5' | ch=='i') if (changdi[x+fxfx[3][0]][y+fxfx[3][1]]==1|changdi[x+fxfx[3][0]][y+fxfx[3][1]]==2) fangx=nextfx=3; else nextfx=3; else if (ch=='0' | ch=='s') stopped=(stopped+1)%2; else if (ch=='4' | ch=='a') t1++; else if (ch=='7' | ch=='q') t2++; else if ((ch=='6' | ch=='d') && t1-1>0) t1--; else if ((ch=='9' | ch=='e') && t2-1>0) t2--; else if (ch=='g') dali=(dali+1)%2; } void reset(){ system("cls"); color(7); gotoxy(2,30); printf("控制方向:1/2/3/5"); gotoxy(4,30); printf("你的速度:4/6"); gotoxy(6,30); printf("怪物速度:7/9"); x=22; y=13; px1=px2=px3=px4=14; py1=11; py2=12; py3=14; py4=15; now=607; now1=389; now2=390; now3=392; now4=393; for (int k=0; k<=n; k++){ int i=k/27,j=k%27; gotoxy(i,j); if (changdi[i][j]==1){color(7); printf("?");} else if (!changdi[i][j]){color(1); printf("■");} if (j=26){gotoxy(i,27); color(7); printf("%d",i);} } gotoxy(0,0); gotoxy(x,y); color(14); printf("●"); gotoxy(px1,py1); color(4); printf("◆"); gotoxy(px2,py2); color(5); printf("◆"); gotoxy(px3,py3); color(3); printf("◆"); gotoxy(px4,py4); color(2); printf("◆"); fangx=0; T1=T2=guaitimer=0; t1=75; t2=100;stopped=0; fenshu=0; guozi=237; g1=g2=g3=g4=0; dali=0; gotoxy(14,30); printf(" "); } void move1(){ int xx,yy; xx=x+fxfx[nextfx][0]; yy=y+fxfx[nextfx][1]; if (changdi[xx][yy]){ if (changdi[xx][yy]==1){fenshu+=1; changdi[xx][yy]=2;} color(14); gotoxy(x,y); printf(" "); gotoxy(xx,yy); if (!dali) printf("◎"); else printf("☆"); now=x*27+y; x=xx; y=yy; fangx=nextfx; } else{ if (x==13 && y==0 && fangx==0){xx=x; yy=26;} else if (x==13 && y==26 && fangx==2){xx=x; yy=0;} else{xx=x+fxfx[fangx][0]; yy=y+fxfx[fangx][1];} if (changdi[xx][yy]){ if (changdi[xx][yy]==1){fenshu+=1; changdi[xx][yy]=2;} color(14); gotoxy(x,y); printf(" "); gotoxy(xx,yy); if (!dali) printf("◎"); else printf("☆"); now=x*27+y; x=xx; y=yy; } } color(7); //gotoxy(15,28); printf("(%d,%d) ",x,y); gotoxy(16,28); printf("now:%d ",now); gotoxy(17,28); printf("%d (%d,%d) ",fangx,fxfx[fangx][0],fxfx[fangx][1]); gotoxy(18,28); printf("(%d,%d) changdi:%d ",xx,yy,changdi[xx][yy]); } void move2(){ int haha,minhaha,xx,yy,chi=0; if (g1){ minhaha=2147483647; if (now1%27==0 | now1%27==26) haha=last1; else if (!dali){ for (int i=0; i<=3; i++) if (changdi[(now1+fx[i])/27][(now1+fx[i])%27] && i!=last1 && minhaha>dis[now1+fx[i]][now]) {minhaha=dis[now1+fx[i]][now]; haha=i;} } else{ minhaha=-minhaha; for (int i=0; i<=3; i++) if (changdi[(now1+fx[i])/27][(now1+fx[i])%27] && i!=last1 && minhaha<dis[now1+fx[i]][now]) {minhaha=dis[now1+fx[i]][now]; haha=i;} } xx=now1/27; yy=now1%27; gotoxy(xx,yy); if (changdi[xx][yy]==1) printf("?");else printf(" "); now1+=fx[haha]; last1=(haha+2)%4; xx=now1/27; yy=now1%27; gotoxy(xx,yy); color(4); printf("◆"); color(7); if (xx==x && yy==y){ if (!dali) chi+=1; else { guozi+=50; fenshu+=50; last1=0; gotoxy(now1/27,now1%27); if (changdi[now1/27][now1%27]==1) printf("?"); else printf(" "); now1=389; } } } if (g2){ int k; minhaha=2147483647; if (fangx==0 | fangx==2){ k=y+(fxfx[fangx][1])*3; while (k>25 | !changdi[x][k]) k--; while (k<1 | !changdi[x][k]) k++; } else{ k=x+(fxfx[fangx][0])*3; while (k>28 | !changdi[k][y]) k--; while (k<1 | !changdi[k][y]) k++; } if (fangx==0 | fangx==2) k=x*27+k; else k=k*27+y; if (now2%27==0 | now2%27==26) haha=last2; else if (!dali) for (int i=0; i<=3; i++){ if (changdi[(now2+fx[i])/27][(now2+fx[i])%27] && i!=last2 && minhaha>dis[now2+fx[i]][k]) {minhaha=dis[now2+fx[i]][k]; haha=i;} } else{ minhaha=-minhaha; for (int i=0; i<=3; i++){ if (changdi[(now2+fx[i])/27][(now2+fx[i])%27] && i!=last2 && minhaha<dis[now2+fx[i]][k]) {minhaha=dis[now2+fx[i]][k]; haha=i;} } } xx=now2/27; yy=now2%27; gotoxy(xx,yy); if (changdi[xx][yy]==1) printf("?");else printf(" "); now2+=fx[haha]; last2=(haha+2)%4; gotoxy(18,30); xx=now2/27; yy=now2%27; gotoxy(xx,yy); color(5); printf("◆"); color(7); if (xx==x && yy==y){ if (!dali) chi+=1; else { guozi+=50; fenshu+=50; last2=0; gotoxy(now2/27,now2%27); if (changdi[now2/27][now2%27]==1) printf("?"); else printf(" "); now2=390; } } } if (g3){ int k; minhaha=2147483647; if (fangx==0 | fangx==2){ k=y+(fxfx[(fangx+1)%4][1])*3; while (k>25 | !changdi[x][k]) k--; while (k<1 | !changdi[x][k]) k++; } else{ k=x+(fxfx[(fangx+1)%4][0])*3; while (k>28 | !changdi[k][y]) k--; while (k<1 | !changdi[k][y]) k++; } if (fangx==0 | fangx==2) k=x*27+k; else k=k*27+y; if (now3%27==0 | now3%27==26) haha=last3; else if (!dali) for (int i=0; i<=3; i++){ if (changdi[(now3+fx[i])/27][(now3+fx[i])%27] && i!=last3 && minhaha>dis[now3+fx[i]][k]) {minhaha=dis[now3+fx[i]][k]; haha=i;} } else { minhaha=-minhaha; for (int i=0; i<=3; i++){ if (changdi[(now3+fx[i])/27][(now3+fx[i])%27] && i!=last3 && minhaha<dis[now3+fx[i]][k]) {minhaha=dis[now3+fx[i]][k]; haha=i;} } } xx=now3/27; yy=now3%27; gotoxy(xx,yy); if (changdi[xx][yy]==1) printf("?");else printf(" "); now3+=fx[haha]; last3=(haha+2)%4; gotoxy(18,30); xx=now3/27; yy=now3%27; gotoxy(xx,yy); color(3); printf("◆"); color(7); if (xx==x && yy==y){ if (!dali) chi+=1; else { guozi+=50; fenshu+=50; last3=0; gotoxy(now3/27,now3%27); if (changdi[now3/27][now3%27]==1) printf("?"); else printf(" "); now3=341; } } } if (chi) beichi++; } // 定义游戏区域大小 const int WIDTH = 80; const int HEIGHT = 20; // 定义挡板信息 int paddleX = WIDTH / 2 - 5; const int PADDLE_WIDTH = 10; // 定义小球信息 int ballX = WIDTH / 2; int ballY = HEIGHT - 2; int ballDirX = 1; int ballDirY = -1; // 定义砖块信息 bool bricks[HEIGHT / 2][WIDTH / 5] = {false}; // 初始化砖块 void initBricks() { for (int i = 0; i < HEIGHT / 2; i++) { for (int j = 0; j < WIDTH / 5; j++) { bricks[i][j] = true; } } } // 绘制游戏界面 void draw() { system("cls"); // 绘制顶部边界 for (int i = 0; i < WIDTH + 2; i++) { cout << "#"; } cout << endl; // 绘制游戏区域 for (int y = 0; y < HEIGHT; y++) { cout << "#"; for (int x = 0; x < WIDTH; x++) { if (x >= paddleX && x < paddleX + PADDLE_WIDTH && y == HEIGHT - 1) { cout << "="; } else if (x == ballX && y == ballY) { cout << "O"; } else if (y < HEIGHT / 2 && bricks[y][x / 5]) { cout << "*"; } else { cout << " "; } } cout << "#" << endl; } // 绘制底部边界 for (int i = 0; i < WIDTH + 2; i++) { cout << "#"; } cout << endl; } // 处理用户输入 void input() { if (_kbhit()) { char ch = _getch(); if (ch == 'a' && paddleX > 0) { paddleX-=6; } else if (ch == 'd' && paddleX + PADDLE_WIDTH < WIDTH) { paddleX+=6; } } } // 更新游戏逻辑 void logic() { ballX += ballDirX; ballY += ballDirY; // 处理小球撞到左右边界 if (ballX == 0 || ballX == WIDTH - 1) { ballDirX = -ballDirX; } // 处理小球撞到顶部边界 if (ballY == 0) { ballDirY = -ballDirY; } // 处理小球撞到挡板 if (ballY == HEIGHT - 2 && ballX >= paddleX && ballX < paddleX + PADDLE_WIDTH) { ballDirY = -ballDirY; } // 处理小球掉落 if (ballY == HEIGHT -1) { cout << "Game Over!" << endl; exit(0); } // 处理小球撞到砖块 if (ballY < HEIGHT / 2 && bricks[ballY][ballX / 5]) { bricks[ballY][ballX / 5] = false; ballDirY = -ballDirY; } } const int daytime=0,night=1; int day=0, during_time=daytime, player_number, my_number; HWND hwnd=GetForegroundWindow();//窗口定义 const int blue=0,yellow=1,red=2,green=3,purple=4,white=5;//颜色常量 void color2(int c){ switch(c) { case 0:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);break; case 1:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);break; case 2:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);break; case 3:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);break; case 4:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN | FOREGROUND_BLUE);break; case 5:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);break; } } void gotoxy2(int x,int y){ COORD position; position.X=x; position.Y=y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), position); } int idx_police=1; /*初始化窗口*/ void init_Show_Window(){ system("mode con lines=60 cols=188");//全屏 ShowWindow(hwnd,SW_MAXIMIZE);//窗口最大化 DeleteMenu(GetSystemMenu(GetConsoleWindow(), FALSE), SC_CLOSE, MF_BYCOMMAND); DrawMenuBar(GetConsoleWindow());//删除×字符 } /*玩家类*/ const int nvwu=0,cunmin=1,yuyanjia=2,langren=3,lieren=4,shouwei=5,good=6,die=1,life=2; class player{ public: int type; int die_or_life; int how(){ return die_or_life; } int is_light;//是否已经公布 int killer; }; player players[1000]; /*转换白天模式*/ void change_daytime(){ during_time=daytime; day++; } /*转换黑夜模式*/ void change_night(){ during_time=night; } int nnvwu=0,ncunmin=0,nyuyanjia=0,nlangren=0,nlieren=0,nshouwei=0; int idxnvwu,idxshouwei,idxyuyanjia,idxlieren,idxlangren[4]={-1,-1,-1,-1}; /*b是否在Arr中*/ bool is_include(int arr[],int b,int l){ for(int i=0;i<l;i++){ if(arr[i]==b) return true; } return false; } /*初始化人数*/ void init_players(){ my_number=rand()%player_number; if(player_number==12) nlangren=4; else if(player_number>=10) nlangren=3; else nlangren=2; for(int i=0;i<player_number;i++) { players[i].die_or_life=life; players[i].is_light=0; players[i].type=-1; players[i].killer=2147483647; } for(int i=0;i<nlangren;i++) { int p=rand()%player_number; if(!is_include(idxlangren,p,4)) idxlangren[i]=p,players[p].type=langren; else i--; Sleep(rand()%80+100); } if(player_number==12) { do{ idxshouwei=rand()%player_number; }while(players[idxshouwei].type!=-1); players[idxshouwei].type=shouwei; } do{ idxnvwu=rand()%player_number; }while(players[idxnvwu].type!=-1); players[idxnvwu].type=nvwu; if(player_number>=10) { do{ idxlieren=rand()%player_number; }while(players[idxlieren].type!=-1); players[idxlieren].type=lieren; } do{ idxyuyanjia=rand()%player_number; }while(players[idxyuyanjia].type!=-1); players[idxyuyanjia].type=yuyanjia; for(int i=0;i<player_number;i++) if(players[i].type==-1) players[i].type=cunmin, ncunmin++; if(players[my_number].type==langren) { for(int i=0;i<nlangren;i++) { players[idxlangren[i]].is_light=1; } } players[my_number].is_light=1; } /*在屏幕上打印东西*/ void print(){ gotoxy2(0,0); cout<<"作者:洛谷393864"; gotoxy2(90,0); if(during_time==night) color2(red); else color2(blue); printf("第%d天 | ",day); if(during_time==night) cout<<"黑夜"; else cout<<"白天"; gotoxy2(0,3); color2(blue); cout<<" 我的号位:"<<my_number+1; for(int i=0;i<player_number;i++){ gotoxy2(i*8+1,4); if(i==idx_police) color2(yellow); else color2(blue); cout<<i+1<<"号位"; gotoxy2(i*8+1,5); if(players[i].how()==die){ color2(red); cout<<"死 亡"; }else{ color2(green); cout<<"存 活"; } gotoxy2(i*8+1,6); color2(blue); if(players[i].is_light){ if(players[i].is_light==1){ switch(players[i].type){ case nvwu: cout<<"女 巫";break; case yuyanjia: cout<<"\b预言家";break; case cunmin: cout<<"村 民";break; case langren:cout<<"狼 人"; break; case lieren:cout<<"猎 人"; break; case shouwei:cout<<"守 卫"; break; } }else{ cout<<"好人"; } }else{ cout<<"未知"; } } } /*判断是否结束,没结束返回0 好人胜利返回1 狼人胜利返回2 平局返回3*/ int is_end(){ int die_bad=0; int die_people=0; int die_god=0; for(int i=0;i<player_number;i++){ if((players[i].type == nvwu || players[i].type == yuyanjia || players[i].type == shouwei)&&players[i].die_or_life==die) die_god++; else if(players[i].type == langren && players[i].die_or_life==die) die_bad++; else if(players[i].type == cunmin && players[i].die_or_life==die) die_people++; } if((die_bad==die_people || die_bad==die_god)&&(die_bad>=nlangren)) return 3; if(die_bad>=nlangren) return 1; if(die_people>=ncunmin||die_god>=(player_number>=10 ? 3:2)) return 2; return 0; } /*游戏开始前的骚操作*/ void before_game(){ srand(time(NULL)); init_Show_Window(); color2(green); cout<<"欢迎来到狼人杀游戏\t\t\t为了更好的游戏体验,请右键点击上方↑↑,点击\"属性\",点击\"字体\"栏目,将字体修改为宋体或新宋体,将字号改为20\n作者:洛谷393864\n请勿私自转载,违者依法追究法律责任 注:10 11 12人局开设猎人 12人局开设守卫警长\n______________________\n"; cout<<"请输入玩家人数(8-12人):"; cin>>player_number; while(player_number<8||player_number>12) { cout<<"请重新输入!\n"; cin>>player_number; } system("cls"); cout<<"初始化身份中,请稍等."; for(int i=0;i<6;i++){ for(int j=0;j<12;j++){ cout<<"."; Sleep(50); } cout<<"\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b"; } system("cls"); init_players(); cout<<"我的号位:"<<my_number+1<<endl <<"我的身份:"; switch(players[my_number].type){ case nvwu: cout<<"女巫\n";break; case yuyanjia: cout<<"预言家\n";break; case cunmin: cout<<"村民\n";break; case langren:cout<<"狼人\n";break; case lieren:cout<<"猎人\n"; break; case shouwei:cout<<"守卫\n";break; } change_daytime(); system("pause"); system("cls"); cout<<"游戏加载中.";int ppppp=rand()%3+2; for(int i=0;i<ppppp;i++){ for(int j=0;j<6;j++){ cout<<"."; Sleep(rand()%100+150); } cout<<"\b\b\b\b\b\b \b\b\b\b\b\b"; } print(); } /*每一天开始前的操作*/ void something_before_everyday(){ change_night(); system("cls"); print(); int langrensha=-1,NVWUDU=-1,nvwujiu=-1,shouweishou=-1; gotoxy2(0,7); cout<<"________________________"; gotoxy2(0,8); color2(white); cout<<"天黑~请闭眼~~~\n"; } /*守卫操作*/ int shouweishou=0; int ShouWei(){ color2(blue); cout<<"守卫~请睁眼~~\n"; Sleep(1500); cout<<"你要守护的是?\n"; if(players[my_number].type==shouwei&&players[my_number].die_or_life == life){ cin>>shouweishou; while(!(shouweishou>=1&&shouweishou<=player_number&&players[shouweishou-1].die_or_life == life)){ cout<<"请重新输入!\n"; cin>>shouweishou; } cout<<"你今晚要守护的是"<<shouweishou<<"号\n"; Sleep(1500); shouweishou--; }else{ if(players[idxshouwei].die_or_life == life){ shouweishou=rand()%10; while(!(shouweishou>=1&&shouweishou<=player_number&&players[shouweishou-1].die_or_life == life)){ shouweishou=rand()%10; } } } Sleep(2000); cout<<"守卫请闭眼"<<endl<<endl; return shouweishou; } /*狼人操作*/ int LangRen(){ int langrensha=-1; color2(red); cout<<"狼人~请睁眼~~~\n"; Sleep(1500); cout<<"你们今晚要杀~谁~~??\n"; if(players[my_number].type==langren&&players[my_number].die_or_life == life){ cin>>langrensha; while(!(langrensha>=1&&langrensha<=player_number&&players[langrensha-1].die_or_life==life)){ cout<<"请重新输入!\n"; cin>>langrensha; } cout<<"你们今晚要杀的是"<<langrensha--<<"号\n"; Sleep(3500); }else{ while(langrensha==-1 || players[langrensha].die_or_life == die || players[langrensha].type==langren){ langrensha=rand()%player_number; } Sleep(3000); } cout<<"狼人请~闭眼~~\n\n"; return langrensha; } /*女巫操作*/ int nvwujiu=0,nvwudu=0,is_nvwujiu=0,is_nvwudu=0; int NvWu(int langrensha){ color2(purple); cout<<"女巫~~请睁眼~~\n"; Sleep(2000); if(players[my_number].type==nvwu&&players[my_number].die_or_life == life){ if(is_nvwujiu) cout<<"你已经用过解药\n",Sleep(1500); else { cout<<"今晚"<<langrensha+1<<"号死了,你想用解药吗?(1想 / 2不想)\n"; int is_nvwujie=0; cin>>is_nvwujie; while(is_nvwujie!=1&&is_nvwujie!=2){ cout<<"请重新输入\n"; cin>>is_nvwujie; } if(is_nvwujie==1) { Sleep(1000); cout<<"已经解救"<<langrensha+1<<"号\n"; nvwujiu=langrensha; } is_nvwujiu=1; } Sleep(1500); if(::is_nvwudu) cout<<"你已经用过解药\n",Sleep(1500); else { cout<<"你想用毒药吗?(1想 / 2不想)\n"; Sleep(1500); int is_nvwudu=0; cin>>is_nvwudu; while(is_nvwudu!=1&&is_nvwudu!=2){ cout<<"请重新输入\n"; cin>>is_nvwudu; } if(is_nvwudu==1){ Sleep(1500); cout<<"你想毒谁?\n"; cin>>nvwudu; while(!(nvwudu>=1&&nvwudu<=player_number&&players[nvwudu].die_or_life==life)){ cout<<"请重新输入\n"; cin>>nvwudu; } nvwudu--; Sleep(1500); cout<<"已经毒死了"<<nvwudu+1<<"号\n"; } ::is_nvwudu=1; } }else{ if(players[idxnvwu].die_or_life == life){ if(!is_nvwujiu) { int is_jiu=rand()%8; if(is_jiu==0){ nvwujiu=langrensha; is_nvwujiu=1; } } if(!is_nvwudu) { int is_du=rand()%4; if(is_du==0){ int num=rand()%player_number; nvwudu=num; is_nvwudu=1; } } } } cout<<"女巫~请闭眼~~\n\n"; return nvwujiu*10000+nvwudu;//传回两个变量,“加密”操作 } int yuyanjiabixutoupiao=-1; /*预言家操作*/ void YuYanJia(){ color2(green); cout<<"预言家~请睁眼~~\n"; Sleep(2000); if(players[my_number].type==yuyanjia&&players[my_number].die_or_life == life){ cout<<"请问你想查验谁的身份\n"; int p; cin>>p; while(!(p>=1&&p<=player_number)){ cout<<"请重新输入!\n"; cin>>p; } Sleep(2000); cout<<p<<"号的身份是——"; Sleep(1000); if(players[p-1].type == langren){ cout<<"狼人\n"; players[p-1].is_light = 1; }else{ cout<<"好人\n"; players[p-1].is_light = 2; } }else{ int p=-1; while(p==-1||players[p].die_or_life==die||p==idxlieren) p=rand()%player_number; if(players[p].type==langren)//锁定目标! { yuyanjiabixutoupiao=p; } } cout<<"预言家~~请闭眼~~\n"; } /*黑夜操作*/ int LANGRENSHA=-1,NVWUDU=-1,NVWUJIU=-1,SHOUWEISHOU=-1; void Night(){ LANGRENSHA=-1,NVWUDU=-1,NVWUJIU=-1,SHOUWEISHOU=-1; //如果有12人局,添加守卫 if(player_number==12){ SHOUWEISHOU=ShouWei(); Sleep(2000); } /*狼人部分*/ LANGRENSHA=LangRen(); Sleep(3500); /*女巫部分*/ int nvwu=NvWu(LANGRENSHA); NVWUDU=nvwu%10+nvwu/10%10; NVWUJIU=nvwu/10000%10+nvwu/100000%10; Sleep(3000); /*预言家部分*/ YuYanJia(); Sleep(2000); } /*猎人操作*/ void Lieren(){ int lierendai=-1; cout<<idxlieren+1<<"号是猎人\n"; players[idxlieren].is_light = 1; Sleep(1000); if(idxlieren==my_number){ cout<<"你想带走几号?\n"; cin>>lierendai; while(lierendai<1||lierendai>player_number||players[lierendai].die_or_life==die){ cout<<"请重新输入!\n"; cin>>lierendai; } lierendai--; }else{ lierendai=rand()%player_number; while(players[lierendai].die_or_life == die){ lierendai=rand()%player_number; } } Sleep(2000); cout<<"猎人选择带走"<<lierendai+1<<"号\n"; Sleep(2000); players[lierendai].die_or_life = die; } void police_die(); /*判断谁死了*/ void panduansiwang(){ system("cls"); print(); gotoxy2(0,7); cout<<"________________________\n"; Sleep(3000); color2(white); cout<<"天亮了\n"; Sleep(2000); gotoxy2(0,9); cout<<"昨晚"; bool is_die[15]={false},is_die_lieren=false,flag=false; for(int i=0;i<player_number;i++) { if(players[i].die_or_life==life) { if(i==LANGRENSHA||i==NVWUDU) { if(players[i].type==lieren) is_die_lieren=true; players[i].killer= (i==LANGRENSHA ? langren:nvwu); players[i].die_or_life=die; is_die[i]=true; } if(i==SHOUWEISHOU||i==NVWUJIU) { if(players[i].type==lieren) is_die_lieren=false; players[i].killer=-1; players[i].die_or_life=life; is_die[i]=false; } } } bool is_police_die=false; for(int i=0;i<player_number;i++) { if(is_die[i]) { if(flag) cout<<"和"<<i+1<<"号"; else cout<<i+1<<"号",flag=true; if(i==idx_police) is_police_die=true; } } if(flag) cout<<"死了\n"; else cout<<"是平安夜\n"; if(is_die_lieren) Lieren(); if(is_police_die) police_die(); } /*选警长*/ void choose_police(){ system("cls"); print(); color2(blue); gotoxy2(0,7); cout<<"________________________\n"; color2(yellow); cout<<"下面开始选举警长,各位不能选举自己~\n"; int tong[100]={0},cannot[100],must[100]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; memset(cannot,-1,sizeof(cannot)); CHOOSE: color2(yellow); Sleep(1500); for(int i=0;i<player_number;i++) { if(players[i].die_or_life==life&&!is_include(cannot,i,player_number)) { if(i==my_number) { cout<<"你要选举几号?\n"; int n; cin>>n; while(n<1||n>player_number||n==i+1||players[n-1].die_or_life==die||!is_include(must,n-1,player_number)) { cout<<"请重新输入!\n"; cin>>n; } cout<<i+1<<"号选举"<<n--<<"号\n"; tong[n]++; } else { int n=rand()%player_number; while(n==i||players[n].die_or_life==die||!is_include(must,n,player_number)) n=rand()%player_number; cout<<i+1<<"号选举"<<n+1<<"号\n"; tong[n]++; } Sleep(1500); } } int idx_max=-1,maxn=-1,len=0; for(int i=0;i<player_number;i++) if(maxn<tong[i]) { maxn=tong[i]; idx_max=i; } int maxn_arr[15]={0}; for(int i=0;i<player_number;i++) { if(tong[i]==maxn) { maxn_arr[len++]=i; } } color2(blue); if(len>1) { for(int i=0;i<len;i++) { if(i==len-1) { cout<<maxn_arr[i]+1<<"号平票\n"; } else { cout<<maxn_arr[i]+1<<"号,"; } } for(int i=0;i<len;i++) cannot[i]=maxn_arr[i]; for(int i=0;i<player_number;i++) { if(is_include(cannot,i,len)) must[i]=i; else must[i]=-1; } color2(white); goto CHOOSE; } cout<<"恭喜"<<idx_max+1<<"号当选警长\n"; Sleep(3000); idx_police=idx_max; return; } /*投票*/ int toupiao(){ int tong[100]={0},cannot[100]={},must[100]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; memset(cannot,-1,sizeof(cannot)); gotoxy2(0,7); color2(blue); cout<<"________________________\n"; color(white); cout<<"下面进入投票环节\n"; memset(tong,0,sizeof(tong)); Sleep(2000); TOUPIAO: for(int i=0;i<player_number;i++){ if(players[i].die_or_life == life&&!is_include(cannot,i,player_number)){ if(i==my_number){ color(white); cout<<"你要投几号?\n"; int n; cin>>n; while(!(n>=1&&n<=player_number&&is_include(must,n-1,player_number))){ cout<<"请重新输入!\n"; cin>>n; } Sleep(2000); cout<<setw(2)<<my_number+1<<"号投了"<<setw(2)<<n<<"号"; if(my_number==n-1) color2(red),cout<<"快来看!这有个疯子投自己!"; if(i==idx_police) color2(yellow),cout<<"(警长)\n"; else cout<<"\n"; if(i==idx_police) tong[n-1]++; tong[n-1]++; }else{ color2(white); int t=-1; while(t==-1 || players[t].die_or_life == die || t==i || !is_include(must,t,player_number)){ if(i==idxyuyanjia&&yuyanjiabixutoupiao!=-1) { t=yuyanjiabixutoupiao; yuyanjiabixutoupiao=-1; continue; } t=rand()%player_number; if(is_include(idxlangren,i,nlangren)) { if(players[t].type == langren) t=-1; } } cout<<setw(2)<<i+1<<"号"<<"投了"<<setw(2)<<t+1<<"号"; if(i==idx_police) cout<<"(警长2票)\n"; else cout<<"\n"; if(i==idx_police) tong[t]++; tong[t]++; } Sleep(rand()%1000+1000); } } int idx_max=-1,maxn=-1,len=0; for(int i=0;i<player_number;i++) if(maxn<tong[i]) { maxn=tong[i]; idx_max=i; } int maxn_arr[15]={0}; for(int i=0;i<player_number;i++) { if(tong[i]==maxn) { maxn_arr[len++]=i; } } color2(blue); if(len>1) { for(int i=0;i<len;i++) { if(i==len-1) { cout<<maxn_arr[i]+1<<"号平票\n"; } else { cout<<maxn_arr[i]+1<<"号,"; } } for(int i=0;i<len;i++) cannot[i]=maxn_arr[i]; for(int i=0;i<player_number;i++) { if(is_include(cannot,i,len)) must[i]=i; else must[i]=-1; } color2(white); goto TOUPIAO; } cout<<idx_max+1<<"号"<<"出局\n"; Sleep(4000); players[idx_max].die_or_life = die; players[idx_max].killer = good; return idx_max; } /*警长死亡*/ void police_die(){ color2(yellow); int type; if(idx_police==my_number) { Sleep(1550); cout<<"你是想撕毁警徽还是移交警徽?(撕毁输入1,移交输入2)"; cin>>type; while(!(type==1||type==2)) { cout<<"请重新输入!\n"; cin>>type; } } else{ type=rand()%3+1; } if(type==1) { cout<<"警长选择撕毁警徽\n"; Sleep(1000); idx_police=-1; } else { int lucky=-1; while(lucky==-1||players[lucky].die_or_life==die) lucky=rand()%player_number; cout<<"警长选择把警徽移交给"<<lucky+1<<"号\n"; Sleep(1500); idx_police=lucky; } } /*故事的最后*/ void the_end(){ system("cls"); switch(is_end()){ case 1:cout<<"好人胜利\n\n"; break; case 2:cout<<"狼人胜利\n\n"; break; case 3:cout<<"本局平局\n\n"; break; } for(int i=0;i<player_number;i++){ cout<<i+1<<"号位:\t"; switch(players[i].type){ case nvwu: cout<<"女巫\t";break; case yuyanjia: cout<<"预言家\t";break; case cunmin: cout<<"村民\t";break; case langren:cout<<"狼人\t";break; case lieren:cout<<"猎人\t"; break; case shouwei:cout<<"守卫\t";break; } cout<<"最终"; switch(players[i].killer){ case nvwu:cout<<"被女巫毒死\n"; break; case langren:cout<<"被狼人杀死\n"; break; case good:cout<<"被投票出局\n"; break; case lieren:cout<<"被猎人带走\n";break; default :cout<<"存活\n"; } cout<<endl; } } void slowsay(string s){for(int i=0;i<s.size();i++){cout<<s[i];Sleep(30);}} int ti(float a) {return ((int)(a*10+5))/10;} void Setpos(float x,float y){COORD pos;pos.X=ti(y*4)/2;pos.Y=ti(x);SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);} void Color(int a){if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);if(a==4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);if(a==6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);if(a==7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);if(a==8) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);if(a==9) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_GREEN|BACKGROUND_BLUE);if(a==10) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE);if(a==11) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_BLUE);if(a==12) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN);if(a==13) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY);if(a==14) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN|FOREGROUND_BLUE);} int Blomax,Ren,Exp,Expmax,Lv,Lvl,Ice,Drug,ar1,ar2,Tar1,Tar2,bl,br,Win,T,Tb,Sy,Up,Upt,Down,u1,u2,Kill,Killb,L,Ll[4],Li,D,Gd[10],Biao,Fire,Fir,Water,Thun,Wind,Magne,I[20][2],ib,Dis,Disb,Dis1,Disb1,Boss,Bblo,Bblomax,Bwhat1,Bwhat2,Bwhat3,Bgo1[10],Bgo2[10],Bgo3[10],Bbr,Bbl,Bl[4]; float X,Y,Vx,Vy,Ding,Blo,Hui,Bx1,By1,Bx2,By2,Bx3,By3,Bvx1,Bvy1,Bvx2,Bvy2,Bvx3,Bvy3,Bway[1001][2]; struct bullet{float x,y,vx,vy;int what;int a,t,How;int life;bool kill;}B[100001]; void Map(int a,int b); void Pan(int a,float x,float y,int b){ float Nox[4],Noy[4];Nox[0]=X,Noy[0]=Y; if(Down==1&&X==22) Nox[1]=X+1,Noy[1]=Y-0.5,Nox[2]=X-1,Noy[2]=Y-0.5;else if(Down==2) Nox[1]=X+1,Noy[1]=Y-0.5,Nox[2]=-10,Noy[2]=-10;else if(Down==1||X<18) Nox[1]=X-1,Noy[1]=Y-0.5,Nox[2]=-10,Noy[2]=-10;else Nox[1]=X+1,Noy[1]=Y-0.5,Nox[2]=X-1,Noy[2]=Y-0.5; for(int i=0;i<3;i++){ if(a==-1){if(abs(x-Nox[i])+abs(y-Noy[i])<1.5) {if(B[b].what==-10)Exp+=2;if(B[b].what==-11)Exp+=1;B[b].life=0;if(B[b].life==0&&b==bl) bl++;Map(3,b);break;}} if(a==-2){if(abs(x-Nox[i])+abs(y-Noy[i])<2.5) {if(B[b].what==-2)Exp+=5,Biao+=5;if(B[b].what==-3)Fire=300,Ice=0,Fir=3;if(B[b].what==-4)Water=200;if(B[b].what==-5){Wind=70;Ding=28.25;Ice=0;if(Y<Ding-1)Vy=5;else Vy=0;if(Up>=1) Vx=-5;if(Down==2) Vx=5;}if(B[b].what==-6){Thun=200;system("color 1F");Sleep(20);system("color 6F");Sleep(10);system("color 0F");}if(B[b].what==-7)Magne=300;if(B[b].what==-8)Ice=0,Drug=0,Blo=fmin((float)Blomax,Blo+20);if(B[b].what==-9)Exp=fmin((float)Expmax,Exp+20);B[b].life=0;if(B[b].life==0&&b==bl) bl++;Map(3,b);break;}} }if(Wind==0&&Thun==0&&(B[b].kill!=0||Killb>=15||Ren==1&&Killb>0)) return; for(int i=0;i<3;i++){ if((Wind>=1||Thun>=1)&&abs(x-Nox[i])+abs(y-Noy[i])<2.5) {if(B[b].what<98)Exp+=2;B[b].life=0;Map(3,b);break;} if(a==1) {if(abs(x-Nox[i])<0.5&&abs(y-Noy[i])<1) {if(B[b].what>=99)Blo-=10;if(B[b].what==14)Blo-=15,Ice=100,B[b].life=0;else if(B[b].what==15)Blo-=20,Ice=0,B[b].life=0;else if(B[b].what==17)Blo-=5,Drug=100,B[b].life=0;else if(B[b].what>=13&&B[b].what<=17)Blo-=10,B[b].life=0;else Blo-=15;B[b].kill=1,Killb=20;Kill=1;Map(3,b);break;}} if (a==2||a==6||a==8||a==9||a==10||a==11||a==12) { if(abs(x-Nox[i])+abs(y-Noy[i])<1.5) { if(a==2)Blo-=20; else if(a==8)Blo-=10; else Blo-=15;B[b].kill=1,Killb=20;Kill=1;if(a!=2){B[b].life=0;if(B[b].life==0&&b==bl) bl++;Map(3,b);break;}}} if(a==4) {if((Wind>=1||Thun>=1)&&abs(x-Nox[i])<1.5&&Noy[i]-y<=0&&Noy[i]-y>=-8) {if(B[b].what<98)Exp+=2;B[b].life=0;Map(3,b);break;}if(abs(x-Nox[i])<1&&Noy[i]-y<=0&&Noy[i]-y>=-8) {Blo-=25,B[b].kill=1,Killb=20;Kill=1;Vy=-1;Y-=0.5;break;}} } } void Map(int a,int b){ Color(0); if(a==-1){ if(Boss==1||Boss==6){if(Bwhat1==5){if(ti(Bx1)==20)Setpos(Bx1,By1),cout<<"==";else Setpos(Bx1,By1),cout<<" ";}else{Setpos(Bx1-1,By1-0.5),cout<<" ";Setpos(Bx1,By1-1),cout<<" ";Setpos(Bx1+1,By1-0.5),cout<<" ";if(abs(ti(Bx1)-20)<=1)Setpos(20,By1-1),cout<<"======";}} if(Boss==2||Boss==6){Setpos(Bx2-1,By2-1);cout<<" ";Setpos(Bx2,By2-1);cout<<" ";Setpos(Bx2+1,By2-1),cout<<" ";Color(0);if(abs(ti(Bx2)-20)<=1)Setpos(20,By2-1),cout<<"======";} if(Boss==3||Boss==6){Setpos(Bx3-1,By3-0.5);cout<<" ";Setpos(Bx3,By3);cout<<" ";Setpos(Bx3+1,By3-1),cout<<" ";Color(0);if(abs(ti(Bx3)-20)<=1)Setpos(20,By3-1),cout<<"=======";} if(X<0)return;if(X>=17&&X<=19){Setpos(X-1,Y);cout<<" ";Setpos(X,Y-1);cout<<" ";Setpos(X+1,Y-1),cout<<" ";}else if(X<=23&&X>=21){Setpos(X+1,Y);cout<<" ";Setpos(X,Y-1);cout<<" ";Setpos(X-1,Y-1),cout<<" ";}else if(X>23){Setpos(X,Y-1);cout<<" ";Setpos(X-1,Y-0.5),cout<<" ";}else if(X<17&&Upt!=0){Setpos(X,Y-1);cout<<" ";Setpos(X+1,Y-1.5),cout<<" ";}else if(X<17){Setpos(X,Y-1);cout<<" ";Setpos(X+1,Y-0.5),cout<<" ";}if(Thun>0){Setpos(X-2,Y-1),cout<<" ";Setpos(X+2,Y-1),cout<<" ";Setpos(X,Y+2),cout<<" ";Setpos(X,Y-2.5),cout<<" ";Setpos(X-1,Y+1),cout<<" ";Setpos(X+1,Y+1),cout<<" ";Setpos(X-1,Y-2),cout<<" ";Setpos(X+1,Y-2),cout<<" ";Setpos(20,Y-2.5),cout<<"============";}if(Wind!=0){Setpos(X+1,Y-5);cout<<" ";Setpos(X,Y-5);cout<<" ";Setpos(X-1,Y-5);cout<<" ";Setpos(20,Y-5),cout<<"========";}if(Water!=0){Setpos(X,Y-4);cout<<" ";Setpos(X+2,Y-3.5);cout<<" ";Setpos(X-2,Y-3.5);cout<<" ";Setpos(X+1,Y-3.5);cout<<" ";Setpos(X-1,Y-3.5);cout<<" ";Setpos(20,Y-5),cout<<"========";}if(Fire!=0){Setpos(X,Y+1),cout<<" ";Setpos(X+1,Y),cout<<" ";Setpos(X-1,Y-1),cout<<" ";Setpos(20,Y-1);cout<<"======";} } if(a==0){ if(Boss==1||Boss==6){if(Bwhat1==5)Color(5),Setpos(Bx1,By1),cout<<"█",Color(0);else if(Bwhat1==4&&Bgo1[1]>6&&Bgo1[1]<11)Color(4),Setpos(Bgo1[5]-1,Bgo1[6]),cout<<"︻",Setpos(Bgo1[5],Bgo1[6]-1),cout<<"【",Setpos(Bgo1[5],Bgo1[6]+1),cout<<"】",Setpos(Bgo1[5]+1,Bgo1[6]),cout<<"︼",Color(0);else{Setpos(Bx1-1,By1-0.5),Color(0),cout<<"●●";Setpos(Bx1,By1-1);if(Bwhat1==2&&Bgo1[1]<=5)Color(1);else if(Bwhat1==3&&Bgo1[1]<=5)Color(5);else if(Bwhat1==6&&Bgo1[1]<=5)Color(8); else Color(4);if(Bwhat1==4) Setpos(Bx1,By1-0.5),cout<<"██(";else cout<<")██(";Setpos(Bx1+1,By1-0.5),cout<<"……";Color(0);}} if(Boss==2||Boss==6){Setpos(Bx2-1,By2-1);Color(0),cout<<"\\ ";Color(0);cout<<".";Setpos(Bx2,By2-1);Color(3);cout<<"◥";Color(5),cout<<"JJJ";Color(0),cout<<">";Color(3);Setpos(Bx2+1,By2-1),cout<<"◢█◣";Color(0);} if(Boss==3||Boss==6){Setpos(Bx3-1,By3-0.5);if(Bwhat3==3||Bwhat3==9) Color(1);else if(Bwhat3==4||Bwhat3==10) Color(4);else if(Bwhat3==5||Bwhat3==11) Color(5);if(Bwhat3==11)cout<<' ';else if(Bwhat3==6) Color(3);else Color(2);cout<<"●-";Setpos(Bx3,By3);if(Bwhat3==11)cout<<"/";else cout<<"┃";Color(0);Setpos(Bx3+1,By3-1),cout<<"●●●";} if(X<0)return;if(Ren==2) Color(12);if(Ren==3) Color(1);if(Ren==4) Color(3);if(Ren==5) Color(4);if(Ren==6) Color(2);if(Drug!=0&&T%5!=0) Color(11);if(Drug!=0&&T%5==0) Color(11);if(Ice!=0) Color(6);if(b==1) Color(8);if(Li!=0) Color(5);if(Ren==1&&Killb>0&&T%4<2) Color(13);if(Wind>0&&T%4<=1) Color(1);if(Wind>0&&T%4>=2) Color(0);if(Thun>0&&T%4<=1) Color(1);if(Thun>0&&T%4>=2) Color(6); if(X>=17&&X<=19){Setpos(X-1,Y);cout<<"●";Setpos(X,Y-1);cout<<"━/";if(T%10<3) Setpos(X+1,Y-1),cout<<"┛╲";else if(T%10<6) Setpos(X+1,Y-1),cout<<"┦ ";else Setpos(X+1,Y-1),cout<<"╯>";if(Wind>0&&T%3==0) Setpos(X+1,Y-1),cout<<"┛╲";else if(Wind>0&&T%3==1) Setpos(X+1,Y-1),cout<<"┦ ";else if(Wind>0&&T%3==2)Setpos(X+1,Y-1),cout<<"╯>";}else if(X<=23&&X>=21){Setpos(X+1,Y);cout<<"●";Setpos(X,Y-1);cout<<"━\\";if(T%10<3) Setpos(X-1,Y-1),cout<<"┓╱";else if(T%10<6) Setpos(X-1,Y-1),cout<<"┪ ";else Setpos(X-1,Y-1),cout<<"╮>";if(Wind>0&&T%3==0) Setpos(X-1,Y-1),cout<<"┓╱";else if(Wind>0&&T%3==1) Setpos(X-1,Y-1),cout<<"┪ ";else if(Wind>0&&T%3==2)Setpos(X-1,Y-1),cout<<"╮>";}else if(X>23){Setpos(X,Y-1);cout<<"━ ●";Setpos(X-1,Y-0.5),cout<<"│>";}else if(X<17&&Upt!=0){Setpos(X,Y-1);cout<<"━ ●";Setpos(X+1,Y-1.5),cout<<"╱ >";}else if(X<17){Setpos(X,Y-1);cout<<"━ ●";Setpos(X+1,Y-0.5),cout<<"│>";}if(Thun>0){Setpos(X-2,Y-1),cout<<"▄▄";Setpos(X+2,Y-1),cout<<"▄▄";Setpos(X,Y+2),cout<<"▌";Setpos(X,Y-2.5),cout<<"▌";Setpos(X-1,Y+1),cout<<"█";Setpos(X+1,Y+1),cout<<"█";Setpos(X-1,Y-2),cout<<"█";Setpos(X+1,Y-2),cout<<"█";}if(Magne>0&&T%7<2)Setpos(X,Y),Color(5),cout<<"★";if(Wind>1){if(T%6<2)Color(1);else Color(0);if(T%8<=1){Setpos(X+1,Y-5);cout<<"---- --";Setpos(X,Y-5);cout<<"- --- -";Setpos(X-1,Y-5);cout<<"--- - --";}else if(T%8<=3){Setpos(X+1,Y-5);cout<<"------ ";Setpos(X,Y-5);cout<<" -- ---";Setpos(X-1,Y-5);cout<<"----- - ";}else if(T%8<=5){Setpos(X+1,Y-5);cout<<" ------";Setpos(X,Y-5);cout<<"-- -- -";Setpos(X-1,Y-5);cout<<"- ----- ";}else if(T%8<=7){Setpos(X+1,Y-5);cout<<"-- ----";Setpos(X,Y-5);cout<<" --- -- ";Setpos(X-1,Y-5);cout<<"- - ----";}}if(Water!=0){Color(1);if(T%20<5){Setpos(X+2,Y-3);cout<<"■";Setpos(X+1,Y-3.5);cout<<"■";Setpos(X-1,Y-2.5);cout<<"■";Setpos(X-2,Y-3);cout<<"■";}else if(T%20<10||T%20>=15){Setpos(X+2,Y-3);cout<<"■";Setpos(X,Y-4);cout<<"■■";Setpos(X-2,Y-3); cout<<"■";}else if(T%20<15){Setpos(X+2,Y-3.5);cout<<"■";Setpos(X+1,Y-3);cout<<"■";Setpos(X-1,Y-3.5);cout<<"■";Setpos(X-2,Y-3);cout<<"■";}}if(Fire!=0){if(T%6<3)Color(4);else Color(5);if(Fir>=1)Setpos(X,Y+1),cout<<"●";if(Fir>=2)Setpos(X+1,Y),cout<<"●";if(Fir>=3)Setpos(X-1,Y-1),cout<<"●";} } if(a==1||a==3){ if(B[b].what==1){Nor;Setpos(B[b].x,B[b].y-1);if(ti(B[b].x)==20)cout<<"======";else cout<<" ";if(B[b].life!=0){B[b].y-=B[b].vy;Setpos(B[b].x,B[b].y);if(B[b].How<=1) Color(13);else Color(4);cout<<"●";if(a==1) Pan(1,B[b].x,B[b].y,b);}} if(B[b].what==2){Nor;Setpos(B[b].x-1,B[b].y-1);if(ti(B[b].x-1)==20)cout<<"======";else cout<<" ";Setpos(B[b].x,B[b].y-1);if(ti(B[b].x)==20)cout<<"======";else cout<<" ";Setpos(B[b].x+1,B[b].y-1);if(ti(B[b].x+1)==20)cout<<"======";else cout<<" ";if(B[b].life!=0){B[b].y-=B[b].vy;Setpos(B[b].x,B[b].y);Color(5);if(B[b].How==0){Setpos(B[b].x-1,B[b].y),cout<<"↑";Setpos(B[b].x,B[b].y-1),cout<<"←┼ →";Setpos(B[b].x+1,B[b].y),cout<<"↓";}else if(B[b].How==1){Setpos(B[b].x-1,B[b].y-1),cout<<"↖ ↗";Setpos(B[b].x,B[b].y),cout<<"╳";Setpos(B[b].x+1,B[b].y-1),cout<<"↙ ↘";} if(a==1) Pan(2,B[b].x,B[b].y,b);}} if(B[b].what==3||B[b].what==5){Nor;Setpos(B[b].x,B[b].y);if(ti(B[b].x)==20)cout<<"==";else cout<<" ";if(B[b].life!=0){B[b].y-=B[b].vy;B[b].x-=B[b].vx;Setpos(B[b].x,B[b].y);if(B[b].How==1) Color(5);else Color(7);cout<<"◎";}} if(B[b].what==4){Nor;Setpos(B[b].x,fmax((float)0,B[b].y-8));if(ti(B[b].x)==20){for(int i=max(0,(int)B[b].y-8);i<=B[b].y;i++)cout<<"==";}else {for(int i=max(0,(int)B[b].y-8);i<=B[b].y;i++)cout<<" ";}if(B[b].life!=0){B[b].y-=B[b].vy;Setpos(B[b].x,fmax((float)0,B[b].y-8));Color(6); for(int i=max(0,(int)B[b].y-8);i<=B[b].y;i++)cout<<"═"; if(a==1) Pan(4,B[b].x,B[b].y,b);}} if(B[b].what==6||B[b].what==8||B[b].what==9){Nor;Setpos(B[b].x-1,B[b].y);if(ti(B[b].x)-1==20)cout<<"==";else cout<<" ";Setpos(B[b].x+1,B[b].y);if(ti(B[b].x)+1==20)cout<<"==";else cout<<" ";Setpos(B[b].x,B[b].y-1);if(ti(B[b].x)==20)cout<<"======";else cout<<" ";if(B[b].life!=0){B[b].y-=B[b].vy;B[b].x-=B[b].vx;Setpos(B[b].x,B[b].y-1);if(B[b].what==6){if(B[b].How<=1) Color(1); else Color(6);}if(B[b].what==9){if(B[b].How<=1) Color(4); else Color(8);}if(B[b].what==8)Color(5);Setpos(B[b].x-1,B[b].y);cout<<"︹";Setpos(B[b].x+1,B[b].y);cout<<"︺";Setpos(B[b].x,B[b].y-1);if(B[b].How%2==1) cout<<"〔●〕"; else cout<<"﹝○﹞"; if(a==1) Pan(6,B[b].x,B[b].y,b);}} if(B[b].what==7){Nor;Setpos(B[b].x,B[b].y);if(B[b].How<0) for(int i=19;i>=20+B[b].How;i--) {Setpos(i,B[b].y);cout<<" ";}if(B[b].How>0) for(int i=21;i<=20+B[b].How;i++) {Setpos(i,B[b].y);cout<<" ";}if(B[b].life!=0){B[b].y-=B[b].vy;if(B[b].How<0) for(int i=19;i>=20+B[b].How;i--) {Setpos(i,B[b].y);cout<<"║"; if(a==1) Pan(7,i,B[b].y,b);}if(B[b].How>0) for(int i=21;i<=20+B[b].How;i++) {Setpos(i,B[b].y);cout<<"║"; if(a==1) Pan(7,i,B[b].y,b);}}} if(B[b].what==10||B[b].what==11||B[b].what==12){Nor;Setpos(B[b].x,B[b].y);if(ti(B[b].x)==20)cout<<"==";else cout<<" ";if(B[b].life!=0){B[b].x-=B[b].vx;B[b].y-=B[b].vy;if(B[b].How==1){B[b].vy-=0.2;}else B[b].vx-=0.35;if(B[b].x>=25) B[b].x=25,B[b].vx*=-0.8;if(B[b].what==11&&B[b].y<=1) B[b].y=1,B[b].vy*=-1;if(B[b].what==12&&B[b].y<=1) B[b].y=1,B[b].vx=0,B[b].vy=-0.5,B[b].How=1;Setpos(B[b].x,B[b].y);if(B[b].what==11)Color(1);else if(B[b].what==12)Color(5);else Color(0);if(B[b].t%4<2)cout<<"▃";else cout<<"▍";if(a==1) Pan(B[b].what,B[b].x,B[b].y,b);}} if(B[b].what>=13&&B[b].what<=17){Nor;Setpos(B[b].x,B[b].y);if(ti(B[b].x)==20)cout<<"====";else cout<<" ";if(B[b].life!=0){B[b].x-=B[b].vx;B[b].y-=B[b].vy;Setpos(B[b].x,B[b].y);if(B[b].what==14) Color(1);else if(B[b].what==15) Color(4);else if(B[b].what==16) Color(5);else if(B[b].what==17) Color(3);else Color(2);cout<<"●";if(B[b].what==14)cout<<"*";if(B[b].what==15)cout<<"";if(B[b].what==16)cout<<"<";if(B[b].what==17)cout<<"X";} if(a==1) Pan(1,B[b].x,B[b].y,b);} if(B[b].what==98&&B[b].life!=0){B[b].y-=B[b].vy;Setpos(B[b].x,B[b].y);if(ti(B[b].x==20))cout<<"==";else cout<<" ";if(B[b].y<=3)B[b].life=0;} if(B[b].what>=99){system("color 2f");if(B[b].y<=3)B[b].life=0;if(B[b].life!=0){B[b].y-=B[b].vy;Setpos(B[b].x,B[b].y);Color(5);if(B[b].what==99)cout<<"█";if(B[b].what>=100&&B[b].what<200){if(B[b].what%5==0)cout<<"我";if(B[b].what%5==1)cout<<"是";if(B[b].what%5==2)cout<<"最";if(B[b].what%5==3)cout<<"强";if(B[b].what%5==4)cout<<"的";}if(B[b].what>=200&&B[b].what<300){if(B[b].what%6==0)cout<<"神";if(B[b].what%6==1)cout<<"级";if(B[b].what%6==2)cout<<"怪";if(B[b].what%6==3)cout<<"物";if(B[b].what%6==4)cout<<"之";if(B[b].what%6==5)cout<<"光";}if(B[b].what>=300&&B[b].what<400){if(B[b].what%8==0)cout<<"你";if(B[b].what%8==1)cout<<"长";if(B[b].what%8==2)cout<<"的";if(B[b].what%8==3)cout<<"跟";if(B[b].what%8==4)cout<<"粑";if(B[b].what%8==5)cout<<"粑";if(B[b].what%8==6)cout<<"似";if(B[b].what%8==7)cout<<"的";}if(B[b].what>=400&&B[b].what<500){if(B[b].what%8==0)cout<<"还";if(B[b].what%8==1)cout<<"不";if(B[b].what%8==2)cout<<"快";if(B[b].what%8==3)cout<<"跪";if(B[b].what%8==4)cout<<"倒";if(B[b].what%8==5)cout<<"在";if(B[b].what%8==6)cout<<"朕";if(B[b].what%8==7)cout<<"前";}if(B[b].what>=500&&B[b].what<600){if(B[b].what%8==0)cout<<"看";if(B[b].what%8==1)cout<<"懂";if(B[b].what%8==2)cout<<"这";if(B[b].what%8==3)cout<<"句";if(B[b].what%8==4)cout<<"话";if(B[b].what%8==5)cout<<"的";if(B[b].what%8==6)cout<<"是";if(B[b].what%8==7)cout<<"猪";} if(a==1) Pan(1,B[b].x,B[b].y,b);}} if(B[b].what==-1){Nor;Setpos(B[b].x,B[b].y);if(ti(B[b].x)==20)cout<<"==";else cout<<" ";if(Boss==0) B[b].life=0;else if(((Boss==1&&abs(B[b].x-Bx1)+abs(B[b].y-By1)<1.5)||(Boss==2&&abs(B[b].x-Bx2)+abs(B[b].y-By2)<1.5)||(Boss==3&&abs(B[b].x-Bx3)+abs(B[b].y-By3)<1.5)||(B[b].t==10))&&B[b].life==1) Bblo-=8+Lv*2,B[b].life=0;if(B[b].life!=0){if(Boss==1)B[b].x=B[b].x+(Bx1-B[b].x)/(10-B[b].t)*1.0,B[b].y=B[b].y+(By1-B[b].y)/(10-B[b].t)*1.0;if(Boss==2)B[b].x=B[b].x+(Bx2-B[b].x)/(10-B[b].t)*1.0,B[b].y=B[b].y+(By2-B[b].y)/(10-B[b].t)*1.0;if(Boss==3)B[b].x=B[b].x+(Bx3-B[b].x)/(10-B[b].t)*1.0,B[b].y=B[b].y+(By3-B[b].y)/(10-B[b].t)*1.0;Setpos(B[b].x,B[b].y);Color(7);if(B[b].t%2==0) cout<<"+";else cout<<"×";}} if(B[b].what<=-2&&B[b].what>=-9){Nor;Setpos(B[b].x-1,B[b].y);if(ti(B[b].x)-1==20)cout<<"==";else cout<<" ";Setpos(B[b].x+1,B[b].y);if(ti(B[b].x)+1==20)cout<<"==";else cout<<" ";Setpos(B[b].x,B[b].y-1);if(ti(B[b].x)==20)cout<<"======";else cout<<" ";if(B[b].life!=0){B[b].y-=B[b].vy;B[b].x-=B[b].vx;if(B[b].what<=-3&&B[b].what>=-7){if(B[b].x<=7)B[b].x=7;if(B[b].x>=28)B[b].x=28;else if(B[b].x>=B[b].a+1&&B[b].How==1)B[b].How=0;else if(B[b].x<=B[b].a-1&&B[b].How==0)B[b].How=1;if(B[b].How==1&&B[b].vx>=-1)B[b].vx-=0.2;if(B[b].How==0&&B[b].vx<=1)B[b].vx+=0.2;}if(B[b].what==-2) Color(3);if(B[b].what==-3) Color(4);if(B[b].what==-4) Color(1);if(B[b].what==-5) Color(0);if(B[b].what==-6) Color(6);if(B[b].what==-7) Color(5);if(B[b].what==-8) Color(2);if(B[b].what==-9) Color(14);if(T%7<=1&&B[b].what==-5)Color(1);else if(T%7<=1)Color(0);Setpos(B[b].x-1,B[b].y);cout<<"︹";Setpos(B[b].x+1,B[b].y);cout<<"︺";Setpos(B[b].x,B[b].y-1);if(B[b].what==-2) cout<<"﹝镖﹞";if(B[b].what==-3) cout<<"﹝火﹞";if(B[b].what==-4) cout<<"﹝水﹞";if(B[b].what==-5) cout<<"﹝风﹞";if(B[b].what==-6) cout<<"﹝雷﹞";if(B[b].what==-7) cout<<"﹝磁﹞";if(B[b].what==-8) cout<<"﹝血﹞";if(B[b].what==-9) cout<<"﹝验﹞"; if(a==1) Pan(-2,B[b].x,B[b].y,b);}} if(B[b].what==-11||B[b].what==-12){Nor;Setpos(B[b].x,B[b].y);if(ti(B[b].x)==20)cout<<"==";else cout<<" ";if(B[b].life!=0){if(Magne>0)B[b].How++,B[b].x=B[b].x+(X-B[b].x)/(10-B[b].How)*1.0,B[b].y=B[b].y+(Y-B[b].y)/(10-B[b].How)*1.0;B[b].y-=B[b].vy;Setpos(B[b].x,B[b].y);if(B[b].what==-10) Color(5);if(B[b].what==-11) Color(7);if(T%7<=1)Color(2);cout<<"◆"; if(a==1) Pan(-1,B[b].x,B[b].y,b);}} if(B[b].what==-13){Nor;Setpos(B[b].x,B[b].y-0.5);if(ti(B[b].x)==20)cout<<"===";else cout<<" ";if(B[b].life!=0){if(B[b].a==13880086){if(Boss==0) B[b].life=0;else if(((Boss==1&&abs(B[b].x-Bx1)+abs(B[b].y-By1)<1.5)||(Boss==2&&abs(B[b].x-Bx2)+abs(B[b].y-By2)<1.5)||(Boss==3&&abs(B[b].x-Bx3)+abs(B[b].y-By3)<1.5)||(B[b].t==5))&&B[b].life==1) Bblo-=8+Lv*2,B[b].life=0;if(B[b].life!=0){if(Boss==1)B[b].x=B[b].x+(Bx1-B[b].x)/(5-B[b].t)*1.0,B[b].y=B[b].y+(By1-B[b].y)/(5-B[b].t)*1.0;if(Boss==2)B[b].x=B[b].x+(Bx2-B[b].x)/(5-B[b].t)*1.0,B[b].y=B[b].y+(By2-B[b].y)/(5-B[b].t)*1.0;if(Boss==3)B[b].x=B[b].x+(Bx3-B[b].x)/(5-B[b].t)*1.0,B[b].y=B[b].y+(By3-B[b].y)/(5-B[b].t)*1.0;}}else{if(B[B[b].a].life==0) B[b].life=0;else if((abs(B[b].x-B[B[b].a].x)+abs(B[b].y-B[B[b].a].y)<1.5||(B[b].t==5))&&B[b].life==1) Exp+=2,B[B[b].a].life=B[b].life=0;if(B[b].life!=0){B[b].x=B[b].x+(B[B[b].a].x-B[b].x)/(5-B[b].t)*1.0,B[b].y=B[b].y+(B[B[b].a].y-B[b].y)/(5-B[b].t)*1.0;}}Setpos(B[b].x,B[b].y-0.5);if(T%6<3)Color(5);else Color(4);cout<<"●";}} }if(br<bl) {br=-1,bl=0;memset(B,0,sizeof(B));}Color(0); } void Move(){ if(X<3) X=3;if(Y<1) Y=1,Vy=0;if(Y>29) Y=29,Vy=0; if(Ice!=0){X-=Vx/2.0;Y+=Vy/2.0;Vy=fmax(Vy-0.025,(float)0);if(T%6==0&&Up==0&&Y<Ding) Y+=0.25;if(T%6==3&&Up==0&&Y>=Ding) Y-=0.25;if(Up==0&&Y<=Ding-1.25) Vy=0.25;if(Up==0&&Y>=Ding+1.25&&Wind==0) Vy=-0.25;if(Up==0&&Down==0&&Vx>0&&X<=18) Up=0,Down=0,Vx=0,Vy=0,X=18,Setpos(20,Y-2.5),cout<<"==========";else if(Down==2&&X<=22) Up=0,Down=1,Vx=0,Vy=0,X=22,Setpos(20,Y-2.5),cout<<"==========";else if(Up==0&&Down==1&&Vx<0&&X>=22) Up=0,Down=1,Vx=0,Vy=0,X=22,Setpos(20,Y-2.5),cout<<"==========";else if(Up>0&&Down==0&&X>18) Up=0,Vx=0,Vy=0,X=18,Setpos(20,Y-2.5),cout<<"==========";else if(Down==2) Vx+=0.175;else if(Up>0&&Upt==0) Vx-=0.175;else if(Up>0&&Upt>0) {Vx=fmax(Vx-0.125,(float)0);if(Upt==1&&T%2==0)Map(-1,0);if(T%2==0)Upt--;}} else{X-=Vx;Y+=Vy;Vy=fmax(Vy-0.05,(float)0);if(Wind==0){if(T%6==0&&Up==0&&Y<Ding) Y+=0.5;if(T%6==3&&Up==0&&Y>=Ding) Y-=0.5;}else{if(T%2==0&&Up==0&&Y<Ding) Y+=0.5;if(T%2==1&&Up==0&&Y>=Ding) Y-=0.5;}if(Up==0&&Y<=Ding-1.25) Vy=0.5;if(Up==0&&Y>=Ding+1.25&&Wind==0) Vy=-0.5;if(Up==0&&Down==0&&Vx>0&&X<=18) Up=0,Down=0,Vx=0,Vy=0,X=18,Setpos(20,Y-2.5),cout<<"==========";else if(Down==2&&X<=22) Up=0,Down=1,Vx=0,Vy=0,X=22,Setpos(20,Y-2.5),cout<<"==========";else if(Up==0&&Down==1&&Vx<0&&X>=22) Up=0,Down=1,Vx=0,Vy=0,X=22,Setpos(20,Y-2.5),cout<<"==========";else if(Up>0&&Down==0&&X>18) Up=0,Vx=0,Vy=0,X=18,Setpos(20,Y-2.5),cout<<"==========";else if(Down==2) Vx+=0.35;else if(Up>0&&Upt==0) Vx-=0.35;else if(Up>0&&Upt>0) {Vx=fmax(Vx-0.25,(float)0);if(Upt==1)Map(-1,0); Upt--;}} for(int i=bl;i<=br;i++){ if(B[i].what<98)if(B[i].x-B[i].vx<=5||B[i].x-B[i].vx>=30||B[i].y-B[i].vy<=0||B[i].y-B[i].vy>=30){B[i].life=0;Map(1,i);} for(int j=0;j<20;j++)if(B[i].what>0&&B[i].life!=0&&abs(B[i].x-I[j][0])<2&&B[i].y-I[j][1]<=2){Setpos(I[j][0],I[j][1]);if(I[j][0]==20) cout<<"===";else cout<<" ";I[j][0]=I[j][1]=-1;B[i].life=0;Exp+=2;} if(B[i].t>=100)B[i].life=0;if(B[i].life==0&&i==bl) bl++; Map(1,i);if(B[i].life==0) continue; else{B[i].t++; if(B[i].what==1){if(B[i].y<=25&&B[i].How==0) B[i].vy=0,B[i].How=1;if(B[i].t==30) B[i].y+=1.5,B[i].How=2;if(B[i].t==35) B[i].vy=1.5,B[i].How=3;} if(B[i].what==2){if(B[i].t%3==0) B[i].How=!B[i].How;} if(B[i].what==3||B[i].what==5){if(B[i].what==3&&B[i].y<=20) B[i].vy=0;if(B[i].what==5&&B[i].y<=21) B[i].vy=0;if(B[i].t>30&&B[i].t%2==0) B[i].How=!B[i].How;if(B[i].what==5&&B[i].t<=30&&B[i].x<X) B[i].vx=-0.2;else if(B[i].what==5&&B[i].t<=70&&B[i].x>X) B[i].vx=0.2;else B[i].vx=0;if(B[i].t==45){B[i].life=0;br++;B[br].what=4;B[br].x=B[i].x;B[br].y=32;B[br].vy=3;B[br].life=1;}} if(B[i].what==6||B[i].what==8||B[i].what==9){if(B[i].vx<0.25&&B[i].vy<0.25&&B[i].t>=50){B[i].life=0;if(B[i].life==0&&i==bl) bl++;Map(1,i);break;}if(B[i].t%5==0) B[i].How=rand()%4;if(B[i].what==9){if(B[i].t==7){X9:float xx=(rand()%41)/40.0,yy=(rand()%41)/40.0;if(xx<=0.5&&yy<=0.5) goto X9;for(int j=1;j<=4;j++){br++,B[br].what=9;B[br].t=11;B[br].x=B[i].x,B[br].y=B[i].y,B[br].vx=xx,B[br].vy=yy;if(j%2==0)swap(B[br].vx,B[br].vy),B[br].vy*=-1;if(j<=2)B[br].vx*=-1,B[br].vy*=-1;B[br].life=1;}B[i].life=0;}}if(B[i].what==8){if(B[i].x>X&&B[i].vx<1.2) B[i].vx+=fmax((float)0,0.2-B[i].t/25);if(B[i].x<X&&B[i].vx>-1.2) B[i].vx-=fmax((float)0,0.2-B[i].t/25);if(B[i].y>Y&&B[i].vy<1.2) B[i].vy+=fmax((float)0,0.2-B[i].t/25);if(B[i].y<Y&&B[i].vy>-1.2) B[i].vy-=fmax((float)0,0.2-B[i].t/25);}} if(B[i].what>=13&&B[i].what<=15&&B[i].How!=0){if(B[i].x==B[i].How)B[i].vx=0,B[i].How=0;} if(B[i].what==16){if(B[i].x<X&&B[i].vx>=-1) B[i].vx-=0.2;else if(B[i].x>X&&B[i].vx<=1) B[i].vx+=0.2;} } if(B[i].life==1&&B[i].a==0&&B[i].what>0){if(B[i].y>Y&&abs(B[i].x-X)<=3&&((B[i].x-X)*(B[i].x-X)+(B[i].y-Y)*(B[i].y-Y))<Dis) Dis=(B[i].x-X)*(B[i].x-X)+(B[i].y-Y)*(B[i].y-Y),Disb=i;else if(((B[i].x-X)*(B[i].x-X)+(B[i].y-Y)*(B[i].y-Y))<Dis1) Dis1=(B[i].x-X)*(B[i].x-X)+(B[i].y-Y)*(B[i].y-Y),Disb1=i;} } } void Guai(int R,int r){ if(R==-1){br++;B[br].what=-1;B[br].x=X+rand()%3-1;B[br].y=Y+rand()%3-1;B[br].life=1;} if(R<=-2&&R>=-11){br++;B[br].what=R;B[br].x=B[br].a=r;B[br].y=29;if(R<=-3&&R>=-7)B[br].vx=-1;B[br].vy=1;B[br].life=1;} if(R==0){br++;B[br].what=1;B[br].x=r;B[br].y=29;B[br].vy=1;B[br].life=1;} if(R==1){br++;B[br].what=2;B[br].x=r;B[br].y=29;B[br].vy=1;B[br].life=1;} if(R==2||R==3){br++;B[br].what=2*R-1;B[br].x=r;B[br].y=29;B[br].vy=1;B[br].life=1;} if(R==4){br++;B[br].what=6;if(r<5)r=5;if(r>30)r=30;B[br].x=r;if(r==11||r==25) B[br].y=29-(rand()%20);else B[br].y=29;X4:B[br].vx=(rand()%21-10)/30.0;B[br].vy=(rand()%25)/30.0;if(B[br].vx<=0.8&&B[br].vy<=0.8)goto X4;int rx=rand()%50;if(rx==0) B[br].vx=0;B[br].life=1;} if(R==5){br++;B[br].How=r;B[br].what=7;if(B[br].How<0) B[br].x=19;if(B[br].How>0) B[br].x=21;B[br].y=29;B[br].vy=1;B[br].life=1;} } void CpGuai(int R,float x,float y,float xx,float yy){ if(R==4){br++;B[br].what=6;B[br].x=x;B[br].y=y;B[br].vx=xx;B[br].vy=yy;B[br].life=1;} if(R==6||R==7||R==8){br++;B[br].what=4+R;B[br].x=x;B[br].y=y;B[br].vx=xx;B[br].vy=yy;B[br].life=1;} } void MesGuai(int a,int rr){ int R=rand()%rr,r=-10086; if(R==0){if(a==1) r=(5+rand()%8)*2;if(a<=3&&a!=1) r=10+rand()%16;if(a==4) r=rand()%75-20;if(a==5) r=2+rand()%4;if(r!=-10086) Guai(a,r);} } void NorGuai(int a,int b){ if(a==1) {if(b==1||b==41) Guai(0,15),Guai(0,17),Guai(0,19);if(b==21||b==61) Guai(0,21),Guai(0,23),Guai(0,25);if(b==81) Guai(0,11),Guai(0,13),Guai(0,15),Guai(0,17),Guai(0,19);if(b==101||b==141) Guai(0,17),Guai(0,19),Guai(0,21),Guai(0,23),Guai(0,25);if(b==121) Guai(0,15),Guai(0,17),Guai(0,19),Guai(0,21),Guai(0,23);if(b>=160&&b<=260&&b%10==0) Guai(0,b/10-1);if(b>=270&&b<=370&&b%10==0) Guai(0,52-b/10);if(b>=460&&b<=560&&b%10==0) Guai(0,b/10-37),Guai(0,b/10-36),Guai(0,b/10-35);if(b>=570&&b<=670&&b%10==0) Guai(0,78-b/10),Guai(0,77-b/10),Guai(0,76-b/10);if(b>=760&&b<=960&&b%10==0) Guai(0,b/10-66),Guai(0,b/10-65),Guai(0,103-b/10),Guai(0,104-b/10);if(b>=1000&&b<=1300) MesGuai(0,30-b/50);} if(a==2) {if(b<=200&&b%30==1) {int r=rand()%4;if(r==1) r=0;for(int i=0;i<4;i++) if(i!=r) Guai(1,i*4+9);}if(b>200&&b<=220&&b%5==1) Guai(1,18);if(b>220&&b<=300&&b%7==1) Guai(1,b/5-26);if(b>350&&b<=370&&b%5==1) Guai(1,22);if(b>370&&b<=450&&b%7==1) Guai(1,96-b/5);if(b==461||b==501||b==541) Guai(1,13),Guai(1,17),Guai(1,21);if(b==481||b==521||b==561) Guai(1,17),Guai(1,21),Guai(1,25);if(b>=561&&b<=861&&b%20==1) Guai(1,b/40+5);if(b>=561&&b<=861&&b%20==11) Guai(1,35-b/40);if(b>=801&&b<=961&&b%15==1) Guai(1,20);if(b>=1000&&b<=1300) MesGuai(1,30-b/50);} if(a==3) {if(b==1||b==61) Guai(3,15),Guai(2,17),Guai(2,19);if(b==31||b==91) Guai(2,21),Guai(2,23),Guai(3,25);if(b>=120&&b<=220&&b%10==0) Guai(2,b/10+3);if(b>=240&&b<=340&&b%10==0) Guai(2,49-b/10);if(b>=360&&b<=460&&b%20==0) Guai(2,b/10-21),Guai(2,61-b/10);if(b>=480&&b<=580&&b%20==0) Guai(3,b/10-33),Guai(3,73-b/10);if(b>=600&&b<750&&b%30==0) {for(int i=0;i<5;i++) Guai(3,i*3+10);}if(b>=750&&b<830&&b%10==0) if(b<=200&&b%40==1) Guai(2,X);if(b>=830&&b<910&&b%20==0) Guai(2,X);if(b>=910&&b<980&&b%10==0) Guai(2,X);if(b>=1000&&b<=1300) MesGuai(rand()%2+2,40-b/50);} if(a==4) {if(b==1) CpGuai(4,10,29,-0.4,0.7),CpGuai(4,14,29,-0.2,0.7),CpGuai(4,21,29,0,0.65);if(b==41) CpGuai(4,10,29,-0.2,0.7),CpGuai(4,14,29,-0.1,0.7),CpGuai(4,18,29,0,0.65);if(b==81) CpGuai(4,5,20,-0.4,0.35),CpGuai(4,10,29,-0.4,0.7),CpGuai(4,14,29,-0.2,0.7),CpGuai(4,30,20,0.25,0.4),CpGuai(4,21,29,0,0.65);if(b==121) CpGuai(4,5,20,-0.2,0.35),CpGuai(4,10,29,-0.2,0.7),CpGuai(4,14,29,-0.1,0.7),CpGuai(4,30,20,0.4,0.4),CpGuai(4,18,29,0,0.65);if(b==161) CpGuai(4,10,29,-0.4,0.7),CpGuai(4,14,29,-0.2,0.7),CpGuai(4,21,29,0,0.6),CpGuai(4,10,29,-0.2,0.7),CpGuai(4,14,29,-0.1,0.7),CpGuai(4,18,29,0,0.65);if(b>=200&&b<=500&&b%40==1) {float r=0,rr;for(int i=1;i<=5;i++){X5:rr=0.7+(rand()%5)/10.0;if(rr==r)goto X5;r=rr;CpGuai(4,i*3+7,29,0,0.5+(rand()%50)/80.0);}}if(b>540&&b<=565&&b%5==1) CpGuai(4,5,8,-2,0.2);if(b>590&&b<=615&&b%5==1) CpGuai(4,30,8,1.5,0.2);if(b>640&&b<=665&&b%5==1) CpGuai(4,5,8,-1.5,0.3);if(b>690&&b<=715&&b%5==1) CpGuai(4,30,8,2,0.3);if(b>=750&&b<=950&&b%20==1) {float r=0,rr;for(int i=1;i<=3;i++){X6:rr=0.7+(rand()%5)/10.0;if(rr==r)goto X6;r=rr;CpGuai(4,i*5+7+(rand()%3),29,0,0.5+(rand()%50)/200.0);}}if(b>=1000&&b<=1300) MesGuai(4,5);} } void RandGood(){ if(Biao>0){Biao--;Guai(-1,0);} if(Gd[1]==0){Gd[1]=rand()%1000+1;if(Win==7)Gd[1]=10086;Gd[3]=rand()%16+8;} else if(Gd[1]<=5){Guai(-2-Gd[1],Gd[3]);memset(Gd,0,sizeof(Gd));} else if(Gd[1]>=20&&Gd[1]<27){Guai(-8,Gd[3]);memset(Gd,0,sizeof(Gd));} else if(Gd[1]>=30&&Gd[1]<37){Guai(-9,Gd[3]);memset(Gd,0,sizeof(Gd));} else if(Gd[1]>=40&&Gd[1]<70){Gd[2]++;if(Gd[2]%2==1)Guai(-10,Gd[3]);if(Gd[2]>=9)memset(Gd,0,sizeof(Gd));} else if(Gd[1]>=70&&Gd[1]<100){Gd[2]++;if(Gd[2]%2==1)Guai(-11,Gd[3]);if(Gd[2]>=9)memset(Gd,0,sizeof(Gd));} else if(Boss!=0&&Gd[1]>=450&&Gd[1]<=500){Guai(-2,Gd[3]);memset(Gd,0,sizeof(Gd));} else Gd[1]=0; for(int i=0;i<20;i++){if(I[i][0]==-1) continue;Setpos(I[i][0],I[i][1]);Color(0);if(I[i][0]==20) cout<<"===";else cout<<" ";I[i][1]++;if(I[i][0]>=28||I[i][0]<=0||I[i][1]>=29) I[i][0]=I[i][1]=-1;else Color(1),Setpos(I[i][0],I[i][1]),cout<<"■";Color(0);} } void Panboss(int bx,int by){ float Nox[4],Noy[4];Nox[0]=X,Noy[0]=Y; if(Down==1&&X==22) Nox[1]=X+1,Noy[1]=Y-0.5,Nox[2]=X-1,Noy[2]=Y-0.5; else if(Down==2) Nox[1]=X+1,Noy[1]=Y-0.5,Nox[2]=-10,Noy[2]=-10; else if(Down==1||X<18) Nox[1]=X-1,Noy[1]=Y-0.5,Nox[2]=-10,Noy[2]=-10; else Nox[1]=X+1,Noy[1]=Y-0.5,Nox[2]=X-1,Noy[2]=Y-0.5; for(int i=0;i<3;i++){if((Boss==1||Boss==6)&&Wind==0&&Thun==0&&abs(Nox[i]-bx)<1&&abs(Noy[i]-by)<1&&Bgo1[4]==0) Blo-=20,Bgo1[4]=1,Killb=20,Kill=1;if((Boss==2||Boss==6)&&Wind==0&&Thun==0&&abs(Nox[i]-bx)<1&&abs(Noy[i]-by)<1&&Bgo2[8]==0) Blo-=20,Bgo2[8]=1,Killb=20,Kill=1;} } void Boss1(){ for(int j=0;j<20;j++)if(abs(Bx1-I[j][0])<2&&By1-I[j][1]<=2){Setpos(I[j][0],I[j][1]);if(I[j][0]==20) cout<<"===";else cout<<" ";I[j][0]=I[j][1]=-1;Bblo-=8+Lv*2;Exp+=2;} if(Bbr==Bbl&&Bbr!=0) Bbr=Bbl=0; for(int i=1;i<=3+(Bbl-Bbr)/5;i++)if(Bbr<Bbl){Setpos(Bway[Bbr][0],Bway[Bbr][1]);if(Bway[Bbr][0]==20) cout<<"==";else cout<<" ";Bbr++;} if(Bwhat1==5){int bx,by;Color(5);for(int i=0;i<10;i++){bx=Bx1-i*Bvx1/10.0;by=By1-i*Bvy1/10.0;Setpos(bx,by),cout<<"█";Bbl++;Bway[Bbl][0]=bx;Bway[Bbl][1]=by;}Color(0);} Bx1-=Bvx1;By1-=Bvy1; if(Bwhat1==0){X2:Bwhat1=rand()%7;if(Bwhat1==2||Bwhat1==3){if(By1<=10||By1>25) goto X2;}if(Bwhat1==4){if(By1<=15||Bx1<20) goto X2;Bgo1[2]=Bx1;Bgo1[3]=By1-1;}if(Bwhat1==5) {X0:Bgo1[3]=rand()%4+1;Bvx1=(rand()%101)/20.0;Bvy1=(rand()%101)/20.0;if(Bgo1[3]<=2) Bvx1*=-1;if(Bgo1[3]%2==1) Bvy1*=-1;if(abs(Bvx1)+abs(Bvy1)<=3||Out1)goto X0;}if(Bwhat1==6){if(By1<=17||By1>25) goto X2;}} if(Bwhat1==1){Bgo1[1]++,Bgo1[2]++;int R=rand()%(5-Bgo1[1]),r=rand()%(10-Bgo1[2]);if(Out1) R=0;if(R==0) {int vx=Bvx1,vy=Bvy1;Bgo1[1]=0;Bvx1=(rand()%101-20)/50.0;Bvy1=(rand()%101-20)/50.0;if(Bgo1[3]<=2) Bvx1*=-1;if(Bgo1[3]%2==1) Bvy1*=-1;if(Out1) r=0;} if(r==0) Chang1 } if(Bwhat1==2){Bgo1[1]++;if(Bgo1[1]>6){Bvy1=-0.3;br++;B[br].x=Bx1,B[br].y=By1-1;B[br].what=6;X3:B[br].vx=(rand()%21-10)/40.0;B[br].vy=(rand()%25)/30.0;if(B[br].vx<=0.8&&B[br].vy<=0.8)goto X3;int rx=rand()%50;if(rx==0) B[br].vx=0;B[br].life=1;}if(Bgo1[1]>8) Chang1} if(Bwhat1==3){Bgo1[1]++;if(Bgo1[1]>6&&Bgo1[1]%3==0){Bvy1=-0.3;br++;B[br].x=Bx1,B[br].y=By1-1;B[br].what=8;B[br].life=1;}if(Bgo1[1]>15) Chang1} if(Bwhat1==4){Bgo1[1]++;if(Bgo1[1]<=8){Setpos(Bgo1[2],Bgo1[3]);if(Bgo1[1]==1)cout<<" ";else if(Bgo1[1]>1&&Bgo1[2]==20) cout<<"==";else cout<<" ";Bgo1[2]--;Setpos(Bgo1[2],Bgo1[3]);int r=rand()%4;if(r%2==0) Color(6);else Color(8);if(r<2) cout<<") ";else cout<<"】";Color(0),system("color C");}if(Bgo1[1]==6) Bgo1[5]=X,Bgo1[6]=Y;if(Bgo1[1]==11){Map(0,(bool)Kill);Setpos(Bgo1[5],Bgo1[6]+1),cout<<" ";Setpos(Bgo1[5],Bgo1[6]-1),cout<<" ";Setpos(Bgo1[5]+1,Bgo1[6]),cout<<" ";Setpos(Bgo1[5]-1,Bgo1[6]),cout<<" ";int bx,by,bvx=Bgo1[2]-Bgo1[5],bvy=Bgo1[3]-Bgo1[6];Color(6);int i=0;while(1){bx=Bgo1[2]-i*bvx/30.0;by=Bgo1[3]-i*bvy/30.0;if(bx<=5||bx>=30||by<0||by>=29) break;Panboss(bx,by);Setpos(bx,by),cout<<"█";Bbl++;Bway[Bbl][0]=bx;Bway[Bbl][1]=by;i++;}Color(0);Map(-1,0);Chang1}} if(Bwhat1==5){Bgo1[1]++,Bgo1[2]++;int R=rand()%(5-Bgo1[1]),r=rand()%(10-Bgo1[2]);if(Out1) R=0;if(R==0) {int vx=Bvx1,vy=Bvy1;Bgo1[1]=0;X1:Bvx1=(rand()%101-20)/20.0;Bvy1=(rand()%101-20)/20.0;if(Bgo1[3]<=2) Bvx1*=-1;if(Bgo1[3]%2==1) Bvy1*=-1;if(abs(Bvx1)+abs(Bvy1)<=3||abs(Bvx1-vx)<=1||abs(Bvy1-vy)<=1)goto X1;if(Out1) r=0;} if(r==0) Chang1 } if(Bwhat1==6){Bgo1[1]++;if(Bgo1[1]>6&&Bgo1[1]%10==0){By1-=1;br++;B[br].x=Bx1,B[br].y=By1-1;B[br].what=9;X30:B[br].vy=1;B[br].life=1;}if(Bgo1[1]>31) Chang1} } void Boss2(){ for(int j=0;j<20;j++)if(abs(Bx2-I[j][0])<2&&By2-I[j][1]<=2){Setpos(I[j][0],I[j][1]);if(I[j][0]==20) cout<<"===";else cout<<" ";I[j][0]=I[j][1]=-1;Bblo-=8+Lv*2;Exp+=2;} if(Bbr==Bbl&&Bbr!=0) Bbr=Bbl=0; for(int i=1;i<=3+(Bbl-Bbr)/5;i++)if(Bbr<Bbl){Setpos(Bway[Bbr][0],Bway[Bbr][1]);if(Bway[Bbr][0]==20) cout<<"==";else cout<<" ";Bbr++;} Bx2-=Bvx2;By2-=Bvy2; if(Bwhat2==0){X21:Bwhat2=rand()%7;if(Bwhat2==2){X31:for(int i=1;i<=3;i++){Bgo2[i*2+1]=rand()%28+1,Bgo2[i*2]=rand()%25+5;if((abs(Bgo2[i*2]-Bx2)<=2&&abs(Bgo2[i*2+1]-By2)<=2)||(abs(Bgo2[i*2]-X)<=2&&abs(Bgo2[i*2+1]-Y)<=2))goto X31;}if(Bgo2[2]==Bgo2[4]||Bgo2[2]==Bgo2[6]||Bgo2[6]==Bgo2[4]||Bgo2[5]==Bgo2[3]||Bgo2[3]==Bgo2[7]||Bgo2[5]==Bgo2[7]) goto X31;}if(Bwhat2==3){Bgo2[2]=rand()%2;}if(Bwhat2==4||Bwhat2==5||Bwhat2==6){Bvy2=-1.5;Bvx2=-0.5;}} if(Bwhat2==1){Bgo2[1]++,Bgo2[2]++;int R=rand()%(5-Bgo2[1]),r=rand()%(30-Bgo2[2]);if(Out2) R=0;if(R==0) {int vx=Bvx2,vy=Bvy2;Bgo2[1]=0;Bvx2=(rand()%101-20)/50.0;Bvy2=(rand()%101-20)/50.0;if(Bgo2[3]<=2) Bvx2*=-1;if(Bgo2[3]%2==1) Bvy2*=-1;if(Out2) r=0;} if(r==0) Chang2 } if(Bwhat2==2){Bgo2[1]++;float bx,by,bvx,bvy;if(Bgo2[1]<21){for(int i=1;i<=3;i++){bvx=Bgo2[i*2]-Bx2,bvy=Bgo2[i*2+1]-By2;if(Bgo2[1]<=10){Setpos(Bx2+(Bgo2[1]-1)*bvx/10.0,By2+(Bgo2[1]-1)*bvy/10.0);if(abs(Bx2+(Bgo2[1]-1)*bvx/10.0-20)<0.5)cout<<"==";else cout<<" ";bx=Bx2+Bgo2[1]*bvx/10.0;by=By2+Bgo2[1]*bvy/10.0;Setpos(bx,by);}else Setpos(Bgo2[i*2],Bgo2[i*2+1]);int r=rand()%4;if(r%2==0) Color(3);else Color(10);if(r<=1) cout<<"×";else cout<<"+";Color(0);}}if(Bgo2[1]==21){Map(0,(bool)Kill);Color(3);int j=0;for(int j=0;j<=30;j++)for(int i=1;i<=3;i++)for(int k=1;k<=4;k++){if(k==1) bvx=j,bvy=0;if(k==2) bvx=-j,bvy=0;if(k==3) bvx=0,bvy=j;if(k==4) bvx=0,bvy=-j;bx=Bgo2[i*2]+bvx,by=Bgo2[i*2+1]+bvy;if(bx<=5||bx>=30||by<0||by>=30) {continue;}Panboss(bx,by);Setpos(bx,by),cout<<"█";Bbl++;Bway[Bbl][0]=bx;Bway[Bbl][1]=by;}Color(0);Map(-1,0);Chang2}} if(Bwhat2==3){Bgo2[1]++;if(Bgo2[1]<=18){if(Bgo2[3]==0) Setpos(Bgo2[4]-3,Bgo2[5]),cout<<" ",Setpos(Bgo2[4]+3,Bgo2[5]),cout<<" ",Color(0),Setpos(20,Bgo2[5]),cout<<"==";if(Bgo2[3]==1) Setpos(Bgo2[4],Bgo2[5]-3.5),cout<<" ",Setpos(Bgo2[4],Bgo2[5]+2.5),cout<<" ",Color(0),Setpos(20,Bgo2[5]+2.5),cout<<"====",Setpos(20,Bgo2[5]-3.5),cout<<"====";if(Bgo2[1]%4==0)Bgo2[3]=!Bgo2[3];if(Bgo2[1]%6<3)Color(3);else Color(5);if(Bgo2[3]==0) Setpos(X-3,Y),cout<<"▼",Setpos(X+3,Y),cout<<"▲",Bgo2[4]=(int)(X+0.5),Bgo2[5]=(int)(Y+0.5);if(Bgo2[3]==1) Setpos(X,Y-3),cout<<" ",Setpos(X,Y+3),cout<<" ",Bgo2[4]=(int)(X+0.5),Bgo2[5]=(int)(Y+0.5);Color(0);}if(Bgo2[1]==18){if(Bgo2[3]==0) Setpos(Bgo2[4]-3,Bgo2[5]),cout<<" ",Setpos(Bgo2[4]+3,Bgo2[5]),cout<<" ",Color(0),Setpos(20,Bgo2[5]),cout<<"==";if(Bgo2[3]==1) Setpos(Bgo2[4],Bgo2[5]-3.5),cout<<" ",Setpos(Bgo2[4],Bgo2[5]+2.5),cout<<" ",Color(0),Setpos(20,Bgo2[5]+2.5),cout<<"====",Setpos(20,Bgo2[5]-3.5),cout<<"====";}if(Bgo2[1]>18&&Bgo2[1]<=25){Bgo2[3]=Bgo2[2];if(Bgo2[3]==0) Setpos(Bgo2[4]-3,Bgo2[5]),cout<<" ",Setpos(Bgo2[4]+3,Bgo2[5]),cout<<" ",Color(0),Setpos(20,Bgo2[5]),cout<<"==";if(Bgo2[3]==1) Setpos(Bgo2[4],Bgo2[5]-3.5),cout<<" ",Setpos(Bgo2[4],Bgo2[5]+2.5),cout<<" ",Color(0),Setpos(20,Bgo2[5]+2.5),cout<<"====",Setpos(20,Bgo2[5]-3.5),cout<<"====";if(Bgo2[1]%4<2)Color(3);else Color(5);if(Bgo2[3]==0) Setpos(Bgo2[4]-3,Bgo2[5]),cout<<"▼",Setpos(Bgo2[4]+3,Bgo2[5]),cout<<"▲";if(Bgo2[3]==1) Setpos(Bgo2[4],Bgo2[5]-3),cout<<" ",Setpos(Bgo2[4],Bgo2[5]+3),cout<<" ";Color(0);}if(Bgo2[1]==25){if(Bgo2[2]==0){Color(3);for(int i=4;i<=29;i++){Setpos(i,Bgo2[5]),cout<<"█";Bbl++;Panboss(i,Bgo2[5]);Bway[Bbl][0]=i;Bway[Bbl][1]=Bgo2[5];}}if(Bgo2[2]==1){Color(3);for(int i=0;i<=28;i++){Setpos(Bgo2[4],i),cout<<"█";Bbl++;Panboss(Bgo2[4],i);Bway[Bbl][0]=Bgo2[4];Bway[Bbl][1]=i;}}Chang2}} if(Bwhat2==4||Bwhat2==5||Bwhat2==6){Bgo2[1]++;if(By2>27)Bvy2=0;if(Bx2>23)Bvx2=0;if(Bgo2[1]>13&&Bgo2[1]%3==0){float t=By2-Y,g=0.35;if(Boss==6) t/=2.0;CpGuai(Bwhat2+2,Bx2,By2,(Bx2-X)/t*1.0+(t-1)*g/2.0,1);}if(Bgo2[1]>20) Chang2} } void Boss3(){ #define Bean br++;B[br].what=13;B[br].x=Bx3-1,B[br].y=By3-1;B[br].vy=1;B[br].life=1; for(int j=0;j<20;j++)if(abs(Bx3-I[j][0])<2&&By3-I[j][1]<=2){Setpos(I[j][0],I[j][1]);if(I[j][0]==20) cout<<"===";else cout<<" ";I[j][0]=I[j][1]=-1;Bblo-=8+Lv*2;Exp+=2;} Bx3-=Bvx3;By3-=Bvy3; if(Bwhat3<=8){if(Bx3>X&&Bvx3<1.5) Bvx3+=0.3;if(Bx3<X&&Bvx3>-1.5) Bvx3-=0.3;} if(Bwhat3==0){X22:Bwhat3=rand()%12;if(Bwhat3==11&&abs(Bx3-20)<=1)goto X22;if(Bwhat3==11)Bgo3[2]=rand()%5;} if(Bwhat3==1){Bgo3[1]++;if(Bgo3[1]==6){br++;B[br].what=13;B[br].x=(int)Bx3-1,B[br].y=By3-1;B[br].vy=1;B[br].vx=1;B[br].How=(int)Bx3-4;B[br].life=1;br++;B[br].what=13;B[br].x=(int)Bx3-1,B[br].y=By3-1;B[br].vy=1;B[br].vx=-1;B[br].How=(int)Bx3+2;B[br].life=1;br++;B[br].what=13;B[br].x=(int)Bx3-1,B[br].y=By3-1;B[br].vy=1;B[br].life=1;Chang3}} if(Bwhat3>=2&&Bwhat3<=6){Bgo3[1]++;if(Bgo3[1]==6){br++;B[br].x=(int)Bx3-1,B[br].y=By3-1;B[br].what=11+Bwhat3;B[br].vy=0.5+(rand()%100)/80.0;if(Bwhat3==5)B[br].vy=B[br].vy*3/4.0;B[br].life=1;Chang3}} if(Bwhat3==7){Bgo3[1]++;if(Bgo3[1]==6){br++;B[br].what=14;B[br].x=(int)Bx3-1,B[br].y=By3-1;B[br].vy=1;B[br].vx=1;B[br].How=(int)Bx3-4;B[br].life=1;br++;B[br].what=14;B[br].x=(int)Bx3-1,B[br].y=By3-1;B[br].vy=1;B[br].vx=-1;B[br].How=(int)Bx3+2;B[br].life=1;br++;B[br].what=14;B[br].x=(int)Bx3-1,B[br].y=By3-1;B[br].vy=1;B[br].life=1;Chang3}} if(Bwhat3==8){Bgo3[1]++;if(Bgo3[1]==6){br++;B[br].what=15;B[br].x=(int)Bx3-1,B[br].y=By3-1;B[br].vy=1;B[br].vx=1;B[br].How=(int)Bx3-4;B[br].life=1;br++;B[br].what=15;B[br].x=(int)Bx3-1,B[br].y=By3-1;B[br].vy=1;B[br].vx=-1;B[br].How=(int)Bx3+2;B[br].life=1;br++;B[br].what=15;B[br].x=(int)Bx3-1,B[br].y=By3-1;B[br].vy=1;B[br].life=1;Chang3}} if(Bwhat3==9){Bvx3=0;Bgo3[1]++;if(Bgo3[1]==6||Bgo3[1]==8){Bean}if(Bgo3[1]>=8)Chang3} if(Bwhat3==10){Bvx3=0;Bgo3[1]++;if(Bgo3[1]==6||Bgo3[1]==8||Bgo3[1]==10||Bgo3[1]==12){Bean}if(Bgo3[1]>=12)Chang3} if(Bwhat3==11){Bvx3=0;Bgo3[1]++;if(Bgo3[1]>=8)for(int i=1;i<=4;i++){br++;B[br].what=80+100*Bgo3[2]+Bgo3[1]*4+i;B[br].x=Bx3-1,B[br].y=By3-1+i;B[br].vy=4;B[br].life=1;br++;B[br].what=99;B[br].x=Bx3,B[br].y=By3-1+i;B[br].vy=4;B[br].life=1;br++;B[br].what=99;B[br].x=Bx3-2,B[br].y=By3-1+i;B[br].vy=4;B[br].life=1;}if(Bgo3[1]>=20){for(int i=1;i<=4;i++){br++;B[br].what=98;B[br].x=Bx3-1,B[br].y=By3-1+i;B[br].vy=4;B[br].life=1;br++;B[br].what=98;B[br].x=Bx3,B[br].y=By3-1+i;B[br].vy=4;B[br].life=1;br++;B[br].what=98;B[br].x=Bx3-2,B[br].y=By3-1+i;B[br].vy=4;B[br].life=1;}Chang3}} } void Ball(int ball){ if(ball==1){if(Fir<3&&T%8==0) Fir++;if(Fir>0){br++;B[br].what=-13;B[br].x=X;B[br].y=Y+rand()%3-1;B[br].life=1;if(Dis<=30) B[br].a=Disb,B[Disb].a=1,Fir--;else if(Boss!=0) B[br].a=13880086,Fir--;else if(Dis!=13880087) B[br].a=Disb,B[Disb].a=1,Fir--;else if(Dis1!=13880087) B[br].a=Disb1,B[Disb1].a=1,Fir--;else B[br].life=0;Dis=Dis1=13880087;}} if(ball==2){if(T%4==0)ib=(ib+1)%20,I[ib][1]=Y-2;if(T%16==0)I[ib][0]=X;if(T%16==4)I[ib][0]=X-1;if(T%16==8)I[ib][0]=X+1;if(T%16==12)I[ib][0]=X-2;if(T%12==9)I[ib][0]=X+2;if(Water==1){for(int i=X-6;i<=X+6;i++)ib=(ib+1)%20,I[ib][0]=i,I[ib][1]=Y-2-0.5*abs(i-X);}} if(ball==3){if(Wind>5){if(Y<Ding-1)Vy=5;else Vy=0;if(Up>=1) Vx=-5;if(Down==2) Vx=5;}if(Wind<5){if(Y>Ding-1)Vy=-5;else Vy=0;if(Up>=1) Vx=-5;if(Down==2) Vx=5;}if(Wind==5){if(Boss==2) Ding=12.25;else Ding=6.25;if(Boss!=0) Bblo-=16+Lv*4;if(Boss==1) Chang1 if(Boss==2) Chang2 if(Boss==3) Chang3 system("color 3F");Sleep(20);system("color 6F");Sleep(10);system("color 0F");system("cls");for(int i=bl;i<=br;i++)if(B[i].what>0)B[i].life=0;Setpos(20,0);for(int i=1;i<=60;i++) printf("=");}} if(ball==4){if(Thun==1){if(Boss!=0) Bblo-=16+Lv*4;if(Boss==1) Chang1 if(Boss==2) Chang2 if(Boss==3) Chang3 system("color 9F");Sleep(20);system("color 6F");Sleep(10);system("color 0F");system("cls");for(int i=bl;i<=br;i++)if(B[i].what>0)B[i].life=0;Setpos(20,0);for(int i=1;i<=60;i++) printf("=");}} if(ball==5){system("cls"); Color(5);Setpos(10,10);cout<<"新天赋!";Y:int rr=rand()%4+2;Setpos(12,10);if(rr==Ren) goto Y;if(rr==2)cout<<"瞬跳";if(rr==3)cout<<"空中悬停";if(rr==4)cout<<"三段跳";if(rr==5)cout<<"反重力跳跃";Setpos(14,10);cout<<"当前天赋:";if(Ren==1)cout<<"小无敌";if(Ren==2)cout<<"瞬跳";if(Ren==3)cout<<"空中悬停";if(Ren==4)cout<<"三段跳";if(Ren==5)cout<<"反重力跳跃";Setpos(16,10);cout<<"换否?(y/n)";G:char g=_getch();if(g=='y')Ren=rr;else if(g!='n')goto G;system("cls");Setpos(20,0);Color(0);for(int i=1;i<=60;i++) printf("=");} if(ball==6){Color(4);for(float i=1;i<=Bblo;i+=Bblomax/20.0)cout<<"▄";Color(0);cout<<' '<<Bblo<<" ";Color(0);} if(ball==7){Color(1);if(Win==7&&T%6<3)Color(3);for(float i=1;i<=Blo;i+=Blomax/20.0)cout<<"▄";Color(0);if(Win==7&&T%6<3)Color(3);printf(" %0.1f ",Blo);} } // 游戏配置常量 #define WIDTH 20 // 控制台游戏区域宽度 #define HEIGHT 15// 控制台游戏区域高度 #define DOUBLE_CLICK_THRESHOLD 300 // 双击判定阈值(毫秒),300ms内连续点击为双击 // 方向枚举 #ifndef DIRECTION_H // 头文件保护宏,防止重复包含 #define DIRECTION_H // 修正后的方向枚举(补充完整的方向定义,避免逻辑歧义) enum Direction { LEFT, // 左 RIGHT, // 右 UP, // 上 DOWN, // 下 STOP // 新增:停止状态,避免空值逻辑错误 }; #endif // DIRECTION_H // 蛇身节点结构体 struct SnakeNode { int x; int y; SnakeNode(int x_, int y_) : x(x_), y(y_) {} }; // 按键状态结构体(记录每个方向键的点击信息) struct KeyState { DWORD lastClickTime; // 上次点击时间(毫秒,Windows系统时间) int clickCount; // 点击次数 KeyState() : lastClickTime(0), clickCount(0) {} }; // 全局变量 vector<SnakeNode> snake; // 存储蛇身 Direction dir = RIGHT; // 初始方向向右 int foodX, foodY; // 食物坐标 int score = 0; // 得分 bool isGameOver = false; // 游戏结束标志 KeyState keyW, keyA, keyS, keyD; // 四个方向键的状态记录 int gameSpeed = 200; // 默认游戏速度(毫秒),值越大移动越慢 bool isPaused = false; // 新增:游戏暂停标志位,初始为未暂停 // 设置控制台光标位置 void setCursorPosition(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 initGame() { // 初始化蛇身 snake.clear(); snake.emplace_back(5, HEIGHT / 2); snake.emplace_back(4, HEIGHT / 2); snake.emplace_back(3, HEIGHT / 2); // 初始化随机数种子 srand((unsigned int)time(NULL)); // 生成初始食物 foodX = rand() % (WIDTH - 2) + 1; foodY = rand() % (HEIGHT - 2) + 1; // 初始化游戏状态 score = 0; isGameOver = false; dir = RIGHT; gameSpeed = 200; isPaused = false; // 初始化时重置为未暂停状态 // 重置按键状态 keyW = KeyState(); keyA = KeyState(); keyS = KeyState(); keyD = KeyState(); // 隐藏光标 hideCursor(); } // 绘制游戏界面 void drawGame() { // 移动光标到左上角覆盖刷新 setCursorPosition(0, 0); // 绘制上边框 for (int i = 0; i < WIDTH; ++i) { cout << "□"; } cout << endl; // 绘制中间游戏区域 for (int y = 0; y < HEIGHT; ++y) { for (int x = 0; x < WIDTH; ++x) { // 绘制左右边框 if (x == 0 || x == WIDTH - 1) { cout << "□"; continue; } // 绘制蛇头(▲) bool isSnakeHead = false; if (!snake.empty() && snake.front().x == x && snake.front().y == y) { cout << "▲"; isSnakeHead = true; } if (isSnakeHead) continue; // 绘制蛇身(含蛇尾,■) bool isSnakeBody = false; for (size_t i = 1; i < snake.size(); ++i) { const auto& node = snake[i]; if (node.x == x && node.y == y) { cout << "■"; isSnakeBody = true; break; } } if (isSnakeBody) continue; // 绘制食物 if (x == foodX && y == foodY) { cout << "●"; continue; } // 绘制空白区域 cout << " "; } cout << endl; } // 绘制下边框 for (int i = 0; i < WIDTH; ++i) { cout << "□"; } cout << endl; // 绘制得分、暂停状态和操作说明 cout << "得分:" << score << " 游戏状态:" << (isPaused ? "已暂停(按E继续)" : "运行中") << " 操作:W/A/S/D 方向,双击加速,E暂停/继续,Q退出" << endl; } // 检测双击并更新移动速度 void checkDoubleClick(KeyState& keyState, Direction targetDir) { DWORD currentTime = GetTickCount(); keyState.clickCount++; if (keyState.clickCount == 1) { keyState.lastClickTime = currentTime; gameSpeed = 200; dir = targetDir; } else if (keyState.clickCount == 2) { if (currentTime - keyState.lastClickTime <= DOUBLE_CLICK_THRESHOLD) { gameSpeed = 50; dir = targetDir; } else { keyState.clickCount = 1; keyState.lastClickTime = currentTime; gameSpeed = 200; dir = targetDir; } } if (currentTime - keyState.lastClickTime > DOUBLE_CLICK_THRESHOLD) { keyState.clickCount = 0; } } // 控制蛇的移动方向 void controlDirection() { if (_kbhit()) { char ch = _getch(); switch (ch) { case 'w': case 'W': if (dir != DOWN && !isPaused) { checkDoubleClick(keyW, UP); keyA.clickCount = 0; keyS.clickCount = 0; keyD.clickCount = 0; } break; case 's': case 'S': if (dir != UP && !isPaused) { checkDoubleClick(keyS, DOWN); keyW.clickCount = 0; keyA.clickCount = 0; keyD.clickCount = 0; } break; case 'a': case 'A': if (dir != RIGHT && !isPaused) { checkDoubleClick(keyA, LEFT); keyW.clickCount = 0; keyS.clickCount = 0; keyD.clickCount = 0; } break; case 'd': case 'D': if (dir != LEFT && !isPaused) { checkDoubleClick(keyD, RIGHT); keyW.clickCount = 0; keyA.clickCount = 0; keyS.clickCount = 0; } break; case 'q': case 'Q': isGameOver = true; break; case 'e': case 'E': isPaused = !isPaused; if (!isPaused) { gameSpeed = 200; } break; } } } // 暂停循环 void pauseLoop() { while (isPaused && !isGameOver) { controlDirection(); Sleep(100); } } // 蛇的移动逻辑(穿墙) void moveSnake() { if (snake.empty() || isPaused) return; int newHeadX = snake.front().x; int newHeadY = snake.front().y; switch (dir) { case UP: newHeadY--; break; case DOWN: newHeadY++; break; case LEFT: newHeadX--; break; case RIGHT: newHeadX++; break; } // 穿墙 if (newHeadX <= 0) newHeadX = WIDTH - 2; else if (newHeadX >= WIDTH - 1) newHeadX = 1; if (newHeadY < 0) newHeadY = HEIGHT - 1; else if (newHeadY >= HEIGHT) newHeadY = 0; // 撞自己 for (const auto& node : snake) { if (node.x == newHeadX && node.y == newHeadY) { isGameOver = true; return; } } // 新头 snake.insert(snake.begin(), SnakeNode(newHeadX, newHeadY)); // 吃食物 if (newHeadX == foodX && newHeadY == foodY) { score += 10; bool foodOnSnake; do { foodOnSnake = false; foodX = rand() % (WIDTH - 2) + 1; foodY = rand() % (HEIGHT - 2) + 1; for (const auto& node : snake) { if (node.x == foodX && node.y == foodY) { foodOnSnake = true; break; } } } while (foodOnSnake); } else { snake.pop_back(); } } // 游戏结束界面 void gameOverUI() { system("cls"); cout << "========================" << endl; cout << " 游戏结束 " << endl; cout << "========================" << endl; cout << " 最终得分:" << score << endl; cout << " 按任意键退出..." << endl; _getch(); } int blood=100,attack=3; string weapon; string aaa[101]; int nnn=10,mmm=10,k,mercy=10,xdf=1,ydf=1; struct monster { int s,a,b; string name; }hudie; void sout(string s){ for(int i=0;i<s.size();i++){ cout<<s[i]; Sleep(40); } cout<<"\n"; Sleep(100); } void jiazai(){ printf("正在检查网络...\n0"); Sleep(150); system("cls"); printf("正在连接服务器...\n▊15"); Sleep(210); system("cls"); printf("加载资源中...\n█▎25"); Sleep(180); system("cls"); printf("加载资源中...\n██▊55"); Sleep(120); system("cls"); printf("加载资源中...\n███▌70"); Sleep(90); system("cls"); printf("加载资源中...\n███▊75"); Sleep(450); system("cls"); printf("正在加载剧情...\n████▌90"); Sleep(120); system("cls"); printf("正在加载怪兽...\n█████100"); Sleep(300); system("cls"); printf("正在进入新章节...\n█████100"); Sleep(900); system("cls"); } void SlowDisplay(char *p) { system("cls"); while(1) { if(*p!=0) printf("%c",*p++); else break; } system ("pause>nul"); } void texiao() { for(int i=1; i<=10; i++) { system("color 2f"); Sleep(10); system("color 0f"); Sleep(10); } } void out() { int i,j; for(i=1;i<=nnn;i++) { for(j=0;j<=mmm;j++) { cout<<aaa[i][j]<<" "; } cout<<endl; } return; } void fight(monster xdf) { cout<<"突然,"; cout<<xdf.name; cout<<"朝你冲了过来!!!\n"; system("pause"); cout<<"是否战斗? 1.是 2.否\n"; int q; cin>>q; if(q==1) { mercy--; while(blood>=0&&xdf.b>=0) { { bool flag=false; cout<<"你的血:"<<blood<<endl<<xdf.name<<"的血:"<<xdf.b<<endl; cout<<"1.攻击 2.闪避 3.特殊技能(暂未开发,请勿选3,否则默认为2)\n"; int q; cin>>q; if(q==1) { if(rand()%100<xdf.s) cout<<"敌人闪开了!!!\n"; else { cout<<"敌人被打中。。。\n"; xdf.b-=attack; }} else { cout<<"猜一个从1~10的数,3次机会,猜对即可闪避2回合。。。"; int xxx=rand()%10+1; int yyy,c=0; while(yyy!=xxx&&c<3) { cin>>yyy; if(yyy>xxx) { cout<<"大了!!!"; } if(yyy<xxx) { cout<<"小了!!!"; } c++; } if(yyy==xxx) { cout<<"闪避成功!!!\n"; flag=true; } else { cout<<"闪避失败!!!\n"; } } if(flag!=true) { cout<<"轮到敌人啦!!!\n"; if(q==1) blood-=xdf.a*2; else blood-=xdf.a; cout<<"你被打中。。。\n"; } } } if(blood<=0) { cout<<"you died!!!"<<endl; return; } else { cout<<"you won!!!"<<endl; return; } } else { mercy+=2; cout<<"you escape!!!\n"; } } bool judge(int xdf,int ydf) { if(xdf<1||ydf<0)return 0; if(xdf>10||ydf>10)return 0; if(aaa[x][y]=='*')return 0; return 1; } void hazz(){ srand(time(NULL)); hudie.s=10; hudie.a=1; hudie.b=20; hudie.name="BUTTfly(蝴蝶)"; int t; while(t!=1) { printf("你好,欢迎来到暗黑诅咒游戏第二季Pavris的封印,如果你没玩第一季,赶紧去玩一下,要不然,你根本看不懂剧情!!!\n"); cout<<"主菜单:"<<endl; cout<<"》1.开始游戏《"<<endl<<"2.查看人物介绍"<<endl<<"3.查看更新日志"<<endl<<"4.查看新手攻略"<<endl<<"5.查看目录"<<endl; cin>>t; if(t==1) system("cls"); else if(t==3) { SlowDisplay("0.0.2 更完第一章和第二章一半\n"); SlowDisplay("0.0.3 更完前两章\n"); } else if(t==4) { SlowDisplay("合理打怪,跟着剧情走即可。。。\n"); } else if(t==2) { SlowDisplay("你:Frisk Black,Rick Black的儿子,18岁中二病青年,父母都死了,由爷爷,奶奶养,根本不知道自己其实是个法师。\n"); SlowDisplay("Crish:强大法师,打败了德沃拉,并封印了他,现任ZO国国王\n"); SlowDisplay("shiys:ZO国忠臣,预言家,法力也很强。\n"); SlowDisplay("Sean Moster:有着奇怪姓氏,有着神秘身世,你的好伙伴,跟Ivy是对龙凤胎。\n"); SlowDisplay("Ivy Moster:Sean他妹妹。\n"); SlowDisplay("Oliver Moster:龙凤胎的爷爷,性格古怪。\n"); SlowDisplay("德利特:你邻居,中年人,警察,他女儿被法师杀害,于是他热衷于捕杀法师,对法师有着深仇大恨。\n"); SlowDisplay("梅林:德利特儿子,20岁。\n"); SlowDisplay("佩刀杀人狂:杀人不眨眼的魔头。\n"); } else if(t==5) { SlowDisplay("第一章 坠落\n"); SlowDisplay("第二章 地下世界\n"); SlowDisplay("第三章 国王\n"); SlowDisplay("第四章 水晶国决斗场\n"); SlowDisplay("第五章 竹子国遗迹\n"); SlowDisplay("第六章 圣骷髅教堂和水晶球\n"); SlowDisplay("第七章 鬼屋逃生\n"); SlowDisplay("第八章 ???\n"); SlowDisplay("第九章 营救\n"); SlowDisplay("第十章 最后一刻\n"); } else { cout<<"ByeBye~"<<endl; } } printf("文字游戏:暗黑诅咒第二季(The Curse Of Darkness And The Seal Of Pavris Black)\n"); Sleep(1000); printf("出品人:drzo(teacherga)\n"); Sleep(1000); printf("版本:0.0.3\n"); Sleep(1000); system("pause"); system("cls"); jiazai(); texiao(); cout<<"查看剧情输1,否则跳过。"<<endl; int tt; cin>>tt; if(tt==1) { SlowDisplay("话说世界上分为两个人种,法师和人类,在中世纪两个人种就走上了不同的路,法师建立了法师地下世界,有竹子国,水晶国和ZO村,后来德沃拉出现,灭了竹子国,后来德沃拉被封印,ZO村变为了ZO国,而打败德沃拉的勇士Crish成为了ZO国国王。\n"); SlowDisplay("暗黑诅咒第一季所有剧情都发生在法师地下王国,而我们这一季的主人公将是一个地上的普通人类,也就是你,Frisk Black。\n"); system("pause"); } jiazai(); int q1; cout<<"现在请选择个武器:1.牙签 2.小石子 3.haobo8\n"; cin>>q1; if(q1==1) weapon="牙签"; else if(q1==2) weapon="小石子"; else weapon="haobo8"; SlowDisplay("drzo:很好,你现在武器选好了,还等什么,开始游戏吧!!!\n"); cout<<"祝你们游戏愉快,输入1开始\n"; int a; cin>>a; if(a==1) { SlowDisplay("第一章 坠落\n"); SlowDisplay("先介绍一下角色:\n"); SlowDisplay("Sean Moster:有着奇怪姓氏,有着神秘身世,你的好伙伴,跟Ivy是对龙凤胎。\n"); SlowDisplay("Ivy Moster:Sean他妹妹。\n"); SlowDisplay("Oliver Moster:龙凤胎的爷爷,性格古怪。\n"); SlowDisplay("德利特:你邻居,中年人,警察,他女儿被法师杀害,于是他热衷于捕杀法师,对法师有着深仇大恨。你还一直记着那恐怖的一天,你亲眼见到德利特女儿被一个无形的手扔起10米高,被摔死,据说是法师干的,但从未找到凶手。。。\n"); SlowDisplay("梅林:德利特儿子,20岁。\n"); SlowDisplay("而你——Frisk Black是个普通高中生,你父母5年前都去世了,你爸爸Rick Black是个神秘的人,你从来都没有见到过他,你母亲总安抚你说他会回来的,但是他永远都没回来,你恨他,他就是个无用之人,甚至不爱自己儿子,导致你一直没有父爱,直到5年前你父母都死了,你悲痛万分,只能由你爷爷奶奶抚养。\n"); SlowDisplay("你觉着你很普通,但真的如此吗?\n"); system("pause"); system("cls"); SlowDisplay("上午十点 图书馆 状态:良好 武器:"); cout<<weapon<<endl; SlowDisplay("你:tmd,作业实在太多了,老师是都在搞笑吗,我就想知道20张卷子2天怎么做完?!!\n"); SlowDisplay("Ivy抱着一堆书从个书架后走出,她说:我看你该认真学习。。。\n"); SlowDisplay("你想:像往常一样热爱学习。。。难道她从来没休息过吗?!\n"); SlowDisplay("你自己发着牢骚,一边寻找文献资料,你想:这图书馆真tm大,连本书都找不到。。。\n"); SlowDisplay("adsw来行走,*是书架,@是你,#是个神奇的东西: 按任意键继续。。。\n"); int i,j; aaa[1]="*@*********"; aaa[2]="* *"; aaa[3]="* * * * * *"; aaa[4]="* * * * * *"; aaa[5]="* *"; aaa[6]="* * * * * *"; aaa[7]="* * * * * *"; aaa[8]="* * * * * *"; aaa[9]="* *"; aaa[10]="*********#*"; out(); char c; for(;;) { c=getch(); system("cls"); if(c=='w') { if(judge(x-1,y)) { swap(aaa[x-1][y],aaa[x][y]); x--; } } if(c=='a') { if(judge(x,y-1)) { swap(aaa[x][y-1],aaa[x][y]); y--; } } if(c=='s') { if(judge(x+1,y)) { swap(aaa[x+1][y],aaa[x][y]); x++; } } if(c=='d') { if(judge(x,y+1)) { swap(aaa[x][y+1],aaa[x][y]); y++; } } out(); if(x==10&&y==9) { system("cls"); Sleep(2000); getch(); break; } } SlowDisplay("你慢慢走一个闪闪发光的东西,你发现是个普通的日记本,陈旧无比,封面都快要掉留下来,沾满灰尘,你拂去灰尘,只见上面画着个佩刀的符号,周围写着一圈大字:B L A C K,你好奇地翻开这本书,突然你的眼前一片白光,你感到这书开始剧烈发烫,你的手一不小心把这书丢在地上,这书一下子把地毯给烧焦了,你眼前仍白光一片,大量的光亮让你感到都快失明了。\n"); SlowDisplay("sean(Ivy哥哥)走了过来:你在干什么啊,你爷爷喊你快回家吃午饭!\n"); SlowDisplay("你立马收起来了书,你把所有刚刚的事情都告诉了Ivy和Sean,你们决定一起去你家研究一下那本书。。。\n"); SlowDisplay("你们到了你卧室里头,你再次打开了那本书,这次书变得更烫,热的迫使你松开手使书掉到了地板上,立马地板烧开了个大洞,而且洞越来越深,黑森森的看不清底。。。\n"); SlowDisplay("你:什么情况?!! 你往洞里喊了几声没有任何响应,突然白光再次在你眼前出现,你的背后有一双手把你推了下去,几声尖叫和几声哐当,你们坠落到了洞的底部!\n"); SlowDisplay("第一章 完\n"); jiazai(); SlowDisplay("第二章 国王\n"); SlowDisplay("你和兄妹两个一起落入深渊,落到洞底,里面空无一人十分黑暗而寂静,你在地上慢慢爬起,但疼痛感使你被迫再次摔倒在潮湿的地上,突然你摸到了一个东西,你一看,竟然是个人的头骨!你被吓得惊声尖叫,Sean和Ivy也被吓了一跳,原来你们站着的地上铺满了尸骸。。。你们在一个墓地里!\n"); fight(hudie); if(blood<=0) SlowDisplay("你:哎呀,原来就是个蝴蝶,虚惊一场。。。\n"); SlowDisplay("Ivy:咱们赶紧离开这里吧。。。我好怕~\n"); SlowDisplay("话音刚落,一把飞刀从你脸旁飞过,你吓得连忙躲开,一个1米8左右的戴着人骨面具的男子从阴影里走出。。。\n"); SlowDisplay("你:你。。。你是谁!?\n"); SlowDisplay("???:...\n"); SlowDisplay("你:快说你名字,否则我就不客气了!\n"); SlowDisplay("???:...\n"); SlowDisplay("???:...\n"); SlowDisplay("突然你背后的飞刀回旋了回来,你需要快速闪避!!!\n"); cout<<"猜一个从1~10的数,3次机会,猜对即可闪避。。。"; int xxx=rand()%10+1; int yyy,cc=0; while(yyy!=xxx&&cc<3) { cin>>yyy; if(yyy>xxx) { cout<<"大了!!!"; } if(yyy<xxx) { cout<<"小了!!!"; } cc++; } if(yyy==xxx) { cout<<"闪避成功!!!\n"; } else { cout<<"闪避失败!!!你死了!!!\n"; } } SlowDisplay("你:大家快跑!!!\n"); SlowDisplay("但是已经晚了,手持佩刀的人朝你们扑了过来,只听他用沙哑的声音默念道:就差一个灵魂了,我就能无敌了。。。\n"); SlowDisplay("突然你背后飞来那本日记本,正中面具男,把他砸晕在地,你们头也不回地跑掉了。。。\n"); system("pause"); SlowDisplay("下午五点 地下 状态:疲劳 武器:"); cout<<weapon<<endl; SlowDisplay("你们不知跑了多长时间,直到你们跑到一条河旁。。。\n"); SlowDisplay("你:让我理一下,首先我们在图书馆里拿到一本破日记本,然后在我卧室里烫了个洞直通地下,之后我们又不知为何掉了下去,就迎面遇上了个疯子杀人魔,最后我们发现这地下大得很,竟然地下连小溪都有,告诉我这一切都是梦。。。\n"); SlowDisplay("Sean:我们现在应该想想怎么离开这里,快看!那边有人!!!\n"); SlowDisplay("你:地下也有人?!\n"); SlowDisplay("你想去跟那个人交流一下,问下路,但你发现那个人手持长刀,身穿盔甲,你想:这人怕是在演戏,这哪里是冷兵器时代?!\n"); SlowDisplay("那人看到了你,眉头一皱,突然一条红光正射中你,你倒在地上无法动弹,之后你和Ivy和Sean都被绑了起来,扔进一个马车上,你自言自语道:莫非我穿越了?!怎么这个年代还有马车?!\n"); SlowDisplay("Ivy哭着说:我明白了。。。\n"); SlowDisplay("Sean害怕又焦急地问:你知道什么了?!!\n"); SlowDisplay("Ivy:我们到了法师世界了,刚刚那个人就是法师,要不然他能把Frisk隔空打倒,而且我在书中读到,法师自从中世纪就消失不见,因为他们自己建了个世界自己生存,所以他们还保留中世纪习俗,而现在我们被一群法师抓走了!!!\n"); SlowDisplay("第二章 完\n"); } typedef struct Frame { COORD position[2]; int flag; }Frame; void SetPos(COORD a) { HANDLE out=GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorPosition(out, a); } void SetPos(int i, int j) { COORD pos={i, j}; SetPos(pos); } void HideCursor() { CONSOLE_CURSOR_INFO cursor_info = {1, 0}; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info); } //把第y行,[x1, x2) 之间的坐标填充为 ch void drawRow(int y, int x1, int x2, char ch) { SetPos(x1,y); for(int i = 0; i <= (x2-x1); i++) cout<<ch; } //在a, b 纵坐标相同的前提下,把坐标 [a, b] 之间填充为 ch void drawRow(COORD a, COORD b, char ch) { if(a.Y == b.Y) drawRow(a.Y, a.X, b.X, ch); else { SetPos(0, 25); cout<<"error code 01:无法填充行,因为两个坐标的纵坐标(x)不相等"; system("pause"); } } //把第x列,[y1, y2] 之间的坐标填充为 ch void drawCol(int x, int y1, int y2, char ch) { int ydf=y1; while(ydf!=y2+1) { SetPos(x, ydf); cout<<ch; y++; } } //在a, b 横坐标相同的前提下,把坐标 [a, b] 之间填充为 ch void drawCol(COORD a, COORD b, char ch) { if(a.X == b.X) drawCol(a.X, a.Y, b.Y, ch); else { SetPos(0, 25); cout<<"error code 02:无法填充列,因为两个坐标的横坐标(y)不相等"; system("pause"); } } //左上角坐标、右下角坐标、用row填充行、用col填充列 void drawFrame(COORD a, COORD b, char row, char col) { drawRow(a.Y, a.X+1, b.X-1, row); drawRow(b.Y, a.X+1, b.X-1, row); drawCol(a.X, a.Y+1, b.Y-1, col); drawCol(b.X, a.Y+1, b.Y-1, col); } void drawFrame(int x1, int y1, int x2, int y2, char row, char col) { COORD a={x1, y1}; COORD b={x2, y2}; drawFrame(a, b, row, col); } void drawFrame(Frame frame, char row, char col) { COORD a = frame.position[0]; COORD b = frame.position[1]; drawFrame(a, b, row, col); } void drawPlaying() { drawFrame(0, 0, 48, 24, '=', '|');// draw map frame; drawFrame(49, 0, 79, 4, '-', '|');// draw output frame drawFrame(49, 4, 79, 9, '-', '|');// draw score frame drawFrame(49, 9, 79, 20, '-', '|');// draw operate frame drawFrame(49, 20, 79, 24, '-', '|');// draw other message frame SetPos(52, 6); cout<<"得分:"; SetPos(52, 7); cout<<"称号:"; SetPos(52,10); cout<<"操作方式:"; SetPos(52,12); cout<<" a,s,d,w 控制战机移动。"; SetPos(52,14); cout<<" p 暂停游戏。"; SetPos(52,16); cout<<" e 退出游戏。"; SetPos(52,18); cout<<" k 发射子弹。"; } //在[a, b)之间产生一个随机整数 int random(int a, int b) { int c=(rand() % (a-b))+ a; return c; } //在两个坐标包括的矩形框内随机产生一个坐标 COORD random(COORD a, COORD b) { int x=random(a.X, b.X); int y=random(a.Y, b.Y); COORD c={xdf, ydf}; return c; } bool judgeCoordInFrame(Frame frame, COORD spot) { if(spot.X>=frame.position[0].X) if(spot.X<=frame.position[1].X) if(spot.Y>=frame.position[0].Y) if(spot.Y<=frame.position[0].Y) return true; return false; } void printCoord(COORD a) { cout <<"( "<<a.X<<" , "<<a.Y<<" )"; } void printFrameCoord(Frame a) { printCoord(a.position[0]); cout <<" - "; printCoord(a.position[1]); } int drawMenu() { SetPos(30, 1); cout<<"P l a n e W a r"; drawRow(3, 0, 79, '-'); drawRow(5, 0, 79, '-'); SetPos(28, 4); cout<<"w 和 s 选择, k 确定"; SetPos(15, 11); cout<<"1. 简单的敌人"; SetPos(15, 13); cout<<"2. 冷酷的敌人"; drawRow(20, 0, 79, '-'); drawRow(22, 0, 79, '-'); SetPos(47, 11); cout<<"简单的敌人:"; SetPos(51, 13); cout<<"简单敌人有着较慢的移动速度。"; int j=11; cout<<">>"; while(1) { if( _kbhit() ) { char x=_getch(); switch (x) { case 'w' : { if( j == 13) { SetPos(12, j); cout<<" "; j = 11; SetPos(12, j); cout<<">>"; SetPos(51, 13); cout<<" "; SetPos(47, 11); cout<<"简单的敌人:"; SetPos(51, 13); cout<<"简单敌人有着较慢的移动速度。"; } break; } case 's' : { if( j == 11 ) { SetPos(12, j); cout<<" "; j = 13; SetPos(12, j); cout<<">>"; SetPos(51, 13); cout<<" "; SetPos(47, 11); cout<<"冷酷的敌人:"; SetPos(51, 13); cout<<"冷酷的敌人移动速度较快。"; } break; } case 'k' : { if (j == 8) return 1; else return 2; } } } } } /*================== the Game Class ==================*/ class Game { public: COORD position[10]; COORD bullet[10]; Frame enemy[8]; int score; int rank; int rankf; std::string title; int flag_rank; Game (); //初始化所有 void initPlane(); void initBullet(); void initEnemy(); //初始化其中一个 //void initThisBullet( COORD ); //void initThisEnemy( Frame ); void planeMove(char); void bulletMove(); void enemyMove(); //填充所有 void drawPlane(); void drawPlaneToNull(); void drawBullet(); void drawBulletToNull(); void drawEnemy(); void drawEnemyToNull(); //填充其中一个 void drawThisBulletToNull( COORD ); void drawThisEnemyToNull( Frame ); void Pause(); void Playing(); void judgePlane(); void judgeEnemy(); void Shoot(); void GameOver(); void printScore(); }; Game::Game() { initPlane(); initBullet(); initEnemy(); score = 0; rank = 25; rankf = 0; flag_rank = 0; } void Game::initPlane() { COORD centren={39, 22}; position[0].X=position[5].X=position[7].X=position[9].X=centren.X; position[1].X=centren.X-2; position[2].X=position[6].X=centren.X-1; position[3].X=position[8].X=centren.X+1; position[4].X=centren.X+2; for(int i=0; i<=4; i++) position[i].Y=centren.Y; for(int i=6; i<=8; i++) position[i].Y=centren.Y+1; position[5].Y=centren.Y-1; position[9].Y=centren.Y-2; } void Game::drawPlane() { for(int i=0; i<9; i++) { SetPos(position[i]); if(i!=5) cout<<"O"; else if(i==5) cout<<"|"; } } void Game::drawPlaneToNull() { for(int i=0; i<9; i++) { SetPos(position[i]); cout<<" "; } } void Game::initBullet() { for(int i=0; i<10; i++) bullet[i].Y = 30; } void Game::drawBullet() { for(int i=0; i<10; i++) { if( bullet[i].Y != 30) { SetPos(bullet[i]); cout<<"^"; } } } void Game::drawBulletToNull() { for(int i=0; i<10; i++) if( bullet[i].Y != 30 ) { COORD pos={bullet[i].X, bullet[i].Y+1}; SetPos(pos); cout<<" "; } } void Game::initEnemy() { COORD a={1, 1}; COORD b={45, 15}; for(int i=0; i<8; i++) { enemy[i].position[0] = random(a, b); enemy[i].position[1].X = enemy[i].position[0].X + 3; enemy[i].position[1].Y = enemy[i].position[0].Y + 2; } } void Game::drawEnemy() { for(int i=0; i<8; i++) drawFrame(enemy[i].position[0], enemy[i].position[1], '-', '|'); } void Game::drawEnemyToNull() { for(int i=0; i<8; i++) { drawFrame(enemy[i].position[0], enemy[i].position[1], ' ', ' '); } } void Game::Pause() { SetPos(61,2); cout<<" "; SetPos(61,2); cout<<"暂停中..."; char c=_getch(); while(c!='p') c=_getch(); SetPos(61,2); cout<<" "; } void Game::planeMove(char x) { if(x == 'a') if(position[1].X != 1) for(int i=0; i<=9; i++) position[i].X -= 2; if(x == 's') if(position[7].Y != 23) for(int i=0; i<=9; i++) position[i].Y += 1; if(x == 'd') if(position[4].X != 47) for(int i=0; i<=9; i++) position[i].X += 2; if(x == 'w') if(position[5].Y != 3) for(int i=0; i<=9; i++) position[i].Y -= 1; } void Game::bulletMove() { for(int i=0; i<10; i++) { if( bullet[i].Y != 30) { bullet[i].Y -= 1; if( bullet[i].Y == 1 ) { COORD pos={bullet[i].X, bullet[i].Y+1}; drawThisBulletToNull( pos ); bullet[i].Y=30; } } } } void Game::enemyMove() { for(int i=0; i<8; i++) { for(int j=0; j<2; j++) enemy[i].position[j].Y++; if(24 == enemy[i].position[1].Y) { COORD a={1, 1}; COORD b={45, 3}; enemy[i].position[0] = random(a, b); enemy[i].position[1].X = enemy[i].position[0].X + 3; enemy[i].position[1].Y = enemy[i].position[0].Y + 2; } } } void Game::judgePlane() { for(int i = 0; i < 8; i++) for(int j=0; j<9; j++) if(judgeCoordInFrame(enemy[i], position[j])) { SetPos(62, 1); cout<<"坠毁"; drawFrame(enemy[i], '+', '+'); Sleep(1000); GameOver(); break; } } void Game::drawThisBulletToNull( COORD c) { SetPos(c); cout<<" "; } void Game::drawThisEnemyToNull( Frame f ) { drawFrame(f, ' ', ' '); } void Game::judgeEnemy() { for(int i = 0; i < 8; i++) for(int j = 0; j < 10; j++) if( judgeCoordInFrame(enemy[i], bullet[j]) ) { score += 5; drawThisEnemyToNull( enemy[i] ); COORD a={1, 1}; COORD b={45, 3}; enemy[i].position[0] = random(a, b); enemy[i].position[1].X = enemy[i].position[0].X + 3; enemy[i].position[1].Y = enemy[i].position[0].Y + 2; drawThisBulletToNull( bullet[j] ); bullet[j].Y = 30; } } void Game::Shoot() { for(int i=0; i<10; i++) if(bullet[i].Y == 30) { bullet[i].X = position[5].X; bullet[i].Y = position[5].Y-1; break; } } void Game::printScore() { if(score == 120 && flag_rank == 0) { rank -= 3; flag_rank = 1; } else if( score == 360 && flag_rank == 1) { rank -= 5; flag_rank = 2; } else if( score == 480 && flag_rank == 2) { rank -= 5; flag_rank = 3; } int x=rank/5; SetPos(60, 6); cout<<score; if( rank!=rankf ) { SetPos(60, 7); if( x == 5) title="初级飞行员"; else if( x == 4) title="中级飞行员"; else if( x == 3) title="高级飞行员"; else if( x == 2 ) title="王牌飞行员"; cout<<title; } rankf = rank; } void Game::Playing() { //HANDLE MFUN; //MFUN= CreateThread(NULL, 0, MusicFun, NULL, 0, NULL); drawEnemy(); drawPlane(); int flag_bullet = 0; int flag_enemy = 0; while(1) { Sleep(8); if(_kbhit()) { char x = _getch(); if ('a' == x || 's' == x || 'd' == x || 'w' == x) { drawPlaneToNull(); planeMove(x); drawPlane(); judgePlane(); } else if ('p' == x) Pause(); else if( 'k' == x) Shoot(); else if( 'e' == x) { //CloseHandle(MFUN); GameOver(); break; } } /* 处理子弹 */ if( 0 == flag_bullet ) { bulletMove(); drawBulletToNull(); drawBullet(); judgeEnemy(); } flag_bullet++; if( 5 == flag_bullet ) flag_bullet = 0; /* 处理敌人 */ if( 0 == flag_enemy ) { drawEnemyToNull(); enemyMove(); drawEnemy(); judgePlane(); } flag_enemy++; if( flag_enemy >= rank ) flag_enemy = 0; /* 输出得分 */ printScore(); } } void Game::GameOver() { system("cls"); COORD p1={28,9}; COORD p2={53,15}; drawFrame(p1, p2, '=', '|'); SetPos(36,12); string str="Game Over!"; for(int i=0; i<str.size(); i++) { Sleep(80); cout<<str[i]; } Sleep(1000); system("cls"); drawFrame(p1, p2, '=', '|'); SetPos(31, 11); cout<<"击落敌机:"<<score/5<<" 架"; SetPos(31, 12); cout<<"得 分:"<<score; SetPos(31, 13); cout<<"获得称号:"<<title; SetPos(30, 16); Sleep(1000); cout<<"继续? 是(y)| 否(n)"; as: char x=_getch(); if(x=='n'){ exit(0); } else if (x == 'y') { system("cls"); Game game; int a = drawMenu(); if(a == 2) game.rank = 20; system("cls"); drawPlaying(); game.Playing(); } else goto as; } // 工具函数:将字符串转换为全小写(消除大小写匹配影响) string toLowerCase(const string& str) { string lowerStr = str; for (char& c : lowerStr) { c = tolower(static_cast<unsigned char>(c)); } return lowerStr; } // 工具函数:将字符串转换为全大写 string toUpperCase(const string& str) { string upperStr = str; for (char& c : upperStr) { c = toupper(static_cast<unsigned char>(c)); } return upperStr; } // 工具函数:检查输入字符串是否包含指定关键词 bool containsKeyword(const string& input, const string& keyword) { string lowerInput = toLowerCase(input); string lowerKeyword = toLowerCase(keyword); return lowerInput.find(lowerKeyword) != string::npos; } // 工具函数:检查输入是否为纯数字(整数/小数) bool isNumber(const string& str) { string lowerStr = toLowerCase(str); bool hasDot = false; bool hasMinus = false; for (size_t i = 0; i < lowerStr.size(); ++i) { if (lowerStr[i] == '-') { // 负号只能在开头 if (i != 0) return false; hasMinus = true; continue; } if (lowerStr[i] == '.') { // 小数点只能出现一次,且不能在开头/结尾 if (hasDot || i == 0 || i == lowerStr.size() - 1) return false; hasDot = true; continue; } // 排除科学计数法(简化处理) if (lowerStr[i] == 'e' || lowerStr[i] == 'E') return false; if (!isdigit(static_cast<unsigned char>(lowerStr[i]))) { return false; } } return true; } // 工具函数:字符串转浮点数 double stringToDouble(const string& str) { istringstream iss(str); double num = 0.0; iss >> num; return num; } // 工具函数:字符串转整数 int stringToInt(const string& str) { istringstream iss(str); int num = 0; iss >> num; return num; } // 工具函数:获取当前系统时间和日期 string getCurrentDateTime() { time_t now = time(nullptr); tm* localTime = localtime(&now); ostringstream oss; // 格式化日期:年-月-日 oss << (localTime->tm_year + 1900) << "-" << setfill('0') << setw(2) << (localTime->tm_mon + 1) << "-" << setfill('0') << setw(2) << localTime->tm_mday << " "; // 格式化时间:时:分:秒 oss << setfill('0') << setw(2) << localTime->tm_hour << ":" << setfill('0') << setw(2) << localTime->tm_min << ":" << setfill('0') << setw(2) << localTime->tm_sec; // 添加星期几 vector<string> weekdays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"}; oss << " " << weekdays[localTime->tm_wday]; return oss.str(); } // 工具函数:获取当前季节 string getCurrentSeason() { time_t now = time(nullptr); tm* localTime = localtime(&now); int month = localTime->tm_mon + 1; if (month >= 3 && month <= 5) { return "春季(春暖花开,草长莺飞)"; } else if (month >= 6 && month <= 8) { return "夏季(骄阳似火,绿树成荫)"; } else if (month >= 9 && month <= 11) { return "秋季(秋高气爽,硕果累累)"; } else { return "冬季(银装素裹,寒风凛冽)"; } } // 工具函数:简单数学计算(加减乘除、平方、开方) string calculateMath(const string& userInput) { string lowerInput = toLowerCase(userInput); double num1 = 0.0, num2 = 0.0; string result = ""; // 提取数字(简化处理:支持两个数字的运算,或单个数字的平方/开方) vector<string> nums; string tempNum = ""; for (char c : lowerInput) { if (isdigit(c) || c == '.' || c == '-') { tempNum += c; } else { if (!tempNum.empty() && isNumber(tempNum)) { nums.push_back(tempNum); tempNum = ""; } } } // 处理最后一个数字 if (!tempNum.empty() && isNumber(tempNum)) { nums.push_back(tempNum); } if (nums.empty()) { return "抱歉,我没有识别到有效的数字,无法进行计算哦~"; } // 平方运算 if (containsKeyword(lowerInput, "平方") || containsKeyword(lowerInput, "^2")) { if (nums.size() >= 1) { num1 = stringToDouble(nums[0]); double square = num1 * num1; ostringstream oss; oss << nums[0] << "的平方结果是:" << square; return oss.str(); } } // 开方运算(仅支持非负数) if (containsKeyword(lowerInput, "开方") || containsKeyword(lowerInput, "平方根")) { if (nums.size() >= 1) { num1 = stringToDouble(nums[0]); if (num1 < 0) { return "抱歉,负数无法进行开方运算哦~"; } double sqrtNum = sqrt(num1); ostringstream oss; oss << nums[0] << "的平方根结果是:" << sqrtNum; return oss.str(); } } // 加法运算 if (containsKeyword(lowerInput, "加") || containsKeyword(lowerInput, "+") || containsKeyword(lowerInput, "求和")) { if (nums.size() >= 2) { num1 = stringToDouble(nums[0]); num2 = stringToDouble(nums[1]); double sum = num1 + num2; ostringstream oss; oss << nums[0] << " + " << nums[1] << " = " << sum; return oss.str(); } } // 减法运算 if (containsKeyword(lowerInput, "减") || containsKeyword(lowerInput, "-") || containsKeyword(lowerInput, "差值")) { if (nums.size() >= 2) { num1 = stringToDouble(nums[0]); num2 = stringToDouble(nums[1]); double diff = num1 - num2; ostringstream oss; oss << nums[0] << " - " << nums[1] << " = " << diff; return oss.str(); } } // 乘法运算 if (containsKeyword(lowerInput, "乘") || containsKeyword(lowerInput, "*") || containsKeyword(lowerInput, "乘积") || containsKeyword(lowerInput, "×")) { if (nums.size() >= 2) { num1 = stringToDouble(nums[0]); num2 = stringToDouble(nums[1]); double product = num1 * num2; ostringstream oss; oss << nums[0] << " × " << nums[1] << " = " << product; return oss.str(); } } // 除法运算(避免除零) if (containsKeyword(lowerInput, "除") || containsKeyword(lowerInput, "/") || containsKeyword(lowerInput, "商") || containsKeyword(lowerInput, "÷")) { if (nums.size() >= 2) { num1 = stringToDouble(nums[0]); num2 = stringToDouble(nums[1]); if (num2 == 0) { return "抱歉,除数不能为零哦~"; } double quotient = num1 / num2; stringstream oss; oss << nums[0] << " ÷ " << nums[1] << " = " << quotient; return oss.str(); } } // 无匹配运算 return "抱歉,我目前支持的运算有:加减乘除、平方、平方根,你可以尝试输入格式如\"10加20\"、\"5的平方\"哦~"; } // 升级后的:生活健康问答(原有6个+新增7个,共13个核心常识) string lifeCommonSense(const string& userInput) { string lowerInput = toLowerCase(userInput); map<string, string> commonSenseMap = { // 原有6个生活健康常识 {"多喝水", "每天饮用1500-2000毫升温水为宜,有助于促进新陈代谢、维持身体正常机能哦~"}, {"早睡早起", "建议每天23点前入睡,早晨7点左右起床,充足的睡眠(7-8小时)对身体健康和精神状态至关重要~"}, {"早餐重要吗", "早餐非常重要!它能为身体补充一夜消耗的能量,激活新陈代谢,减少午餐暴饮暴食的概率,建议搭配蛋白质、碳水和蔬菜~"}, {"熬夜危害", "长期熬夜会导致免疫力下降、内分泌紊乱、记忆力减退、皮肤状态变差,还可能增加心血管疾病的风险哦~"}, {"蔬菜水果", "每天建议摄入500克以上蔬菜、200-350克水果,保证维生素和膳食纤维的摄入,有助于肠道健康~"}, {"适度运动", "每周建议进行150分钟中等强度有氧运动(如快走、游泳、骑行),或75分钟高强度运动,同时搭配2-3次力量训练,有助于增强体质~"}, // 新增7个生活健康常识(满足需求) {"护眼技巧", "连续用眼不超过40分钟,每间隔远眺5米外物体10分钟,每天做1次眼保健操,避免在昏暗/强光下看电子屏幕~"}, {"养胃建议", "三餐定时定量,少吃生冷、辛辣、油炸食物,细嚼慢咽(每口咀嚼20次以上),饭后不宜立即躺下或剧烈运动~"}, {"冬季保暖", "重点做好颈部、腰部、脚踝保暖,避免露脚踝出行,室内外温差大时及时增减衣物,减少感冒风险~"}, {"夏季防暑", "避免中午10点-下午4点长时间外出,外出携带遮阳伞和淡盐水/绿豆汤,出现头晕乏力及时到阴凉处休息~"}, {"口腔护理", "每天早晚各刷牙1次(每次不少于3分钟),饭后用温水漱口,每年至少做1次口腔检查和洗牙~"}, {"缓解疲劳", "久坐1小时起身活动5分钟,拉伸肩颈和腰部,平时可多做深呼吸训练,保证每天适量饮水和微量运动~"}, {"提高免疫力", "保证充足睡眠、均衡饮食、适度运动,减少熬夜和精神压力,必要时可补充维生素C,避免频繁接触病菌~"} }; // 遍历常识库匹配完整循环逻辑 for (const auto& pair : commonSenseMap) { if (containsKeyword(lowerInput, pair.first)) { return pair.second; } } // 通用健康建议(补充额外温馨提示) if (containsKeyword(lowerInput, "健康") || containsKeyword(lowerInput, "养生") || containsKeyword(lowerInput, "身体") || containsKeyword(lowerInput, "保健")) { return "养生的核心是“规律作息、均衡饮食、适度运动、心情愉悦”哦~ 额外提示:1. 保持积极心态,减少焦虑内耗;2. 定期做全身体检,早发现早调理;3. 戒烟限酒,远离有害生活习惯;4. 根据季节变化调整养生方案,顺应自然规律~"; } // 无匹配常识 return ""; } // 工具函数:趣味互动与小知识(修复语法截断错误) string funInteraction(const string& userInput) { string lowerInput = toLowerCase(userInput); // 猜谜/趣味问答 if (containsKeyword(lowerInput, "谜语") || containsKeyword(lowerInput, "猜谜")) { vector<string> riddles = { "什么东西越洗越脏,不洗有人吃,洗了没人吃?(答案:水)", "什么东西生来就穿红衣裳,常年住在泥里塘,满身珍珠圆溜溜,酸甜可口营养棒?(答案:草莓)", "耳朵长,尾巴短,红眼睛,白毛衫,三瓣嘴儿胆子小,青菜萝卜吃个饱?(答案:兔子)", "小小诸葛亮,独坐中军帐,摆下八卦阵,专捉飞来将?(答案:蜘蛛)", "远看像座山,近看不是山,上边水直流,下边有人走?(答案:雨伞)", "有面没有口,有脚没有手,虽有四只脚,自己不会走?(答案:桌子)", "身穿白袍子,头戴红帽子,走路像公子,说话高嗓子?(答案:鹅)", "小时穿黑衣,大时穿绿衣,水里过日子,岸上来休息?(答案:青蛙)", "身小力不小,团结又勤劳,有时搬粮食,有时挖地道?(答案:蚂蚁)", "白天草里住,晚上空中游,金光闪闪动,见尾不见头?(答案:萤火虫)", "头戴红帽子,身穿白袍子,走路摆架子,说话伸脖子?(答案:鹅)", "嘴像小铲子,脚像小扇子,走路左右摆,水上划船子?(答案:鸭子)", "胖娃娃,滑手脚,红尖嘴儿一身毛,背上浅浅一道沟,肚里血红好味道?(答案:桃子)", "一个黑孩,从不开口,要是开口,掉出舌头?(答案:瓜子)", "尖尖嘴,细细腿,狡猾多疑拖大尾?(答案:狐狸)", "像球样的圆,像血样的红,向珠样的亮,样蜜样的甜?(答案:樱桃)", "小时青,老来黄,金包银,有六方?(答案:稻谷)", "身穿黄衣裳,弯弯像月亮,兄弟排一起,个个甜蜜蜜?(答案:香蕉)", "屋子方方,有门没窗,屋外热烘,屋里冰霜?(答案:冰箱)", "头戴红缨帽,身穿绿战袍,说话音清脆,时时呱呱叫?(答案:鹦鹉)", "小小坛子,装满饺子,吃掉饺子,吐出珠子?(答案:橘子)", "有手没有脚,有脸没有嘴,会走没有腿,会说没有嘴?(答案:钟表)", "身披花棉袄,唱歌呱呱叫,田里捉害虫,丰收立功劳?(答案:青蛙)", "小小毛驴不吃草,光有骨头没有毛,有人骑它它就跑,无人骑它它站着?(答案:陀螺)", "远看一朵花,近看一脸疤,开在篱笆上,朵朵喇叭花?(答案:牵牛花)" }; int riddleIdx = rand() % riddles.size(); return "我来给你出一个谜语吧:" + riddles[riddleIdx]; } if (containsKeyword(lowerInput, "笑话") || containsKeyword(lowerInput, "开心")) { vector<string> jokes = { "为什么数学书总是很忧郁?因为它有太多的问题~", "小明问妈妈:“为什么我的名字里没有一个月字?”妈妈说:“因为你爸爸姓苏啊。”", "什么动物最容易摔倒?狐狸,因为它太狡猾(脚滑)了~", "医生问病人是怎么骨折的,病人说:“我觉得鞋里有沙子,就扶着电线杆抖鞋,结果有个二货以为我触电了,拿棍子把我打骨折了。”", "从前有个土豆,走在路上突然摔倒了,然后它就变成了薯片~", "问:什么车最怕水?答:消防车,因为它最怕火,水克火呀~", "小明写作文时不会写“伞”字,就问爸爸,爸爸说:“上面一个人,下面一个米,中间加个十字。”小明写完后,作文里写的是:“今天下雨,我带了一个人米十出门。”", "为什么超人要穿紧身衣?因为救人要紧~", "一只蜗牛被两只乌龟打劫了,警察来问它发生了什么,蜗牛说:“我不知道,一切都发生得太快了。”", "什么水果最忙?芒果,因为它总是忙(芒)个不停~", "我家猫不喜欢吃鱼,我问它为什么,它说:“我怕被鱼刺卡到,毕竟我是一只讲究的猫。”", "老师问:“青蛙和癞蛤蟆有什么区别?”学生答:“青蛙思想保守,坐井观天;癞蛤蟆思想前卫,想吃天鹅肉,还成了网红。”", "从前有个馒头,走在路上饿了,就把自己吃了~", "问:什么鸟不会飞?答:菜鸟~", "妈妈问儿子:“你知道为什么袋鼠的肚子上有个袋子吗?”儿子说:“因为它怕忘记带孩子出门。”", "什么水永远喝不完?口水~", "一只蚊子叮在我的脸上,我拍了一下,蚊子没死,我脸肿了,蚊子说:“你敢打我?我给你点颜色看看。”", "为什么自行车不能骑到天上?因为它怕高(糕),怕变成自行车糕~", "小明考试考了零分,爸爸问他:“你怎么考的?”小明说:“老师说,不会的题就空着,我全空着,难道不对吗?”", "什么球离你最近?眼球~", "有个胖子从高楼跳下来,结果变成了死胖子~", "问:布和纸怕什么?答:布怕一万,纸怕万一(不怕一万,只怕万一)~", "小蚂蚁迷路了,问另一只蚂蚁:“你知道我的家在哪里吗?”另一只蚂蚁说:“你看,你家就在你屁股后面呀。”小蚂蚁回头看:“哇,原来我一直带着家走啊。”", "为什么长颈鹿的脖子那么长?因为它要吃树上的叶子,总不能让树弯腰吧~", "我对着镜子练口才,结果镜子说:“你别讲了,我都听腻了。”" }; int jokeIdx = rand() % jokes.size(); return "给你讲个笑话:" + jokes[jokeIdx]; } if (containsKeyword(lowerInput, "小知识") || containsKeyword(lowerInput, "冷知识")) { vector<string> coldKnowledge = { "蜜蜂的翅膀每分钟振动约11400次,所以飞行时会发出“嗡嗡”声~", "水在真空中会先沸腾后结冰,因为真空环境气压为0,水的沸点会大幅降低~", "人的指甲生长速度比脚趾甲快约4倍,且夏天比冬天长得快~", "北极熊的皮肤其实是黑色的,它的白毛是透明的,能反射光线看起来是白色~", "章鱼有3个心脏,9个大脑,其中一个主脑在头部,8个副脑在腕足上~", "柠檬的维生素C含量比橙子还高,一颗柠檬的维C能满足成人一天的需求~", "我们看到的月光,其实是月球反射的太阳光,且光线到达地球需要约1.3秒~", "蜗牛的牙齿数量是动物中最多的,有超过25000颗牙齿,藏在它的舌头上~", "牛奶加热后会结皮,是因为牛奶中的蛋白质受热后凝固,浮在表面形成奶皮~", "人的眼睛在黑暗中适应环境需要约20-30分钟,这期间视力会慢慢提升~", "蒲公英的种子上的绒毛,能让它借助风力飘到数公里外,提高繁殖概率~", "骆驼的驼峰里不是水,而是脂肪,脂肪分解时能同时产生水和能量,供骆驼在沙漠中生存~", "扑克牌中的54张牌,代表一年有52个星期,大王和小王代表太阳和月亮~", "向日葵并不是一直跟着太阳转,成熟后的向日葵会固定朝向东方~", "人的耳朵和鼻子一辈子都在生长,只是速度非常缓慢,几乎看不出来~", "蜂蜜永远不会变质,考古学家曾在古埃及墓葬中发现3000多年前的蜂蜜,仍可食用~", "猫的瞳孔会随光线变化,强光下变细成一条线,弱光下变圆,能更好地调节进光量~", "乒乓球最初的材质是赛璐珞,现在改用塑料,更环保也更耐用~", "彩虹的颜色顺序是红、橙、黄、绿、青、蓝、紫,是光的色散形成的,反向彩虹颜色顺序相反~", "大象是唯一不会跳跃的哺乳动物,因为它的体重太大,骨骼结构无法支撑跳跃的冲击力~", "人的舌头有不同的味觉区域,舌尖尝甜,舌侧尝酸,舌根尝苦,舌面尝咸~", "雪花的形状都是六边形的,且世界上没有两片完全相同的雪花~", "竹子其实是草本植物,不是木本植物,它的茎干没有形成层,不会逐年长粗~", "冰箱的冷藏室温度一般在0-4℃,这个温度能抑制细菌繁殖,延长食物保质期~", "蜻蜓的眼睛是复眼,由数万个小眼睛组成,能同时看到360度的视野,捕捉猎物时非常精准~" }; int knowledgeIdx = rand() % coldKnowledge.size(); return "冷知识分享:" + coldKnowledge[knowledgeIdx]; } // 完整闭合语法,补充完整的containsKeyword调用 if (containsKeyword(lowerInput, "加油") || containsKeyword(lowerInput, "鼓励")) { vector<string> cheer_words = { "冲就完事了,你肯定行!", "别怕困难,一步一步来,你超棒的!", "加油加油,你的努力都会有结果~", "坚持住,胜利就在前方啦!", "你超厉害的,这点小事根本难不倒你!", "只管往前冲,背后有人为你撑腰~", "全力以赴就好,你已经很棒了!", "越努力越幸运,继续加油呀!", "放平心态,大胆去做,你超赞的!", "朝着目标冲,你一定能做到!" }; int cheerIdx = rand() % cheer_words.size(); return cheer_words[cheerIdx]; } if (containsKeyword(lowerInput, "谢谢") || containsKeyword(lowerInput, "感谢")) { vector<string> thank_words = { "不客气,能帮到你就好。", "不用谢,举手之劳而已。", "没事儿,应该的。", "客气啥,以后有事随时说。", "不用这么见外,互相帮忙是应该的。", "谢啥呀,能搞定就行~", "不客气,这是我该做的,有需要随时开口。", "不用感谢,能配合完成事情就好。", "你太客气了,举手之劳,不必挂怀。", "不客气,后续有其他需求,也可以告诉我。" }; int thankIdx = rand() % thank_words.size(); return thank_words[thankIdx]; } // 无匹配趣味内容 return ""; } long long blk_void_phantom[6][6]; // 棋盘尺寸 const int sz_abyss_crimson = 4; // 怪异函数:初始化空白棋盘 void init_void_chaos_nexus() { for(int qwq_shadow=0;qwq_shadow<sz_abyss_crimson;qwq_shadow++) for(int awa_horror=0;awa_horror<sz_abyss_crimson;awa_horror++) blk_void_phantom[qwq_shadow][awa_horror] = 0; } // 怪异函数:随机生成2/4 void spawn_rand_dark_echo() { int x_soul_fall,y_dust_grave; while(true) { x_soul_fall = rand()%sz_abyss_crimson; y_dust_grave = rand()%sz_abyss_crimson; if(blk_void_phantom[x_soul_fall][y_dust_grave] == 0) { int rnd_omen = rand()%10; blk_void_phantom[x_soul_fall][y_dust_grave] = (rnd_omen<7) ? 2 : 4; break; } } } // 怪异函数:绘制界面 void render_ghost_ruin_wall() { system("cls"); for(int i_night_mist=0;i_night_mist<sz_abyss_crimson;i_night_mist++) { for(int j_blood_veil=0;j_blood_veil<sz_abyss_crimson;j_blood_veil++) { cout<<blk_void_phantom[i_night_mist][j_blood_veil]<<"\t"; } cout<<endl<<endl; } cout<<"【w/s/a/d】上下左右 | 怪异2048"<<endl; } // 左移合并 void shift_left_abyss_tide() { for(int i=0;i<4;i++) { for(int col=0;col<4;col++) { if(blk_void_phantom[i][col]==0)continue; for(int k=col+1;k<4;k++) { if(blk_void_phantom[i][k]==0)continue; if(blk_void_phantom[i][col]==blk_void_phantom[i][k]) { blk_void_phantom[i][col] *= 2; blk_void_phantom[i][k] = 0; } break; } } // 空位左挤 for(int t=0;t<4;t++) { for(int p=0;p<3;p++) { if(blk_void_phantom[i][p]==0) { blk_void_phantom[i][p] = blk_void_phantom[i][p+1]; blk_void_phantom[i][p+1] = 0; } } } } } // 右移合并 void shift_right_curse_flame() { for(int i=0;i<4;i++) { for(int col=3;col>=0;col--) { if(blk_void_phantom[i][col]==0)continue; for(int k=col-1;k>=0;k--) { if(blk_void_phantom[i][k]==0)continue; if(blk_void_phantom[i][col]==blk_void_phantom[i][k]) { blk_void_phantom[i][col] *= 2; blk_void_phantom[i][k] = 0; } break; } } for(int t=0;t<4;t++) { for(int p=3;p>0;p--) { if(blk_void_phantom[i][p]==0) { blk_void_phantom[i][p] = blk_void_phantom[i][p-1]; blk_void_phantom[i][p-1] = 0; } } } } } // 上移合并 void shift_above_frost_soul() { for(int j=0;j<4;j++) { for(int row=0;row<4;row++) { if(blk_void_phantom[row][j]==0)continue; for(int k=row+1;k<4;k++) { if(blk_void_phantom[k][j]==0)continue; if(blk_void_phantom[row][j]==blk_void_phantom[k][j]) { blk_void_phantom[row][j] *= 2; blk_void_phantom[k][j] = 0; } break; } } for(int t=0;t<4;t++) { for(int p=0;p<3;p++) { if(blk_void_phantom[p][j]==0) { blk_void_phantom[p][j] = blk_void_phantom[p+1][j]; blk_void_phantom[p+1][j] = 0; } } } } } // 下移合并 void shift_down_demon_ash() { for(int j=0;j<4;j++) { for(int row=3;row>=0;row--) { if(blk_void_phantom[row][j]==0)continue; for(int k=row-1;k>=0;k--) { if(blk_void_phantom[k][j]==0)continue; if(blk_void_phantom[row][j]==blk_void_phantom[k][j]) { blk_void_phantom[row][j] *= 2; blk_void_phantom[k][j] = 0; } break; } } for(int t=0;t<4;t++) { for(int p=3;p>0;p--) { if(blk_void_phantom[p][j]==0) { blk_void_phantom[p][j] = blk_void_phantom[p-1][j]; blk_void_phantom[p-1][j] = 0; } } } } } // 检测是否合成2048【通关】 bool chk_victory_eternal_blade() { for(int xx_lost_dusk=0;xx_lost_dusk<4;xx_lost_dusk++) for(int yy_wither_moon=0;yy_wither_moon<4;yy_wither_moon++) if(blk_void_phantom[xx_lost_dusk][yy_wither_moon] == 2048) return true; return false; } // 检测是否彻底无路可走【失败】 bool chk_gameover_void_realm() { // 1. 先看有没有空格,有空格就没失败 for(int x_black_flame=0;x_black_flame<4;x_black_flame++) for(int y_cold_shadow=0;y_cold_shadow<4;y_cold_shadow++) if(blk_void_phantom[x_black_flame][y_cold_shadow] == 0) return false; // 2. 横向相邻能否合并 for(int i=0;i<4;i++) for(int j=0;j<3;j++) if(blk_void_phantom[i][j] == blk_void_phantom[i][j+1]) return false; // 3. 纵向相邻能否合并 for(int j=0;j<4;j++) for(int i=0;i<3;i++) if(blk_void_phantom[i][j] == blk_void_phantom[i+1][j]) return false; // 全部不能动 → 游戏结束 return true; } // 升级后的:日常工具类功能(原有4个+新增5个,共9个核心工具) string dailyTools(const string& userInput) { string lowerInput = toLowerCase(userInput); // 1. 长度单位换算(米<->厘米,千米<->米) if (containsKeyword(lowerInput, "米") && containsKeyword(lowerInput, "厘米")) { vector<string> nums; string tempNum = ""; for (char c : lowerInput) { if (isdigit(c) || c == '.') { tempNum += c; } else { if (!tempNum.empty() && isNumber(tempNum)) { nums.push_back(tempNum); tempNum = ""; } } } if (!tempNum.empty() && isNumber(tempNum)) nums.push_back(tempNum); if (!nums.empty()) { double num = stringToDouble(nums[0]); if (containsKeyword(lowerInput, "米转厘米") || containsKeyword(lowerInput, "米换厘米")) { ostringstream oss; oss << num << "米 = " << num * 100 << "厘米"; return oss.str(); } else { ostringstream oss; oss << num << "厘米 = " << num / 100 << "米"; return oss.str(); } } } // 2. 重量单位换算(千克<->克) if (containsKeyword(lowerInput, "千克") && containsKeyword(lowerInput, "克")) { vector<std::string> nums; string tempNum = ""; for (char c : lowerInput) { if (isdigit(c) || c == '.') { tempNum += c; } else { if (!tempNum.empty() && isNumber(tempNum)) { nums.push_back(tempNum); tempNum = ""; } } } if (!tempNum.empty() && isNumber(tempNum)) nums.push_back(tempNum); if (!nums.empty()) { double num = stringToDouble(nums[0]); if (containsKeyword(lowerInput, "千克转克") || containsKeyword(lowerInput, "千克换克")) { std::ostringstream oss; oss << num << "千克 = " << num * 1000 << "克"; return oss.str(); } else { std::ostringstream oss; oss << num << "克 = " << num / 1000 << "千克"; return oss.str(); } } } // 3. 密码安全建议 if (containsKeyword(lowerInput, "密码安全建议") || containsKeyword(lowerInput, "密码安全") || containsKeyword(lowerInput, "账号安全")) { std::vector<std::string> Words_protect={ "密码长度不少于8位,包含大小写字母、数字和特殊符号", "不同平台使用不同密码,避免“一套密码走天下”", "定期更换密码(建议3-6个月一次)", "不要将密码告诉他人,也不要记录在易泄露的地方~", "密码分级设置建议:\n1. 核心级(金融/支付/社保):12位以上高强度密码(含特殊符号),独立设置;\n2. 重要级(社交/邮箱/购物):10位混合密码,不同平台不重复;\n3. 普通级(论坛/小游戏/测试平台):8位简易密码,可复用但需定期改;\n4. 临时级(一次性注册):随机生成,无需记忆,用完可弃。\n" }; int thankIdx123= rand() %Words_protect.size(); return Words_protect[thankIdx123]; } if(containsKeyword(userInput,"密码记忆") || containsKeyword(userInput,"如何记忆密码") || containsKeyword(userInput,"记密码技巧") || containsKeyword(userInput,"记住密码的技巧")){ std::vector<std::string> Class_remenber={ "首字母法:用一句熟悉的话提取首字母,搭配数字/符号(如“今天吃火锅123”→JTCBG123!)", "替换法:将字母替换为相似数字(如a→4,b→8,s→5)", "固定前缀+平台后缀:如Core_WeChat123,Core_Alipay456", "使用正规密码管理器(如系统自带/知名第三方),仅记主密码。" }; int thankIdx11123= rand() %Class_remenber.size(); return Class_remenber[thankIdx11123]; } if (containsKeyword(lowerInput, "手机密码技巧") || containsKeyword(userInput,"手机密码建议") || containsKeyword(lowerInput, "锁屏密码建议") || containsKeyword(userInput,"锁屏密码建议") || containsKeyword(userInput,"手机密码建议") || containsKeyword(userInput,"密码建议")) { std::vector<std::string> Phone_skil={ "数字密码避免6位相同/连号(如123456/666666)、生日/手机号后6位", "推荐使用混合密码(图案+数字)或指纹/面部识别,开启二次验证", "手机支付密码与锁屏密码区分,不将密码告知他人", "开启密码错误多次锁定功能,防止暴力破解。" }; int thankIdx1123= rand() %Phone_skil.size(); return Phone_skil[thankIdx1123]; } if (containsKeyword(lowerInput, "改密码频率") || containsKeyword(lowerInput, "密码更换周期") || containsKeyword(lowerInput, "改密码周期") || containsKeyword(lowerInput, "更换密码频率")) { return "密码更换频率建议(按平台类型):\n1. 金融/支付/社保:3-6个月更换一次,若出现异常立即更换;\n2. 社交/邮箱/办公:6-12个月更换一次;\n3. 普通平台/论坛:12个月以上或平台提示风险时更换;\n4. 注意:更换时避免仅修改末尾1位,需大幅调整,不重复历史密码。"; } // 4. 文件备份建议 if (containsKeyword(lowerInput, "备份") || containsKeyword(lowerInput, "文件") || containsKeyword(lowerInput, "数据")) { return "数据备份小贴士:1. 采用“321备份原则”(3份数据、2种介质、1份异地);2. 重要文件定期备份到U盘、移动硬盘或云盘;3. 开启云盘自动同步功能,避免手动备份遗漏;4. 定期检查备份文件的完整性,确保可正常恢复~"; } // 新增5个日常工具类功能(满足需求) // 5. 简易日期推算(明天/昨天的日期) if (containsKeyword(lowerInput, "明天") || containsKeyword(lowerInput, "昨天")) { std::time_t now = std::time(nullptr); std::tm* tmPtr = localtime(&now); if (containsKeyword(lowerInput, "明天")) { tmPtr->tm_mday += 1; } else { tmPtr->tm_mday -= 1; } mktime(tmPtr); // 自动校正日期(跨月/跨年) std::ostringstream oss; oss << (tmPtr->tm_year + 1900) << "-" << std::setfill('0') << std::setw(2) << (tmPtr->tm_mon + 1) << "-" << std::setfill('0') << std::setw(2) << tmPtr->tm_mday; std::vector<std::string> weekdays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"}; oss << " " << weekdays[tmPtr->tm_wday]; return containsKeyword(lowerInput, "明天") ? "明天的日期是:" + oss.str() : "昨天的日期是:" + oss.str(); } // 6. 人民币大小写简易转换(仅支持1-999元,日常常用) if (containsKeyword(lowerInput, "人民币转换") || containsKeyword(lowerInput, "大小写转换")) { std::vector<std::string> nums; std::string tempNum = ""; for (char c : lowerInput) { if (isdigit(c)) { tempNum += c; } else { if (!tempNum.empty() && isNumber(tempNum)) { nums.push_back(tempNum); tempNum = ""; } } } if (!tempNum.empty() && isNumber(tempNum)) nums.push_back(tempNum); if (nums.empty()) { return "请输入需要转换的金额(1-999元),例如“人民币转换 123”~"; } int amount = stringToInt(nums[0]); if (amount < 1 || amount > 999) { return "暂支持1-999元的简易转换,后续将扩展更多金额~"; } std::string chineseNum[] = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"}; std::string unit[] = {"元", "拾", "佰"}; int bai = amount / 100; int shi = (amount % 100) / 10; int ge = amount % 10; std::ostringstream oss; if (bai > 0) oss << chineseNum[bai] << unit[2]; if (shi > 0) oss << (shi == 1 && bai == 0 ? "" : chineseNum[shi]) << unit[1]; if (ge > 0 || amount == 0) oss << chineseNum[ge] << unit[0]; return nums[0] + "元 对应的人民币大写是:" + oss.str() + "(整)"; } // 7. 出行打包小贴士(日常/短途) if (containsKeyword(lowerInput, "打包") || containsKeyword(lowerInput, "出行整理")) { return "短途出行打包小贴士:1. 采用“分层打包法”,常用物品放外层,衣物放内层;2. 衣物卷起来存放,节省空间且不易起皱;3. 洗漱用品用密封袋装好,避免漏液;4. 必备物品:身份证/手机/充电器/纸巾/雨伞,提前放入随身包;5. 鞋子单独包装,避免弄脏衣物~"; } // 8. 家庭小妙招(日常实用) if (containsKeyword(lowerInput, "生活妙招") || containsKeyword(lowerInput, "家庭技巧")) { return "日常家庭小妙招:1. 去除水垢:用白醋浸泡水垢处30分钟,再用抹布擦拭;2. 去除衣物油渍:用洗洁精直接涂抹在油渍处,静置10分钟后正常清洗;3. 延长鲜花花期:在花瓶水中加入少许白糖或阿司匹林;4. 去除冰箱异味:放入几块活性炭或切开的柠檬,定期更换~"; } // 无匹配工具功能 return ""; } // ====================== 游戏类功能(保留完整) ====================== // 子功能:猜数字游戏 void playGuessNumber() { std::cout<<"你想要曹SB自创还是AI?\n"; std::string s; std::cin>>s; if(s=="AI"||s=="ai"||s=="Ai"||s=="aI"){ std::cout << "\n===== 猜数字游戏 开始 =====" << std::endl; std::cout << "游戏规则:我会生成一个1-100之间的随机整数,你需要猜出它,我会提示你“大了”或“小了”~" << std::endl; std::cout << "输入“放弃”可结束当前游戏。" << std::endl; // 初始化随机数种子 srand(static_cast<unsigned int>(time(nullptr))); int targetNum = rand() % 100 + 1; std::string userGuessStr; int userGuess = 0; int guessCount = 0; while (true) { std::cout << "\n请输入你的猜测(1-100):"; std::getline(std::cin, userGuessStr); // 放弃游戏 if (toLowerCase(userGuessStr) == "放弃" || toLowerCase(userGuessStr) == "quit") { std::cout << "游戏结束!正确答案是:" << targetNum << ",下次加油哦~" << std::endl; break; } // 验证输入是否为有效整数 if (!isNumber(userGuessStr) || stringToDouble(userGuessStr) != floor(stringToDouble(userGuessStr))) { std::cout << "输入无效!请输入一个1-100之间的整数哦~" << std::endl; continue; } userGuess = stringToInt(userGuessStr); guessCount++; // 验证数值范围 if (userGuess < 1 || userGuess > 100) { std::cout << "数值超出范围!请输入1-100之间的整数~" << std::endl; continue; } // 判断猜测结果 if (userGuess > targetNum) { std::cout << "提示:你猜的数字大了,再小一点试试~" << std::endl; } else if (userGuess < targetNum) { std::cout << "提示:你猜的数字小了,再大一点试试~" << std::endl; } else { std::cout << "恭喜你!猜对啦!" << std::endl; std::cout << "你一共猜了 " << guessCount << " 次,太厉害了~" << std::endl; break; } } std::cout << "===== 猜数字游戏 结束 =====" << std::endl; }else if(s=="曹SB"||s=="曹莫凡"){ std::cout<<"===== 猜数字游戏 开始 =====\n"; while(1){ std::cout<<"你想要几级难度?\n"; std::cout<<"1. 一级难度:1~20里面猜数\n"; std::cout<<"2. 二级难度:1~50里面猜数\n"; std::cout<<"3. 三级难度:1~100里面猜数\n"; std::cout<<"4. 四级难度:1~250里面猜数\n"; std::cout<<"5. 五级难度:1~500里面猜数\n"; std::cout<<"请按数字选择难度\n"; int a; std::cin>>a; if(a==1){ int b=rand()%20+1; std::cout<<"你一共可以猜3次\n开始吧!"; std::cout<<"\n你:"; int c; int d=3; int flag=0; while(d--){ std::cin>>c; if(c>b){ std::cout<<"大了!\n"; }else if(c<b){ std::cout<<"小了!\n"; }else{ std::cout<<"猜对了!\n"; flag=1; break; } } if(flag==0){ std::cout<<"很遗憾,你猜错了!\n你真菜!\n正确答案是:"<<b<<"\n"; } }else if(a==2){ int b=rand()%50+1; std::cout<<"你一共可以猜4次\n开始吧!"; std::cout<<"\n你:"; int c; int d=4; int flag=0; while(d--){ std::cin>>c; if(c>b){ std::cout<<"大了!\n"; }else if(c<b){ std::cout<<"小了!\n"; }else{ std::cout<<"猜对了!\n"; flag=1; break; } } if(flag==0){ std::cout<<"很遗憾,你猜错了!\n你真菜!\n正确答案是:"<<b<<"\n"; } }else if(a==3){ int b=rand()%50+1; std::cout<<"你一共可以猜6次\n开始吧!"; std::cout<<"\n你:"; int c; int d=6; int flag=0; while(d--){ std::cin>>c; if(c>b){ std::cout<<"大了!\n"; }else if(c<b){ std::cout<<"小了!\n"; }else{ std::cout<<"猜对了!\n"; flag=1; break; } } if(flag==0){ std::cout<<"很遗憾,你猜错了!\n你真菜!\n正确答案是:"<<b<<"\n"; } }else if(a==4){ int b=rand()%50+1; std::cout<<"你一共可以猜7次\n开始吧!"; std::cout<<"\n你:"; int c; int d=7; int flag=0; while(d--){ std::cin>>c; if(c>b){ std::cout<<"大了!\n"; }else if(c<b){ std::cout<<"小了!\n"; }else{ std::cout<<"猜对了!\n"; flag=1; break; } } if(flag==0){ std::cout<<"很遗憾,你猜错了!\n你真菜!\n正确答案是:"<<b<<"\n"; } }else{ int b=rand()%50+1; std::cout<<"你一共可以猜9次\n开始吧!"; std::cout<<"\n你:"; int c; int d=9; int flag=0; while(d--){ std::cin>>c; if(c>b){ std::cout<<"大了!\n"; }else if(c<b){ std::cout<<"小了!\n"; }else{ std::cout<<"猜对了!\n"; flag=1; break; } } if(flag==0){ std::cout<<"很遗憾,你猜错了!\n你真菜!\n正确答案是:"<<b<<"\n"; } } std::cout<<"你还想玩吗?\n1.想玩 2.退出\n"; int abc; std::cin>>abc; if(abc==1){ continue; }else{ break; } } std::cout << "===== 猜数字游戏 结束 =====\n"; } } // 子功能:五子棋游戏(简化版,9*9棋盘,人机对战简易逻辑) void playGomoku() { std::cout << "\n===== 五子棋游戏 开始 =====" << std::endl; std::cout << "游戏规则:9*9棋盘,你执黑子(X),我执白子(O),先连成5子(横/竖/斜)者获胜~" << std::endl; std::cout << "输入格式:行号 列号(如“3 5”,行号和列号均为1-9),输入“放弃”可结束当前游戏。" << std::endl; // 初始化9*9棋盘,空格表示空位置 std::vector<std::vector<char>> board(9, std::vector<char>(9, ' ')); std::string userInput; int row = 0, col = 0; // 打印棋盘辅助函数 auto printBoard = [&]() { std::cout << "\n 1 2 3 4 5 6 7 8 9" << std::endl; std::cout << " +-------------------+" << std::endl; for (int i = 0; i < 9; ++i) { std::cout << i+1 << " | "; for (int j = 0; j < 9; ++j) { std::cout << board[i][j] << " "; } std::cout << "|" << std::endl; } std::cout << " +-------------------+" << std::endl; }; // 检查是否获胜辅助函数 auto checkWin = [&](int r, int c, char piece) -> bool { // 横向检查 int count = 0; for (int j = 0; j < 9; ++j) { if (board[r][j] == piece) { count++; if (count == 5) return true; } else { count = 0; } } // 纵向检查 count = 0; for (int i = 0; i < 9; ++i) { if (board[i][c] == piece) { count++; if (count == 5) return true; } else { count = 0; } } // 斜向1(左上到右下) count = 0; int startR = r - std::min(r, c); int startC = c - std::min(r, c); while (startR < 9 && startC < 9) { if (board[startR][startC] == piece) { count++; if (count == 5) return true; } else { count = 0; } startR++; startC++; } // 斜向2(右上到左下) count = 0; startR = r - std::min(r, 8 - c); startC = c + std::min(r, 8 - c); while (startR < 9 && startC >= 0) { if (board[startR][startC] == piece) { count++; if (count == 5) return true; } else { count = 0; } startR++; startC--; } return false; }; // 电脑简易落子(优先占空,简单防守) auto computerMove = [&]() { // 优先填充用户附近的空位(简化逻辑) for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) { if (board[i][j] == ' ') { board[i][j] = 'O'; return; } } } }; // 游戏主循环 printBoard(); while (true) { // 用户落子 std::cout << "\n请输入你的落子位置:"; std::getline(std::cin, userInput); // 放弃游戏 if (toLowerCase(userInput) == "放弃" || toLowerCase(userInput) == "quit") { std::cout << "游戏结束!感谢参与五子棋游戏~" << std::endl; break; } // 解析输入(行 列) std::istringstream iss(userInput); if (!(iss >> row >> col) || row < 1 || row > 9 || col < 1 || col > 9) { std::cout << "输入无效!请按照“行号 列号”的格式输入(如“3 5”),行号列号均为1-9~" << std::endl; continue; } // 转换为数组索引(0开始) row--; col--; // 检查位置是否为空 if (board[row][col] != ' ') { std::cout << "该位置已经有棋子了!请选择其他空位~" << std::endl; continue; } // 用户落子(X) board[row][col] = 'X'; printBoard(); // 检查用户是否获胜 if (checkWin(row, col, 'X')) { std::cout << "恭喜你!你获胜了!五子连珠,太厉害了~" << std::endl; break; } // 电脑落子(O) std::cout << "我正在落子中..."; computerMove(); std::cout << "完成!" << std::endl; printBoard(); // 检查电脑是否获胜(简化逻辑,遍历找O的五子连珠) bool computerWin = false; for (int i = 0; i < 9 && !computerWin; ++i) { for (int j = 0; j < 9 && !computerWin; ++j) { if (board[i][j] == 'O') { computerWin = checkWin(i, j, 'O'); } } } if (computerWin) { std::cout << "我获胜啦!下次你可以再努力一点哦~" << std::endl; break; } } std::cout << "===== 五子棋游戏 结束 =====" << std::endl; } // 子功能:简易国际象棋(简化规则,8*8棋盘,核心棋子移动逻辑) void playSimpleChess() { std::cout << "\n===== 简易国际象棋 开始 =====" << std::endl; std::cout << "游戏规则:8*8棋盘,你执白棋(大写字母),我执黑棋(小写字母),核心棋子:王(K/k)、后(Q/q)、兵(P/p)~" << std::endl; std::cout << "输入格式:原位置 目标位置(如“a2 a4”,字母a-h表示列,数字1-8表示行),输入“放弃”可结束当前游戏。" << std::endl; std::cout << "简化规则:兵只能向前走1步,后可以横/竖/斜走任意步,王只能走1步(暂不支持吃子、将军等复杂规则)~" << std::endl; // 初始化8*8棋盘 std::vector<std::vector<char>> board(8, std::vector<char>(8, ' ')); // 初始化兵的位置 for (int j = 0; j < 8; ++j) { board[1][j] = 'P'; // 白兵(用户) board[6][j] = 'p'; // 黑兵(电脑) } // 初始化王和后的位置 board[0][3] = 'Q'; // 白后 board[0][4] = 'K'; // 白王 board[7][3] = 'q'; // 黑后 board[7][4] = 'k'; // 黑王 std::string userInput; std::string fromPos, toPos; // 打印棋盘辅助函数 auto printChessBoard = [&]() { std::cout << "\n a b c d e f g h" << std::endl; std::cout << " +-----------------+" << std::endl; for (int i = 0; i < 8; ++i) { std::cout << 8 - i << " | "; for (int j = 0; j < 8; ++j) { std::cout << board[i][j] << " "; } std::cout << "|" << 8 - i << std::endl; } std::cout << " +-----------------+" << std::endl; std::cout << " a b c d e f g h" << std::endl; }; // 位置转换辅助函数(如a2 -> (6, 0)) auto posToIndex = [&](const std::string& pos, int& row, int& col) -> bool { if (pos.size() != 2) return false; char colChar = tolower(pos[0]); char rowChar = pos[1]; if (colChar < 'a' || colChar > 'h' || rowChar < '1' || rowChar > '8') return false; col = colChar - 'a'; row = 8 - (rowChar - '0'); return true; }; // 游戏主循环 printChessBoard(); while (true) { // 用户走棋 std::cout << "\n请输入你的走棋(格式如“a2 a4”):"; std::getline(std::cin, userInput); // 放弃游戏 if (toLowerCase(userInput) == "放弃" || toLowerCase(userInput) == "quit") { std::cout << "游戏结束!感谢参与简易国际象棋游戏~" << std::endl; break; } // 解析输入 std::istringstream iss(userInput); if (!(iss >> fromPos >> toPos)) { std::cout << "输入无效!请按照“原位置 目标位置”的格式输入(如“a2 a4”)~" << std::endl; continue; } // 转换位置为索引 int fromRow, fromCol, toRow, toCol; if (!posToIndex(fromPos, fromRow, fromCol) || !posToIndex(toPos, toRow, toCol)) { std::cout << "位置无效!请输入a-h列和1-8行组成的位置(如“a2”)~" << std::endl; continue; } // 检查原位置是否有用户的棋子(大写字母) if (board[fromRow][fromCol] == ' ' || islower(board[fromRow][fromCol])) { std::cout << "原位置没有你的棋子!请选择自己的白棋(大写字母)~" << std::endl; continue; } // 简化:暂不验证棋子移动规则,直接移动(复杂规则可后续扩展) board[toRow][toCol] = board[fromRow][fromCol]; board[fromRow][fromCol] = ' '; std::cout << "你的走棋完成!" << std::endl; printChessBoard(); // 电脑简易走棋(随机移动一个黑棋,简化逻辑) std::cout << "我正在走棋中..."; bool computerMoved = false; for (int i = 0; i < 8 && !computerMoved; ++i) { for (int j = 0; j < 8 && !computerMoved; ++j) { if (islower(board[i][j])) { // 简单移动逻辑:尝试向前或向右移动一格 if (i+1 < 8 && board[i+1][j] == ' ') { board[i+1][j] = board[i][j]; board[i][j] = ' '; computerMoved = true; } else if (j+1 < 8 && board[i][j+1] == ' ') { board[i][j+1] = board[i][j]; board[i][j] = ' '; computerMoved = true; } } } } std::cout << "完成!" << std::endl; printChessBoard(); } std::cout << "===== 简易国际象棋 结束 =====" << std::endl; } // 怪异变量名(绝对不重名) int z4kR1ddl3_m47r1x[4][4]; // 初始化棋盘 void init_z3r0_f13ld() { for(int i=0;i<4;i++) for(int j=0;j<4;j++) z4kR1ddl3_m47r1x[i][j] = 0; } // 随机生成2/4 void sp4wn_r4nd_crypt() { int aX3l_p0s, b34m_p0s; while(1){ aX3l_p0s = rand()%4; b34m_p0s = rand()%4; if(z4kR1ddl3_m47r1x[aX3l_p0s][b34m_p0s] == 0){ z4kR1ddl3_m47r1x[aX3l_p0s][b34m_p0s] = rand()%10<7 ? 2 : 4; break; } } } // 画界面 void sh0w_crypt_m47r1x() { system("cls"); for(int i=0;i<4;i++){ for(int j=0;j<4;j++) cout << z4kR1ddl3_m47r1x[i][j] << "\t"; cout << "\n\n"; } cout << " W S A D 移动\n"; } // 左移 void m0v3_l3ft_sh4d0w() { for(int i=0;i<4;i++){ for(int k=0;k<3;k++) for(int j=0;j<3;j++) if(z4kR1ddl3_m47r1x[i][j]==0) swap(z4kR1ddl3_m47r1x[i][j],z4kR1ddl3_m47r1x[i][j+1]); for(int j=0;j<3;j++) if(z4kR1ddl3_m47r1x[i][j]==z4kR1ddl3_m47r1x[i][j+1]){ z4kR1ddl3_m47r1x[i][j]*=2; z4kR1ddl3_m47r1x[i][j+1]=0; } for(int k=0;k<3;k++) for(int j=0;j<3;j++) if(z4kR1ddl3_m47r1x[i][j]==0) swap(z4kR1ddl3_m47r1x[i][j],z4kR1ddl3_m47r1x[i][j+1]); } } // 右移 void m0v3_r1ght_sh4d0w() { for(int i=0;i<4;i++){ for(int k=0;k<3;k++) for(int j=3;j>0;j--) if(z4kR1ddl3_m47r1x[i][j]==0) swap(z4kR1ddl3_m47r1x[i][j],z4kR1ddl3_m47r1x[i][j-1]); for(int j=3;j>0;j--) if(z4kR1ddl3_m47r1x[i][j]==z4kR1ddl3_m47r1x[i][j-1]){ z4kR1ddl3_m47r1x[i][j]*=2; z4kR1ddl3_m47r1x[i][j-1]=0; } for(int k=0;k<3;k++) for(int j=3;j>0;j--) if(z4kR1ddl3_m47r1x[i][j]==0) swap(z4kR1ddl3_m47r1x[i][j],z4kR1ddl3_m47r1x[i][j-1]); } } // 上移 void m0v3_up_sh4d0w() { for(int j=0;j<4;j++){ for(int k=0;k<3;k++) for(int i=0;i<3;i++) if(z4kR1ddl3_m47r1x[i][j]==0) swap(z4kR1ddl3_m47r1x[i][j],z4kR1ddl3_m47r1x[i+1][j]); for(int i=0;i<3;i++) if(z4kR1ddl3_m47r1x[i][j]==z4kR1ddl3_m47r1x[i+1][j]){ z4kR1ddl3_m47r1x[i][j]*=2; z4kR1ddl3_m47r1x[i+1][j]=0; } for(int k=0;k<3;k++) for(int i=0;i<3;i++) if(z4kR1ddl3_m47r1x[i][j]==0) swap(z4kR1ddl3_m47r1x[i][j],z4kR1ddl3_m47r1x[i+1][j]); } } // 下移 void m0v3_d0wn_sh4d0w() { for(int j=0;j<4;j++){ for(int k=0;k<3;k++) for(int i=3;i>0;i--) if(z4kR1ddl3_m47r1x[i][j]==0) swap(z4kR1ddl3_m47r1x[i][j],z4kR1ddl3_m47r1x[i-1][j]); for(int i=3;i>0;i--) if(z4kR1ddl3_m47r1x[i][j]==z4kR1ddl3_m47r1x[i-1][j]){ z4kR1ddl3_m47r1x[i][j]*=2; z4kR1ddl3_m47r1x[i-1][j]=0; } for(int k=0;k<3;k++) for(int i=3;i>0;i--) if(z4kR1ddl3_m47r1x[i][j]==0) swap(z4kR1ddl3_m47r1x[i][j],z4kR1ddl3_m47r1x[i-1][j]); } } // 判断胜利 bool ch3ck_v1ct0ry() { for(int i=0;i<4;i++) for(int j=0;j<4;j++) if(z4kR1ddl3_m47r1x[i][j]==2048) return 1; return 0; } // 判断失败 bool ch3ck_g4m30v3r() { for(int i=0;i<4;i++) for(int j=0;j<4;j++) if(z4kR1ddl3_m47r1x[i][j]==0) return 0; for(int i=0;i<4;i++) for(int j=0;j<3;j++) if(z4kR1ddl3_m47r1x[i][j]==z4kR1ddl3_m47r1x[i][j+1]) return 0; for(int j=0;j<4;j++) for(int i=0;i<3;i++) if(z4kR1ddl3_m47r1x[i][j]==z4kR1ddl3_m47r1x[i+1][j]) return 0; return 1; } // 核心游戏调度函数:匹配游戏关键词,启动对应游戏 std::string gameModule(const std::string& userInput) { std::string lowerInput = toLowerCase(userInput); if (containsKeyword(lowerInput, "猜数字")) { playGuessNumber(); return "猜数字游戏已结束,欢迎下次再玩~"; } if (containsKeyword(lowerInput, "五子棋")) { playGomoku(); return "五子棋游戏已结束,欢迎下次再玩~"; } if (containsKeyword(lowerInput, "国际象棋") || containsKeyword(lowerInput, "象棋")) { playSimpleChess(); return "简易国际象棋游戏已结束,欢迎下次再玩~"; } if (containsKeyword(lowerInput, "游戏")) { return "我目前支持以下游戏哦:1. 猜数字(1-100);2. 五子棋(9*9棋盘);3. 简易国际象棋(8*8棋盘)。你可以直接输入游戏名称启动游戏~"; } // 无匹配游戏 return ""; } // ====================== 新增:额外实用功能(心灵鸡汤+节日提示) ====================== std::string extraUsefulFunctions(const std::string& userInput) { std::string lowerInput = toLowerCase(userInput); // 1. 心灵鸡汤/正能量语录 if (containsKeyword(lowerInput, "鸡汤") || containsKeyword(lowerInput, "正能量") || containsKeyword(lowerInput, "鼓励语录")) { std::vector<std::string> chickenSoup = { "你不需要很厉害才能开始,但你需要开始才能很厉害~", "生活最好的状态,是既有脚踏实地的努力,也有仰望星空的诗意~", "慢慢来,谁不是摸着石头过河,发光不是太阳的专利,你也可以~", "那些看似不起波澜的日复一日,会在某天让你看到坚持的意义~", "你只管善良,上天自有衡量;你只管努力,时间自有答案~" }; srand(static_cast<unsigned int>(time(nullptr))); int index = rand() % chickenSoup.size(); return "正能量语录:" + chickenSoup[index]; } // 2. 节日简易提示(常见传统节日) if (containsKeyword(lowerInput, "节日") || containsKeyword(lowerInput, "传统节日")) { return "常见传统节日及寓意:1. 春节:辞旧迎新,阖家团圆;2. 元宵节:赏花灯,吃汤圆,庆团圆;3. 端午节:纪念屈原,驱邪避灾;4. 中秋节:赏月吃月饼,阖家团圆;5. 重阳节:登高望远,敬老爱老~ 另外,每年的2月14日是情人节,12月25日是圣诞节哦~"; } // 3. 读书推荐(经典入门书籍) if (containsKeyword(lowerInput, "读书推荐") || containsKeyword(lowerInput, "好书推荐")) { return "经典好书推荐:1. 文学类:《平凡的世界》《百年孤独》;2. 成长类:《刻意练习》《终身成长》;3. 哲学类:《苏菲的世界》《中国哲学简史》;4. 科普类:《时间简史》《万物简史》;5. 职场类:《高效能人士的七个习惯》《金字塔原理》~"; } // 无匹配额外功能 return ""; } // --- 新增代码 --- // 工具函数:处理不礼貌用语 std::string handleAbusiveLanguage(const std::string& userInput) { std::string lowerInput = toLowerCase(userInput); // 定义一个包含不礼貌用语的列表(这里仅为示例,你可以根据需要扩展) std::vector<std::string> abusiveWords = { "笨蛋", "傻瓜","傻子" ,"垃圾", "去死", "废物", "SB", "shit", "fuck", "idiot", "stupid" , "傻逼" , "大聪明" , "你妈" , "你妈的" , "NPC" , "他妈" , "他妈的" , "有病" , "娘的" , "sb" , "菜" , "菜就多练" , "输不起就别玩" , "神经病" , "沙子" , "曹莫凡是沙子" , "曹莫凡是傻子" , "脑残" , "What's fuking good!" }; // 检查输入是否包含任何不礼貌用语 for (const std::string& word : abusiveWords) { if (containsKeyword(lowerInput, word)) { // 定义一些友好的回应 std::vector<std::string> responses = { "我们应该友好交流哦,这样才能更好地互相帮助。", "语言是有温度的,让我们用更温暖的方式沟通吧!", "我理解你可能有些情绪,但请使用文明用语,谢谢。", "别这样嘛,有什么问题我们可以一起解决,开心一点~", "看来你今天心情不太好,需要我讲个笑话或者给你一些正能量吗?" }; // 随机选择一个回应 srand(static_cast<unsigned int>(time(nullptr))); int randomIndex = rand() % responses.size(); return responses[randomIndex]; } } // 如果没有检测到不礼貌用语,返回空字符串 return ""; } // --- 新增代码结束 --- // 核心类:增强版AI大模型(多用途规则匹配实现交互) class EnhancedAIModel { private: // 模型名称 std::string modelName; public: // 构造函数:初始化模型名称 EnhancedAIModel(const std::string& name) : modelName(name) {} // 核心方法:处理用户输入,生成响应 std::string generateResponse(const std::string& userInput) { // 空输入处理 if (userInput.empty()) { return "抱歉,我没有接收到你的输入,请重新输入。"; } // --- 新增代码 --- // 优先检查是否为不礼貌用语 std::string abuseResponse = handleAbusiveLanguage(userInput); if (!abuseResponse.empty()) { return abuseResponse; } // --- 新增代码结束 --- std::string lowerInput = toLowerCase(userInput); std::string toolResponse = ""; // 1. 问候类场景匹配 if (containsKeyword(userInput, "你好") || containsKeyword(userInput, "hello") || containsKeyword(userInput, "嗨") || containsKeyword(userInput, "哈喽") || containsKeyword(userInput, "早上好") || containsKeyword(userInput, "下午好") || containsKeyword(userInput, "晚上好")) { std::time_t now = std::time(nullptr); std::tm* localTime = std::localtime(&now); int hour = localTime->tm_hour; std::string greetings = ""; if (hour >= 6 && hour < 12) { greetings = "早上好呀!"; } else if (hour >= 12 && hour < 18) { greetings = "下午好呀!"; } else if (hour >= 18 && hour < 22) { greetings = "晚上好呀!"; } else { greetings = "你好呀!"; } return greetings + "我是" + modelName + ",新增更多日常工具和健康常识,还有额外实用功能,有什么可以帮到你的吗?"; } // 2. 身份查询场景匹配 if (containsKeyword(userInput, "你是谁") || containsKeyword(userInput, "你的名字") || containsKeyword(userInput, "你是什么") || containsKeyword(userInput, "来自哪里")) { return "我是用C++编写的增强版AI模型" + modelName + ",具备问候交互、数学计算、日期查询、生活建议(13个核心常识)、日常工具(9个核心功能)、趣味互动、游戏娱乐、额外实用功能等多种能力,专门为你提供全面的基础交互服务~"; } // 3. 天气查询场景匹配(简化响应,无真实接口调用) if (containsKeyword(userInput, "天气") || containsKeyword(userInput, "温度") || containsKeyword(userInput, "下雨") || containsKeyword(userInput, "晴天") || containsKeyword(userInput, "刮风") || containsKeyword(userInput, "雾霾")) { return "当前无法获取实时天气数据哦~ 建议你:1. 查看手机自带天气APP;2. 访问气象部门官方网站;3. 关注当地气象公众号。出行前记得根据天气准备衣物和雨具哦!"; } // 4. 编程相关场景匹配 if (containsKeyword(userInput, "编程") || containsKeyword(userInput, "代码") || containsKeyword(userInput, "c++") || containsKeyword(userInput, "java") || containsKeyword(userInput, "python") || containsKeyword(userInput, "开发") || containsKeyword(userInput, "调试") || containsKeyword(userInput, "语法")) { if (containsKeyword(userInput, "c++")) { return "C++是一门强大的静态编译型语言,非常适合开发高性能程序、游戏引擎、系统级软件和嵌入式设备。学习C++建议:1. 先掌握基础语法(变量、循环、函数);2. 深入理解面向对象思想(类、继承、多态);3. 学习STL标准模板库;4. 多做实战项目,积累调试经验~"; } else if (containsKeyword(userInput, "python")) { return "Python是一门简洁易读的解释型语言,生态丰富,广泛应用于数据分析、人工智能、Web开发、自动化测试等领域。学习Python建议:1. 掌握基础语法和数据结构;2. 学习常用第三方库(NumPy、Pandas、TensorFlow);3. 通过小项目(爬虫、计算器、小游戏)巩固知识~"; } else if (containsKeyword(userInput, "java")) { return "Java是一门跨平台的面向对象语言,具有“一次编写,到处运行”的特点,广泛应用于企业级开发、Android开发、大数据处理等领域。学习Java建议:1. 掌握基础语法和面向对象特性;2. 学习集合框架和IO流;3. 了解Spring、MyBatis等主流框架;4. 参与项目开发,积累实战经验~"; } else { return "编程学习的核心是“多学、多练、多总结”哦!无论学习哪门语言,都建议:1. 打好基础,不要急于求成;2. 多看官方文档和优质教程;3. 遇到问题先独立思考,再寻求帮助;4. 坚持做实战项目,将理论转化为能力~"; } } // 5. 日期时间查询场景匹配 if (containsKeyword(userInput, "时间") || containsKeyword(userInput, "日期") || containsKeyword(userInput, "今天") || containsKeyword(userInput, "星期") || containsKeyword(userInput, "季节") || containsKeyword(userInput, "月份")) { if (containsKeyword(userInput, "季节")) { return "当前的季节是:" + getCurrentSeason(); } else { return "当前系统时间和日期是:" + getCurrentDateTime(); } } // 6. 数学计算场景匹配 if (containsKeyword(userInput, "加") || containsKeyword(userInput, "减") || containsKeyword(userInput, "乘") || containsKeyword(userInput, "除") || containsKeyword(userInput, "平方") || containsKeyword(userInput, "开方") || containsKeyword(userInput, "计算") || containsKeyword(userInput, "等于")) { return calculateMath(userInput); } // 7. 生活常识与健康养生场景匹配(升级后13个常识) toolResponse = lifeCommonSense(userInput); if (!toolResponse.empty()) { return toolResponse; } // 8. 趣味互动场景匹配(笑话、谜语、鼓励等) toolResponse = funInteraction(userInput); if (!toolResponse.empty()) { return toolResponse; } // 9. 日常工具与安全建议场景匹配(升级后9个工具) toolResponse = dailyTools(userInput); if (!toolResponse.empty()) { return toolResponse; } // 10. 游戏娱乐场景匹配(保留完整) toolResponse = gameModule(userInput); if (!toolResponse.empty()) { return toolResponse; } // 11. 额外实用功能场景匹配(新增:鸡汤+节日+读书推荐) toolResponse = extraUsefulFunctions(userInput); if (!toolResponse.empty()) { return toolResponse; } // 12. 学习相关场景匹配 if (containsKeyword(userInput, "学习") || containsKeyword(userInput, "考试") || containsKeyword(userInput, "复习") || containsKeyword(userInput, "效率") || containsKeyword(userInput, "记忆") || containsKeyword(userInput, "备考")) { return "学习效率提升小贴士:1. 制定合理的学习计划,拆分目标到每天;2. 采用“番茄工作法”(25分钟学习+5分钟休息);3. 做好笔记,定期复盘总结;4. 理解记忆为主,避免死记硬背;5. 保持良好的学习环境,远离干扰源;6. 劳逸结合,适当放松,避免疲劳战~"; } // 13. 告别场景匹配 if (containsKeyword(userInput, "再见") || containsKeyword(userInput, "拜拜") || containsKeyword(userInput, "bye") || containsKeyword(userInput, "下次见")) { return "再见啦!感谢你的使用,希望下次能继续为你提供帮助~ 如果后续有其他需求,随时可以来找我哦!"; } //15.啦啦啦 if(containsKeyword(userInput,"你可以干什么")||containsKeyword(userInput,"干什么")||containsKeyword(userInput,"我可以问什么")||containsKeyword(userInput,"你会什么")){ return "\n你可以尝试询问以下内容:\n" "1. 问候类(你好、早上好)\n" "2. 日期时间(现在几点、今天星期几、明天日期)\n" "3. 数学计算(100加200、5的平方、倒计时几分钟(仅支持一小时以内))\n" "4. 生活健康(护眼技巧、养胃建议、提高免疫力等13个常识)\n" "5. 编程相关(C++学习、Python应用)\n" "6. 趣味互动(讲个笑话、猜谜语)\n" "7. 日常工具(密码安全、人民币转换、生活妙招等9个功能)\n" "8. 游戏娱乐(猜数字、五子棋、国际象棋)\n" "9.满级游戏(吃豆人、狼人杀、黑暗诅咒、贪吃蛇)\n" "10.有漏洞的游戏(打砖块、子弹打飞机、才译翔游戏中心)【这类游戏玩完会直接退出整个AI】\n" "11. 额外功能(正能量鸡汤、节日提示、读书推荐)\n" "最后,如果你想玩火柴人游戏、那请你结束整个AI,会有一个选项哦!\n"; } // 14. 未知场景默认响应(更新所有功能提示) return "抱歉,我目前的能力有限,暂时无法理解你的需求。你可以尝试询问以下内容哦:\n" "1. 问候类(你好、早上好)\n" "2. 日期时间(现在几点、今天星期几、明天日期)\n" "3. 数学计算(100加200、5的平方、倒计时几分钟(仅支持一小时以内))\n" "4. 生活健康(护眼技巧、养胃建议、提高免疫力等13个常识)\n" "5. 编程相关(C++学习、Python应用)\n" "6. 趣味互动(讲个笑话、猜谜语)\n" "7. 日常工具(密码安全、人民币转换、生活妙招等9个功能)\n" "8. 游戏娱乐(猜数字、五子棋、国际象棋)\n" "9. 满级游戏 (黑暗诅咒、吃豆人、贪吃蛇、狼人杀)\n" "10. 有漏洞的游戏(子弹打飞机、打砖块、才译翔游戏中心)【这类游戏玩完会直接退出整个AI】\n" "11. 额外功能(正能量鸡汤、节日提示、读书推荐)\n" "最后,如果你想玩火柴人游戏、那请你结束整个AI,会有一个选项哦!\n"; } // 修复后的:运行模型(启动交互循环) void run() { std::cout << "========== " << modelName << " 启动成功 ==========" << std::endl; std::cout << "【增强版功能说明】支持问候、日期、计算、生活健康(13个常识)、日常工具(9个功能)、趣味互动、游戏娱乐、额外实用功能(鸡汤/节日/读书)等多种用途" << std::endl; std::cout << "请输入你的问题(输入\"退出\"可结束程序):" << std::endl; std::string userInput; while (true) { std::cout << "\n你:"; // 读取用户整行输入(包含空格) std::getline(std::cin, userInput); // 退出程序判断(修复:定义lowerInput并调用toLowerCase) std::string lowerInput = toLowerCase(userInput); if(lowerInput=="才译翔C++中心"||lowerInput=="才译翔游戏"||lowerInput=="才译翔游戏中心"){ SetConsoleOutputCP(936); SetConsoleCP(936); srand(time(nullptr)); initAdminUser(); selectLanguage(); showAnnouncement(); showLoginRegisterMenu(); } if(lowerInput=="子弹打飞机"){ system("cls"); std::cout<<"作者:曹SB(caomofan · 曹莫凡)" << std::endl; srand((unsigned int)time(nullptr)); // 修正随机种子初始化方式(更规范) HideCursor(); // 隐藏光标 // 注意:这里的 Game 是飞机大战的 Game 类,需确保类定义在调用之前 Game game; // 初始化飞机大战游戏对象 int a = drawMenu(); if(a == 2) game.rank = 20; // 冷酷难度,调整敌机移动速度 system("cls"); drawPlaying(); // 绘制游戏界面 game.Playing(); // 启动游戏主循环 } if(lowerInput=="要玩狼人杀"||lowerInput=="狼人杀"){ int wheel=0; before_game(); while(!is_end()){ //黑夜准备 something_before_everyday(); Sleep(1500); //黑夜部分 Night(); //进入黑夜! change_daytime(); //换天 //天亮了 panduansiwang();//判断谁死了 Sleep(2000); system("cls"); print(); if(is_end()) break; //选警长 if(!wheel&&player_number==12) { choose_police(); system("cls"); print(); } //投票环节 int idx_max=toupiao();//票数最多的人 int lierendai=-1; if(idx_max==idx_police){ police_die(); } if(players[idx_max].type==lieren){//启动猎人程序 Lieren(); if(is_end()) break; } system("cls"); print(); wheel++; } the_end(); system("pause"); } if(lowerInput=="贪吃蛇"){ if (lowerInput == "贪吃蛇") { system("cls"); initGame(); // 必须加!原来漏了初始化 while (!isGameOver) { controlDirection(); if (isPaused) { pauseLoop(); continue; } moveSnake(); drawGame(); Sleep(gameSpeed); } gameOverUI(); isGameOver = false; // 下次玩重置 } } if(lowerInput=="黑暗诅咒"||lowerInput=="黑暗诅咒第二季"||lowerInput=="要玩黑暗诅咒第二季"){ hazz(); } if(lowerInput=="要玩2048小游戏"||lowerInput=="要玩2048"||lowerInput=="2048游戏"||lowerInput=="要玩2048游戏"){ srand(time(0)); init_z3r0_f13ld(); sp4wn_r4nd_crypt(); sp4wn_r4nd_crypt(); char k3y_pr355; while(1){ sh0w_crypt_m47r1x(); if(ch3ck_v1ct0ry()){ cout<<" 恭喜合成2048,通关!\n"; break; } if(ch3ck_g4m30v3r()){ cout<<" 无法移动,游戏结束!\n"; break; } cin>>k3y_pr355; if(k3y_pr355=='a') m0v3_l3ft_sh4d0w(); if(k3y_pr355=='d') m0v3_r1ght_sh4d0w(); if(k3y_pr355=='w') m0v3_up_sh4d0w(); if(k3y_pr355=='s') m0v3_d0wn_sh4d0w(); sp4wn_r4nd_crypt(); } } if(lowerInput=="要玩吃豆人"||lowerInput=="吃豆人"){ begin(); int jixu=1; reset(); string bb[4]={"●","①","②","③"}; color(7); gotoxy(12,12); printf("倒计时"); color(12); for (int i=3; i>=0; i--){if (i==0) color(11);gotoxy(13,13); cout<<bb[i]; Sleep(1000);} gotoxy(12,12); printf(" "); gotoxy(13,13); printf(" "); color(7); while (!f){ Sleep(1); gotoxy(10,30); printf("得分:%d ",fenshu); gotoxy(8,30); printf("怪物速度:%d ",300-t2); gotoxy(9,30); printf("你的速度:%d ",300-t1); gotoxy(15,30); printf("被吃次数:%d ",beichi); if (kbhit()) shuru(); if (stopped) continue; T1=(T1+1)%t1; T2=(T2+1)%t2; if (T1%t1==0 && now+fx[fangx]>0 && now+fx[fangx]<n) move1(); if (T2%t2==0){ if (guaitimer<=8){ if (guaitimer==0) g1=1; if (guaitimer==8) g2=1; guaitimer++; } if (!g3 && fenshu>=30) g3=1; move2(); } if (fenshu==guozi)f=2; } if (f=2) { Sleep(3000); system("cls"); printf("恭喜你吃完了!\n你一共被怪物吃掉了 %d 次",beichi); Sleep(3000); char ying; scanf("%c",&ying); } } if(lowerInput=="要玩打砖块"||lowerInput=="打砖块"){ srand(time(NULL)); initBricks(); while (true) { draw(); input(); logic(); // Sleep(500); } } if(lowerInput=="倒计时1分钟"||lowerInput=="倒计时2分钟"||lowerInput=="倒计时3分钟"||lowerInput=="倒计时4分钟"||lowerInput=="倒计时5分钟"||lowerInput=="倒计时6分钟"||lowerInput=="倒计时7分钟"||lowerInput=="倒计时8分钟"||lowerInput=="倒计时9分钟"||lowerInput=="倒计时10分钟"||lowerInput=="倒计时11分钟"||lowerInput=="倒计时12分钟"||lowerInput=="倒计时13分钟"||lowerInput=="倒计时14分钟"||lowerInput=="倒计时15分钟"||lowerInput=="倒计时16分钟"||lowerInput=="倒计时17分钟"||lowerInput=="倒计时18分钟"||lowerInput=="倒计时19分钟"||lowerInput=="倒计时20分钟"||lowerInput=="倒计时21分钟"||lowerInput=="倒计时22分钟"||lowerInput=="倒计时23分钟"||lowerInput=="倒计时24分钟"||lowerInput=="倒计时25分钟"||lowerInput=="倒计时26分钟"||lowerInput=="倒计时27分钟"||lowerInput=="倒计时28分钟"||lowerInput=="倒计时29分钟"||lowerInput=="倒计时30分钟"||lowerInput=="倒计时31分钟"||lowerInput=="倒计时32分钟"||lowerInput=="倒计时33分钟"||lowerInput=="倒计时34分钟"||lowerInput=="倒计时35分钟"||lowerInput=="倒计时36分钟"||lowerInput=="倒计时37分钟"||lowerInput=="倒计时38分钟"||lowerInput=="倒计时39分钟"||lowerInput=="倒计时40分钟"||lowerInput=="倒计时41分钟"||lowerInput=="倒计时42分钟"||lowerInput=="倒计时43分钟"||lowerInput=="倒计时44分钟"||lowerInput=="倒计时45分钟"||lowerInput=="倒计时46分钟"||lowerInput=="倒计时47分钟"||lowerInput=="倒计时48分钟"||lowerInput=="倒计时49分钟"||lowerInput=="倒计时50分钟"||lowerInput=="倒计时51分钟"||lowerInput=="倒计时52分钟"||lowerInput=="倒计时53分钟"||lowerInput=="倒计时54分钟"||lowerInput=="倒计时55分钟"||lowerInput=="倒计时56分钟"||lowerInput=="倒计时57分钟"||lowerInput=="倒计时58分钟"||lowerInput=="倒计时59分钟"||lowerInput=="倒计时60分钟"){ int lalala; sout("请输入分钟数:\n"); cin>>lalala; int wodeshijie=lalala*60; for(int i=1;i<=wodeshijie;i++){ system("cls"); cout<<"剩余:"; cout<<wodeshijie-i; cout<<"秒\n"; Sleep(875); } sout("时间到!"); system("cls"); } if (lowerInput == "退出" || lowerInput == "exit") { std::cout << modelName << ":再见啦,欢迎下次再来!有需要随时可以找我哦~" << std::endl; break; } // 生成并输出响应 std::string response = generateResponse(userInput); std::cout << modelName << ":" << response << std::endl; } } }; // 主函数:程序入口 int main() { std::string str; sout("工工工工工工工工工工工"); sout("工 _ ______ 工"); sout("工 / \\ |_ _| 工"); sout("工 / _ \\ || 工"); sout("工 / /_\\ \\ || 工"); sout("工/ / \\ \\ |- -| 工"); sout("工工工工工工工工工工工"); sout("欢迎来到AI智能对话!!!"); std::cout<<"|------使用说明------|\n| 本AI十分智能 |\n| 原创:Caomofan |\n| 请加标点符号 |\n|--------------------|\n"; Sleep(500); sout("请输入用户名:"); std::string s; std::cin>>s; std::cout<<"你好"; std::cout<<s<<"!\n"; sout("请输入密码(本机密码默认666666):"); int mm; std::cin>>mm; if(mm==123456){ sout("你是特工!"); sout("我是你的特工助理!"); } sout("正在开机中...."); printf("正在检查网络...\n0"); Sleep(150); system("cls"); printf("正在连接主页服务器...\n▊15"); Sleep(210); system("cls"); printf("加载资源中...\n█▎ 25"); Sleep(180); system("cls"); printf("加载资源中...\n██▊ 55"); Sleep(120); system("cls"); printf("正在加载系统...\n███▌ 70"); Sleep(90); system("cls"); printf("正在检查软件中...\n███▊ 75"); Sleep(450); system("cls"); printf("正在准备软件...\n████▌ 90"); Sleep(120); system("cls"); printf("正在准备设置...\n█████ 100"); Sleep(300); system("cls"); printf("正在开启主机...\n█████ 100\n"); system("cls"); // 创建并运行增强版AI模型 EnhancedAIModel myAIModel("C++增强版全功能AI助手(含工具/健康/额外功能)"); myAIModel.run(); sout("你想试试火柴人游戏吗?很好玩的!有很多技能!很刺激!\n1.玩 2.不玩\n请输入:"); int laalla; cin>>laalla; if(laalla==1){ system("mode con cols=60 lines=37");CONSOLE_CURSOR_INFO cursor_info={1,0};SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);srand((unsigned)time(NULL)); Win=0;Ren=1;Lv=1;Blo=Blomax=100;Expmax=300;Hui=15;X=18,Y=6; ReStart:system("cls");memset(B,0,sizeof(B));memset(I,-1,sizeof(I));T=0;bl=0;br=-1;Upt=0; Start:Blo=Blomax * 100;Ding=6.25; memset(Bgo1,0,sizeof(Bgo1));memset(Bgo2,0,sizeof(Bgo2));memset(Bgo3,0,sizeof(Bgo3)); if(Win%2==0) T=0;if(Win%2==0&&D==0){if(Win>0)Ball(5);Boss=0;lL:L=rand()%4+1;for(int i=0;i<=Win/2-1;i++)if(L==Ll[i]) goto lL;Ll[Win/2]=L;}if(Win%2==1&&D==0){if(Win==7)Boss=6,T=0,Blomax+=100;else{bl:Boss=rand()%3+1;for(int i=0;i<=3;i++)if(Boss==Bl[i]) goto bl;}Bl[Win/2]=Boss;Bwhat1=Bwhat2=Bwhat3=0,Bx1=10,By1=20,Bx2=15,By2=20,Bx3=21,By3=20;system("color 4C");Sleep(20);system("color 0F");Map(0,1);Sleep(1000);}if(Win%2==1){Bblomax=500+(Win/2)*500;Bblo=Bblomax;if(Boss==2) Ding=12.25;} while(1){ T++; if(Wind==0){if(GetAsyncKeyState(VK_LEFT)&0x8000) Vy=-(10-abs(Ding-Y)*1.5)/20.0;if(GetAsyncKeyState(VK_RIGHT)&0x8000) Vy=(10-abs(Ding-Y)*1.5)/20.0;}if(GetAsyncKeyState(VK_UP)&0x8000&&u1==0) {u1++;if(Down==1){Down=0;Up=0;if(Ren==2)Map(-1,0),Vx=0,X=18,Li=5;else Vx=7,Vy=0.3;}else if(Up==0&&Wind==0) {Down=0;Up=1;if(Ren==2)Map(-1,0),Vx=1,X=10,Map(0,3),Li=5;else Vx=2,Vy=0.1;}else if(Up==1&&Wind==0) {Down=0;Up=2;if(Ren==2)Map(-1,0),Vx=1,X-=6,Map(0,3),Li=5;else Vx=1.5,Vy=0.1;}else if(Ren==3&&Up==2&&Wind==0) {Down=0;Up=3;Vx=1;Vy=0.5;Upt=30;}else if(Ren==4&&Up==2&&Wind==0) {Down=0;Up=3;Vx=1.8;Vy=0.1;}}if(GetAsyncKeyState(VK_DOWN)&0x8000&&u2==0) {u2++;if(Down==1&&Ren==5){Down=2;Up=0;Vx=-1.7;}else {Down=1;Up=0;if(Ren==2)Map(-1,0),Vx=0,X=22,Map(0,3),Li=5;else {if(Upt!=0) Map(-1,0),Upt=0;Vx=-7;}}}if((GetAsyncKeyState(VK_UP)&0x8000) ?0:1) u1=0;if((GetAsyncKeyState(VK_DOWN)&0x8000) ?0:1) u2=0;if(kbhit()){char g=_getch();if(g==' ') Sleep(100),Setpos(4,1),Sy++,system("pause");}if(Sy==1) Setpos(4,1),printf(" "),Sy--; if(Drug==0) Blo=fmin((float)Blomax,Blo+Hui/100.0);else if(T%10==0)Blo--;if(T%20==0) {if(Kill!=0) Kill=0;if(Lvl!=0) Lvl=0;}if(Killb>0) Killb--;if(Li>0) Li--;if(Ice>0) Ice--;if(Drug>0) Drug--;if(Magne>0) Magne--; if(Fire>0) Ball(1),Fire--;if(Water>0) Ball(2),Water--;if(Wind>0) Ball(3),Wind--;if(Thun>0) Ball(4),Thun--; if(Boss==0) NorGuai(L,T%1500);RandGood();if(T%20==1)Exp++; if(T%50==1){Exp++;system("cls");Setpos(20,0);Color(0);for(int i=1;i<=60;i++) printf("=");if(Win==0&&T<300){Setpos(4,6);cout<<"↑/↓ 跳跃/下翻,←→ 些微移动(松手即返回)"; Setpos(8,6);cout<<"球可以开启特殊效果,经验积满(300)可提升级别。";Setpos(8,6);cout<<"打败 7 波即胜利,打败 BOSS 有新天赋。";Setpos(10,15);cout<<"空格可以暂停。";}} Map(-1,0); if(Boss==1) Boss1();if(Boss==2) Boss2();if(Boss==3) Boss3();if(Boss==6) Boss1(),Boss2(),Boss3(); Move();Map(0,(bool)Kill);Color(0); Setpos(1,1);Blo=fmin(Blo,(float)Blomax);if(Boss==0)cout<<"血量: "<<(int)Blo<<" ";Color(0);Setpos(1,9),cout<<"死亡次数: "<<D<<" ";Setpos(2,1);Exp=min(Exp,Expmax);if(Exp>=Expmax)Exp=0,Lv++,Lvl++,Hui++,Blomax+=5;if(Lvl>0)Color(5);cout<<"级别: "<<Lv;Color(0);Setpos(2,9);cout<<"经验: "<<Exp<<" ";if(Boss>0) Setpos(3,1),cout<<"血量 : ",Ball(7);if(Boss>0&&Boss!=6) Setpos(4,1),cout<<"怪物血量: ",Ball(6);if(Boss==6) Setpos(1,9),printf("时间: %0.1f s ",T/15.0); if(Win==0) Sleep(55);if(Win==1) Sleep(50);if(Win==2) Sleep(35);if(Win==3) Sleep(40);if(Win==4) Sleep(25);if(Win==5) Sleep(30);if(Win==6) Sleep(20);if(Win>=7) Sleep(17); if(Boss==3&&Bblo<=0){for(int i=1;i<=4;i++){br++;B[br].what=98;B[br].x=Bx3-1,B[br].y=By3-1+i;B[br].vy=4;B[br].life=1;br++;B[br].what=98;B[br].x=Bx3,B[br].y=By3-1+i;B[br].vy=4;B[br].life=1;br++;B[br].what=98;B[br].x=Bx3-2,B[br].y=By3-1+i;B[br].vy=4;B[br].life=1;}} if((Win%2==0&&T>=1400)||(Win%2==1&&Bblo<=0)||(Win==7&&T>=450)||Blo<=0) {Map(-1,0);break;} } if(Blo<=0){ Sleep(1000); D++; system("color BF"); Setpos(15,11); Color(4); cout<<"GAME OVER..."; Sleep(2000); goto ReStart; } else if(Win==6){ system("color AF"); Setpos(15,11); Color(4); cout<<"坚持30秒 !"; Sleep(2000); Setpos(30,0); Win++; } else if(Win==7){ Sleep(1000); system("color BE"); Setpos(15,11); Color(5); cout<<"YOU WIN !"; Sleep(2000); Setpos(30,0); system("cls"); slowsay("\n\n\n\n\n剩余血量:");cout<<Blo<<endl; slowsay("\n\n\n\n\n等级:");cout<<Lv<<endl; slowsay("\n\n\n\n\n死亡次数:");cout<<D<<endl; return 0; }else Sleep(1000),Win++,D=0; goto Start; }else{ sout("那好吧!下次见!"); } return 0; }
Note.ms
/manjiAI