来来来
2026-07-23 20:41:44
发布于:广东
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
/* ===================== 数据定义 ===================== */
struct Fish {
char name[32];
int minPull, maxPull;
int weight;
int price;
int rare; // 0普通 1稀有 2传说
};
Fish fishTable[] = {
{"游魂鲤", 1, 3, 2, 5, 0},
{"怨灵鲫", 2, 4, 3, 6, 0},
{"赤瞳红鲤", 4, 7, 5, 12, 1},
{"雾隐魂鳗", 5, 9, 6, 15, 1},
{"深渊鱼王", 8, 14, 12, 40, 2},
};
int fishCount = 5;
struct Rod {
char name[32];
int pullMax;
int cost;
};
Rod rodTable[] = {
{"竹制魂竿", 6, 0},
{"碳魂路亚", 10, 80},
{"深渊电绞", 16, 200},
};
int rodCount = 3;
/* ===================== 全局状态 ===================== */
int money = 0;
int rodIdx = 0;
int caught[5] = {0};
int stamina = 100;
const int maxStamina = 100;
/* ===================== 工具函数 ===================== */
int randInt(int a, int b) {
return a + rand() % (b - a + 1);
}
void delay() {
for (int i = 0; i < 40000000; i++);
}
void drawBar(const char* label, int cur, int maxx, char ch) {
int len = 20;
int block = cur * len / maxx;
if (block < 0) block = 0;
if (block > len) block = len;
cout << "\r" << label << " [";
for (int i = 0; i < block; i++) cout << ch;
for (int i = block; i < len; i++) cout << "-";
cout << "] " << cur << "/" << maxx << " ";
cout.flush();
}
/* ===================== 钓鱼核心(含三种钓法) ===================== */
void fishing() {
cout << "\n抛竿中...";
delay();
cout << " 咬钩!\n";
int fishId = randInt(0, fishCount - 1);
Fish f = fishTable[fishId];
int pull = 0;
int lineHP = 100;
int fishHP = 30 + f.rare * 20;
stamina = maxStamina;
cout << "钓法选择:1硬拉 2控线 3放流(每回合输一个数字)\n";
while (true) {
int struggle = randInt(f.minPull, f.maxPull);
if (f.rare == 2 && randInt(1, 4) == 1)
struggle += randInt(2, 4);
drawBar("拉力", pull, rodTable[rodIdx].pullMax, '=');
drawBar("体力", stamina, maxStamina, '#');
drawBar("鱼耐力", fishHP, 100, '*');
cout << " 挣扎:" << struggle << " 线:" << lineHP << " ";
int style;
cin >> style;
int damage = 0;
int lineCost = 0;
int staCost = 0;
if (style == 1) { // 硬拉:高伤高险
if (stamina < 8) {
cout << "\n体力不足!\n";
continue;
}
pull += 3;
damage = (pull > struggle) ? (pull - struggle) * 2 : 0;
lineCost = struggle * 2;
staCost = 8;
} else if (style == 2) { // 控线:均衡
pull += 1;
damage = (pull > struggle) ? (pull - struggle) * 1 : 0;
lineCost = struggle;
staCost = 4;
} else if (style == 3) { // 放流:苟命
pull -= 2;
if (pull < 0) pull = 0;
damage = 1;
lineCost = struggle / 2;
staCost = -3;
} else {
cout << "\n放弃,鱼跑了\n";
return;
}
stamina -= staCost;
if (stamina > maxStamina) stamina = maxStamina;
if (stamina < 0) stamina = 0;
lineHP -= lineCost;
fishHP -= damage;
if (pull > rodTable[rodIdx].pullMax) {
cout << "\n拉力过载!断线!\n";
return;
}
if (lineHP <= 10)
cout << "\033[31m[线快断]\033[0m\r";
if (lineHP <= 0) {
cout << "\n鱼线断裂!\n";
return;
}
if (fishHP <= 0) {
cout << "\n上岸!钓到 " << f.name
<< " 卖价" << f.weight * f.price << "\n";
money += f.weight * f.price;
caught[fishId]++;
return;
}
}
}
/* ===================== 商店 / 图鉴 ===================== */
void shop() {
cout << "\n[渔具店]\n";
for (int i = 0; i < rodCount; i++)
cout << i << "." << rodTable[i].name
<< " 拉力上限" << rodTable[i].pullMax
<< " 售价" << rodTable[i].cost << "\n";
cout << "买哪根?: ";
int k; cin >> k;
if (k >= 0 && k < rodCount && money >= rodTable[k].cost) {
money -= rodTable[k].cost;
rodIdx = k;
cout << "换竿成功!\n";
} else {
cout << "买不起或无效\n";
}
}
void dex() {
cout << "\n[魂鱼图鉴]\n";
for (int i = 0; i < fishCount; i++)
cout << fishTable[i].name << " 钓到:" << caught[i] << "次\n";
}
/* ===================== 主菜单 ===================== */
int main() {
srand((unsigned)time(0));
memset(caught, 0, sizeof(caught));
cout << "=== 钓魂 C++98 完整版 ===\n";
while (true) {
cout << "\n金币:" << money
<< " 鱼竿:" << rodTable[rodIdx].name
<< "\n1.钓鱼 2.买竿 3.图鉴 4.退出 : ";
int cmd; cin >> cmd;
if (cmd == 1) fishing();
else if (cmd == 2) shop();
else if (cmd == 3) dex();
else if (cmd == 4) break;
else cout << "无效\n";
}
cout << "收工,最终金币:" << money << "\n";
return 0;
}
这里空空如也



















有帮助,赞一个