游戏
2026-07-09 22:18:00
发布于:浙江
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <cstdlib>
#include <ctime>
using namespace std;
void setColor(int c) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), c);
}
bool isCN = true;
void switchLang() {
system("cls");
setColor(14);
cout << "=== 语言切换 / Switch Language ===" << endl;
setColor(7);
cout << "1. 中文模式" << endl;
cout << "2. English mode" << endl;
cout << "选择: ";
int c; cin >> c;
isCN = (c == 1);
system("cls");
}
int main() {
srand(time(0));
system("mode con cols=80 lines=30");
system("cls");
// ===== 诈玩家 =====
setColor(7);
cout << endl << "--------------------------------" << endl;
cout << "Process exited after 0.8536 seconds with return value 0" << endl;
cout << "请按任意键继续. . ." << endl;
setColor(7);
getch();
system("cls");
setColor(10);
cout << endl << "骗到你啦!哈哈哈!" << endl;
setColor(14);
cout << "游戏没坏,逗你玩的!" << endl << endl;
setColor(7);
cout << "1. 中文模式" << endl;
cout << "2. English mode" << endl;
cout << "选择: ";
int lc; cin >> lc;
isCN = (lc == 1);
system("cls");
// ===== 玩家属性 =====
int gold = 1000, atk = 10, def = 5, hp = 100, maxHp = 100;
int potion = 3, level = 1, exp = 0;
int choice;
while (true) {
system("cls");
setColor(14);
cout << "========================================" << endl;
setColor(7);
if (isCN) {
cout << "等级:" << level << " 经验:" << exp << "/" << level*50;
cout << " 攻击:" << atk << " 防御:" << def;
cout << " HP:" << hp << "/" << maxHp << " 药水:" << potion << " 金币:" << gold << endl;
cout << "========================================" << endl;
cout << "1.商店 2.打怪 3.用药水 4.状态 5.切换语言 0.退出" << endl;
cout << "选择: ";
} else {
cout << "Lv:" << level << " Exp:" << exp << "/" << level*50;
cout << " ATK:" << atk << " DEF:" << def;
cout << " HP:" << hp << "/" << maxHp << " Potions:" << potion << " Gold:" << gold << endl;
cout << "========================================" << endl;
cout << "1.Shop 2.Fight 3.Potion 4.Stats 5.Lang 0.Exit" << endl;
cout << "Choice: ";
}
cin >> choice;
if (choice == 0) {
if (isCN) cout << "再见!" << endl;
else cout << "Goodbye!" << endl;
break;
}
if (choice == 5) { switchLang(); continue; }
// ===== 商店 =====
if (choice == 1) {
while (true) {
system("cls");
setColor(14);
cout << "========================================" << endl;
setColor(7);
if (isCN) {
cout << " 金币:" << gold << " 攻击:" << atk << " 防御:" << def << " HP:" << hp << "/" << maxHp << endl;
setColor(14);
cout << "========================================" << endl;
cout << " 1. 武器" << endl;
cout << " 2. 防具" << endl;
cout << " 3. 药水" << endl;
cout << " 4. 饰品" << endl;
cout << " 0. 返回" << endl;
cout << "========================================" << endl;
setColor(7);
cout << "选择: ";
} else {
cout << " Gold:" << gold << " ATK:" << atk << " DEF:" << def << " HP:" << hp << "/" << maxHp << endl;
setColor(14);
cout << "========================================" << endl;
cout << " 1. Weapons" << endl;
cout << " 2. Armors" << endl;
cout << " 3. Potions" << endl;
cout << " 4. Accessories" << endl;
cout << " 0. Back" << endl;
cout << "========================================" << endl;
setColor(7);
cout << "Choice: ";
}
int shopType; cin >> shopType;
if (shopType == 0) break;
// ===== 武器 =====
if (shopType == 1) {
while (true) {
system("cls");
setColor(14);
cout << "========================================" << endl;
setColor(7);
if (isCN) {
cout << " 金币:" << gold << " 攻击:" << atk << endl;
setColor(14);
cout << "========================================" << endl;
setColor(10);
cout << " ★ 武器 ★" << endl;
setColor(7);
cout << " 1.木剑 +5攻击 10金" << endl;
cout << " 2.石剑 +8攻击 25金" << endl;
cout << " 3.铁剑 +12攻击 50金" << endl;
cout << " 4.钢剑 +16攻击 80金" << endl;
cout << " 5.大马士革剑 +20攻击 120金" << endl;
cout << " 6.武士刀 +22攻击 150金" << endl;
cout << " 7.斩铁剑 +25攻击 180金" << endl;
cout << " 8.暗影之刃 +28攻击 220金" << endl;
cout << " 9.火焰剑 +30攻击 260金" << endl;
cout << "10.冰霜剑 +30攻击 260金" << endl;
cout << "11.雷电剑 +32攻击 300金" << endl;
cout << "12.圣剑 +35攻击 350金" << endl;
cout << "13.魔剑 +38攻击 400金" << endl;
cout << "14.龙牙剑 +42攻击 500金" << endl;
cout << "15.王者之剑 +45攻击 600金" << endl;
cout << "16.御神刀·村正 +50攻击 800金" << endl;
cout << "17.天丛云 +55攻击 1000金" << endl;
cout << "18.布都御魂 +60攻击 1200金" << endl;
cout << "19.霜之哀伤 +65攻击 1500金" << endl;
cout << "20.剑圣之刃 +70攻击 2000金" << endl;
cout << "21.神剑·天照 +75攻击 2500金" << endl;
cout << "22.终焉之刃 +80攻击 3000金" << endl;
cout << "23.星尘之剑 +85攻击 4000金" << endl;
cout << "24.虚空之刃 +90攻击 5000金" << endl;
cout << "25.创世之剑 +100攻击 9999金" << endl;
setColor(14);
cout << "========================================" << endl;
cout << " 0.返回" << endl;
cout << "========================================" << endl;
setColor(7);
cout << "选择: ";
} else {
cout << " Gold:" << gold << " ATK:" << atk << endl;
setColor(14);
cout << "========================================" << endl;
setColor(10);
cout << " ★ Weapons ★" << endl;
setColor(7);
cout << " 1.Wooden Sword +5 ATK 10G" << endl;
cout << " 2.Stone Sword +8 ATK 25G" << endl;
cout << " 3.Iron Sword +12 ATK 50G" << endl;
cout << " 4.Steel Sword +16 ATK 80G" << endl;
cout << " 5.Damascus Blade +20 ATK 120G" << endl;
cout << " 6.Katana +22 ATK 150G" << endl;
cout << " 7.Iron Cleaver +25 ATK 180G" << endl;
cout << " 8.Shadow Blade +28 ATK 220G" << endl;
cout << " 9.Flame Sword +30 ATK 260G" << endl;
cout << "10.Frost Sword +30 ATK 260G" << endl;
cout << "11.Thunder Sword +32 ATK 300G" << endl;
cout << "12.Holy Sword +35 ATK 350G" << endl;
cout << "13.Demon Blade +38 ATK 400G" << endl;
cout << "14.Dragon Tooth +42 ATK 500G" << endl;
cout << "15.King's Sword +45 ATK 600G" << endl;
cout << "16.Muramasa +50 ATK 800G" << endl;
cout << "17.Ame-no-Murakumo +55 ATK 1000G" << endl;
cout << "18.Futsunomitama +60 ATK 1200G" << endl;
cout << "19.Frostmourne +65 ATK 1500G" << endl;
cout << "20.Blade of Sword Saint +70 ATK 2000G" << endl;
cout << "21.Divine Blade Amaterasu +75 ATK 2500G" << endl;
cout << "22.Blade of Eternity +80 ATK 3000G" << endl;
cout << "23.Stardust Sword +85 ATK 4000G" << endl;
cout << "24.Void Blade +90 ATK 5000G" << endl;
cout << "25.Genesis Sword +100 ATK 9999G" << endl;
setColor(14);
cout << "========================================" << endl;
cout << " 0.Back" << endl;
cout << "========================================" << endl;
setColor(7);
cout << "Choice: ";
}
int sc; cin >> sc;
if (sc == 0) break;
if (sc < 1 || sc > 25) { if(isCN) cout<<"无效!" << endl; else cout<<"Invalid!" << endl; system("pause"); continue; }
int price=10+(sc-1)*15, val=5+(sc-1)*3;
if (sc > 16) { val=50+(sc-16)*5; price=800+(sc-16)*200; }
if (gold < price) { if(isCN) cout<<"金币不够!"<< endl; else cout<<"Not enough!" << endl; system("pause"); continue; }
gold -= price; atk += val;
if(isCN) cout<<"攻击+"<<val << " 剩余金币:"<<gold << endl;
else cout<<"ATK+"<<val << " Gold left:"<<gold << endl;
system("pause");
}
}
// ===== 防具 =====
if (shopType == 2) {
while (true) {
system("cls");
setColor(14);
cout << "========================================" << endl;
setColor(7);
if (isCN) {
cout << " 金币:" << gold << " 防御:" << def << endl;
setColor(14);
cout << "========================================" << endl;
setColor(11);
cout << " ★ 防具 ★" << endl;
setColor(7);
cout << " 1.布甲 +3防御 15金" << endl;
cout << " 2.皮甲 +6防御 30金" << endl;
cout << " 3.锁甲 +10防御 60金" << endl;
cout << " 4.板甲 +15防御 100金" << endl;
cout << " 5.黑铁甲 +20防御 150金" << endl;
cout << " 6.秘银甲 +25防御 220金" << endl;
cout << " 7.龙鳞甲 +30防御 300金" << endl;
cout << " 8.暗影甲 +35防御 400金" << endl;
cout << " 9.圣甲 +40防御 500金" << endl;
cout << "10.玄铁重甲 +45防御 600金" << endl;
cout << "11.神铠 +50防御 800金" << endl;
cout << "12.龙神甲 +60防御 1200金" << endl;
cout << "13.不灭之铠 +70防御 2000金" << endl;
cout << "14.苍穹之甲 +80防御 3000金" << endl;
cout << "15.虚空之铠 +100防御 5000金" << endl;
setColor(14);
cout << "========================================" << endl;
cout << " 0.返回" << endl;
cout << "========================================" << endl;
setColor(7);
cout << "选择: ";
} else {
cout << " Gold:" << gold << " DEF:" << def << endl;
setColor(14);
cout << "========================================" << endl;
setColor(11);
cout << " ★ Armors ★" << endl;
setColor(7);
cout << " 1.Cloth Armor +3 DEF 15G" << endl;
cout << " 2.Leather Armor +6 DEF 30G" << endl;
cout << " 3.Chain Mail +10 DEF 60G" << endl;
cout << " 4.Plate Armor +15 DEF 100G" << endl;
cout << " 5.Black Iron Armor +20 DEF 150G" << endl;
cout << " 6.Mithril Armor +25 DEF 220G" << endl;
cout << " 7.Dragon Scale Armor +30 DEF 300G" << endl;
cout << " 8.Shadow Armor +35 DEF 400G" << endl;
cout << " 9.Holy Armor +40 DEF 500G" << endl;
cout << "10.Darksteel Armor +45 DEF 600G" << endl;
cout << "11.Divine Armor +50 DEF 800G" << endl;
cout << "12.Dragon God Armor +60 DEF 1200G" << endl;
cout << "13.Immortal Armor +70 DEF 2000G" << endl;
cout << "14.Celestial Armor +80 DEF 3000G" << endl;
cout << "15.Void Armor +100 DEF 5000G" << endl;
setColor(14);
cout << "========================================" << endl;
cout << " 0.Back" << endl;
cout << "========================================" << endl;
setColor(7);
cout << "Choice: ";
}
int sc; cin >> sc;
if (sc == 0) break;
if (sc < 1 || sc > 15) { if(isCN) cout<<"无效!" << endl; else cout<<"Invalid!" << endl; system("pause"); continue; }
int price=15+(sc-1)*15, val=3+(sc-1)*3;
if (gold < price) { if(isCN) cout<<"金币不够!"<< endl; else cout<<"Not enough!" << endl; system("pause"); continue; }
gold -= price; def += val;
if(isCN) cout<<"防御+"<<val << " 剩余金币:"<<gold << endl;
else cout<<"DEF+"<<val << " Gold left:"<<gold << endl;
system("pause");
}
}
// ===== 药水 =====
if (shopType == 3) {
while (true) {
system("cls");
setColor(14);
cout << "========================================" << endl;
setColor(7);
if (isCN) {
cout << " 金币:" << gold << " HP:" << hp << "/" << maxHp << endl;
setColor(14);
cout << "========================================" << endl;
setColor(12);
cout << " ★ 药水 ★" << endl;
setColor(7);
cout << " 1.小生命药水 +20HP 15金" << endl;
cout << " 2.生命药水 +50HP 40金" << endl;
cout << " 3.大生命药水 +100HP 80金" << endl;
cout << " 4.超生命药水 +200HP 150金" << endl;
cout << " 5.满生命药水 满HP 300金" << endl;
setColor(14);
cout << "========================================" << endl;
cout << " 0.返回" << endl;
cout << "========================================" << endl;
setColor(7);
cout << "选择: ";
} else {
cout << " Gold:" << gold << " HP:" << hp << "/" << maxHp << endl;
setColor(14);
cout << "========================================" << endl;
setColor(12);
cout << " ★ Potions ★" << endl;
setColor(7);
cout << " 1.Minor Health Potion +20 HP 15G" << endl;
cout << " 2.Health Potion +50 HP 40G" << endl;
cout << " 3.Greater Health Potion +100 HP 80G" << endl;
cout << " 4.Super Health Potion +200 HP 150G" << endl;
cout << " 5.Full Health Potion Full HP 300G" << endl;
setColor(14);
cout << "========================================" << endl;
cout << " 0.Back" << endl;
cout << "========================================" << endl;
setColor(7);
cout << "Choice: ";
}
int sc; cin >> sc;
if (sc == 0) break;
if (sc < 1 || sc > 5) { if(isCN) cout<<"无效!" << endl; else cout<<"Invalid!" << endl; system("pause"); continue; }
int val=20+(sc-1)*30, price=15+(sc-1)*25;
if (sc == 5) { val=999; price=300; }
if (gold < price) { if(isCN) cout<<"金币不够!"<< endl; else cout<<"Not enough!" << endl; system("pause"); continue; }
gold -= price;
if (val == 999) { hp = maxHp; if(isCN) cout<<"HP已回满!" << endl; else cout<<"HP fully restored!" << endl; }
else { hp += val; if(hp > maxHp) maxHp = hp; if(isCN) cout<<"HP+"<<val << endl; else cout<<"HP+"<<val << endl; }
if(isCN) cout<<"剩余金币:"<<gold << endl; else cout<<"Gold left:"<<gold << endl;
system("pause");
}
}
// ===== 饰品 =====
if (shopType == 4) {
while (true) {
system("cls");
setColor(14);
cout << "========================================" << endl;
setColor(7);
if (isCN) {
cout << " 金币:" << gold << " 攻击:" << atk << " 防御:" << def << " HP:" << hp << "/" << maxHp << endl;
setColor(14);
cout << "========================================" << endl;
setColor(13);
cout << " ★ 饰品 ★" << endl;
setColor(7);
cout << " 1.贤者之石 全属性+20 500金" << endl;
cout << " 2.生命之冠 HP+100 1000金" << endl;
cout << " 3.力量手环 攻击+15 600金" << endl;
cout << " 4.守护戒指 防御+15 600金" << endl;
setColor(14);
cout << "========================================" << endl;
cout << " 0.返回" << endl;
cout << "========================================" << endl;
setColor(7);
cout << "选择: ";
} else {
cout << " Gold:" << gold << " ATK:" << atk << " DEF:" << def << " HP:" << hp << "/" << maxHp << endl;
setColor(14);
cout << "========================================" << endl;
setColor(13);
cout << " ★ Accessories ★" << endl;
setColor(7);
cout << " 1.Philosopher's Stone All+20 500G" << endl;
cout << " 2.Crown of Life HP+100 1000G" << endl;
cout << " 3.Bracelet of Strength ATK+15 600G" << endl;
cout << " 4.Ring of Protection DEF+15 600G" << endl;
setColor(14);
cout << "========================================" << endl;
cout << " 0.Back" << endl;
cout << "========================================" << endl;
setColor(7);
cout << "Choice: ";
}
int sc; cin >> sc;
if (sc == 0) break;
if (sc == 1) {
if (gold < 500) { if(isCN) cout<<"金币不够!"<< endl; else cout<<"Not enough!" << endl; system("pause"); continue; }
gold -= 500; atk += 10; def += 5; maxHp += 20; hp += 20;
if(isCN) cout<<"全属性提升!攻击+10 防御+5 HP+20" << " 剩余金币:"<<gold << endl;
else cout<<"All stats up! ATK+10 DEF+5 HP+20" << " Gold left:"<<gold << endl;
} else if (sc == 2) {
if (gold < 1000) { if(isCN) cout<<"金币不够!"<< endl; else cout<<"Not enough!" << endl; system("pause"); continue; }
gold -= 1000; hp += 100; if(hp > maxHp) maxHp = hp;
if(isCN) cout<<"HP+100" << " 剩余金币:"<<gold << endl;
else cout<<"HP+100" << " Gold left:"<<gold << endl;
} else if (sc == 3) {
if (gold < 600) { if(isCN) cout<<"金币不够!"<< endl; else cout<<"Not enough!" << endl; system("pause"); continue; }
gold -= 600; atk += 15;
if(isCN) cout<<"攻击+15" << " 剩余金币:"<<gold << endl;
else cout<<"ATK+15" << " Gold left:"<<gold << endl;
} else if (sc == 4) {
if (gold < 600) { if(isCN) cout<<"金币不够!"<< endl; else cout<<"Not enough!" << endl; system("pause"); continue; }
gold -= 600; def += 15;
if(isCN) cout<<"防御+15" << " 剩余金币:"<<gold << endl;
else cout<<"DEF+15" << " Gold left:"<<gold << endl;
} else {
if(isCN) cout<<"无效!" << endl; else cout<<"Invalid!" << endl;
}
system("pause");
}
}
}
}
// ===== 打怪 =====
if (choice == 2) {
int mHp = 20 + rand()%20;
int mAtk = 3 + rand()%5;
int mDef = 1 + rand()%2;
int gReward = 10 + rand()%15;
int eReward = 5 + rand()%8;
setColor(12);
if(isCN) cout << endl << "怪物 HP:"<<mHp<<" 攻击:"<<mAtk<<" 防御:"<<mDef << endl;
else cout << endl << "Monster HP:"<<mHp<<" ATK:"<<mAtk<<" DEF:"<<mDef << endl;
setColor(7);
while (mHp > 0 && hp > 0) {
if(isCN) cout<<"1.攻击 2.防御 3.逃跑: ";
else cout<<"1.Attack 2.Defend 3.Run: ";
int act; cin >> act;
if (act == 1) {
int dmg = atk + rand()%5 - mDef/2;
if (dmg < 1) dmg = 1;
mHp -= dmg;
if(isCN) cout<<"造成"<<dmg<<"伤害!" << endl;
else cout<<"Dealt "<<dmg<<" damage!" << endl;
if (mHp <= 0) {
setColor(14);
gold += gReward; exp += eReward;
if(isCN) cout<<"胜利!+"<<gReward<<"金币 +"<<eReward<<"经验" << endl;
else cout<<"Victory! +"<<gReward<<"G +"<<eReward<<"Exp" << endl;
if (exp >= level*50) {
level++; exp=0; maxHp+=10; hp=maxHp; atk+=3; def+=2;
setColor(13);
if(isCN) cout<<"升级!" << endl;
else cout<<"Level Up!" << endl;
setColor(7);
}
setColor(7);
break;
}
}
if (act == 3 && rand()%2==0) {
if(isCN) cout<<"逃跑成功!" << endl;
else cout<<"Escaped!" << endl;
break;
}
int mDmg = mAtk + rand()%3 - def/2;
if (mDmg < 1) mDmg = 1;
if (act == 2) mDmg /= 2;
hp -= mDmg;
if(isCN) cout<<"怪物造成"<<mDmg<<"伤害!HP:"<<hp<<"/"<<maxHp << endl;
else cout<<"Monster dealt "<<mDmg<<" damage! HP:"<<hp<<"/"<<maxHp << endl;
if (hp <= 0) {
setColor(12);
gold -= 50; if (gold < 0) gold = 0;
hp = maxHp/2;
if(isCN) cout<<"被击败!失去50金币" << endl;
else cout<<"Defeated! Lost 50 gold" << endl;
setColor(7);
}
}
system("pause");
}
// ===== 用药水 =====
if (choice == 3) {
if (potion > 0) {
hp += 30; if (hp > maxHp) hp = maxHp;
potion--;
if(isCN) cout<<"HP+30,当前HP:"<<hp<<"/"<<maxHp<<" 剩余药水:"<<potion << endl;
else cout<<"HP+30, Current HP:"<<hp<<"/"<<maxHp<<" Potions left:"<<potion << endl;
} else {
if(isCN) cout<<"没有药水!" << endl;
else cout<<"No potions!" << endl;
}
system("pause");
}
// ===== 状态 =====
if (choice == 4) {
if(isCN) {
cout << endl << "=== 状态 ===" << endl;
cout << "等级:" << level << " 经验:" << exp << "/" << level*50 << endl;
cout << "攻击:" << atk << " 防御:" << def << endl;
cout << "HP:" << hp << "/" << maxHp << " 药水:" << potion << " 金币:" << gold << endl;
} else {
cout << endl << "=== Stats ===" << endl;
cout << "Level:" << level << " Exp:" << exp << "/" << level*50 << endl;
cout << "ATK:" << atk << " DEF:" << def << endl;
cout << "HP:" << hp << "/" << maxHp << " Potions:" << potion << " Gold:" << gold << endl;
}
system("pause");
}
}
return 0;
}
全部评论 1
顶顶顶
3天前 来自 浙江
0













有帮助,赞一个