C++#include<bits/stdc++.h>
#include<windows.h>
#include<string>
using namespace std;
long double money = 1000, hp = 300, ap = 30;
int fuwen[25];
bool boss[5];
bool speedup = false;
int fuwen_gailv = 4;
int kuijia_level, wuqi_level;
long double zengfu_hp = 1, zengfu_ap = 1;
int random(int a, int b)
{
return (rand() % (b - a)) + a + 1;
}
long double powld(long double base, long double power)
{
return pow((long double)base, (long double)power);
}
string print(long double x)
{
string s = "";
if(x < 1e8) s.append(to_string(x));
else if(x < 1e12) s.append(to_string(x / 1e8) + "亿");
else if(x < 1e16) s.append(to_string(x / 1e12) + "兆");
else if(x < 1e20) s.append(to_string(x / 1e16) + "京");
else if(x < 1e24) s.append(to_string(x / 1e20) + "垓");
else if(x < 1e28) s.append(to_string(x / 1e24) + "稊");
else if(x < 1e32) s.append(to_string(x / 1e28) + "穰");
else if(x < 1e36) s.append(to_string(x / 1e32) + "沟");
else if(x < 1e40) s.append(to_string(x / 1e36) + "涧");
else if(x < 1e44) s.append(to_string(x / 1e40) + "正");
else if(x < 1e48) s.append(to_string(x / 1e44) + "载");
else if(x < 1e52) s.append(to_string(x / 1e48) + "极");
else if(x < 1e308) s.append(to_string(log(x) / log(1.78e308)) + "∞");
else s.append("数量太大 不显示了!!!");
return s;
}
void INS()
{
ifstream fin("data.txt", ios::in);
fin >> money >> hp >> ap;
for(int i = 0;i < 25;i++) fin >> fuwen[i];
fin >> kuijia_level >> wuqi_level;
for(int i = 0;i < 5;i++) fin >> boss[i];
fin >> fuwen_gailv;
fin >> zengfu_hp >> zengfu_ap;
}
void OUTS()
{
ofstream fout("data.txt", ios::out);
fout << money << endl << hp << endl << ap << endl;
for(int i = 0;i < 25;i++) fout << fuwen[i] << ' ';
cout << endl;
fout << kuijia_level << endl << wuqi_level << endl;
for(int i = 0;i < 5;i++) fout << boss[i] << ' ';
cout << endl;
fout << fuwen_gailv << endl;
fout << zengfu_hp << ' ' << zengfu_ap << endl;
}
bool pk(string ename, long double ehp, long double eap, int elevel)
{
cout << "你与 " << elevel << "级的" << ename << " 开始了战斗!" << endl;
Sleep(1000);
double nowhp = hp * zengfu_hp;
while(nowhp > 0 && ehp > 0)
{
Sleep(200 * (speedup ? 0.1 : 1));
cout << endl << endl;
cout << "你的生命值:" << print(nowhp) << endl << ename << "生命值:" << print(ehp) << endl;
Sleep(150 * (speedup ? 0 : 1));
if(!speedup) cout << "你对" << ename << "发起攻击 威力无比 造成了 " << print(ap * zengfu_ap) << " 点伤害!!!" << endl;
ehp -= ap * zengfu_ap;
Sleep(150 * (speedup ? 0 : 1));
if(!speedup) cout << ename << "对你发起攻击 威力无比 造成了 " << print(eap) << " 点伤害!!!" << endl;
nowhp -= eap;
}
if(nowhp > 0)
{
cout << "你 胜利了!!!!!!" << endl;
Sleep(1000);
return true;
}
else
{
cout << "你 失败了………………" << endl;
Sleep(1000);
return false;
}
}
void zhandoujiemian(string name, int minl, int maxl, int baolv, string ename, int baomoney, int id)
{
while(1)
{
OUTS();
cout << endl << "副本 " << name << endl;
cout << "1 战斗" << endl;
cout << "2 符文室" << endl;
cout << "3 离开" << endl;
int x;
cin >> x;
if(x == 1)
{
int elevel = random(minl, maxl);
bool x = pk(ename, 20 * powld(1.2, elevel + 10), 2 * powld(1.2, elevel + 10), elevel);
if(x)
{
cout << "你击败了" << ename << "!获得:金币" << baomoney << endl;
money += baomoney;
if(fuwen[id] == 0 && random(1, 100) <= fuwen_gailv)
{
cout << "获得" << name << "的符文!" << endl;
fuwen[id] = 1;
}
if(kuijia_level < elevel && random(1, 100) <= baolv)
{
cout << "获得一个" << elevel << "级别的盔甲!" << endl;
cout << "< > 盔甲属性:生命值+" << 20 * pow(1.2, elevel + 10);
system("pause");
hp -= 20 * powld(1.2, kuijia_level + 10);
hp += 20 * powld(1.2, elevel + 10);
kuijia_level = elevel;
}
if(wuqi_level < elevel && random(1, 100) <= 45)
{
cout << "获得一个" << elevel << "级别的武器!" << endl;
cout << "< > 武器属性:攻击力+" << 2 * pow(1.2, elevel + 10);
system("pause");
ap -= 2 * powld(1.2, wuqi_level + 10);
ap += 2 * powld(1.2, elevel + 10);
wuqi_level = elevel;
}
system("pause");
}
}
else if(x == 2)
{
if(fuwen[id] == 0)
{
cout << "你还没有符文碎片!!!" << endl;
Sleep(1000);
}
else if(fuwen[id] == -1)
{
cout << "符文已经激活 不能再重复了" << endl;
Sleep(1000);
}
else
{
cout << "符文缓缓地亮了起来……" << endl;
Sleep(1000);
cout << "获得" << name << "符文增幅 血量+" << 20 * powld(1.2, maxl) << " 攻击力+" << 2 * powld(1.2, maxl) << "" << endl;
fuwen[id] = -1;
hp += 20 * powld(1.2, maxl);
ap += 2 * powld(1.2, maxl);
}
}
else if(x == 3)
{
return;
}
}
}
void zhushijie()
{
while(1)
{
OUTS();
cout << endl << "???Craft1.0 副本 主世界" << endl;
cout << "Chapter1 僵尸洞穴 (Lv. 1-10)" << endl;
cout << "Chapter2 骷髅山巅 (Lv. 5-14)" << endl;
cout << "Chapter3 史莱姆城 (Lv. 9-18)" << endl;
cout << "Chapter4 潮湿沼泽 (Lv. 13-22)" << endl;
cout << "Chapter5 古城回响 (Lv. 17-26)" << endl;
if(fuwen[0] && fuwen[1] && fuwen[2] && fuwen[3] && fuwen[4]) cout << "6 挑战BOSS (Lv. 30)" << endl;
else cout << "6 ???" << endl;
cout << "7 返回上一级" << endl;
int x;
cin >> x;
if(x == 1) zhandoujiemian("僵尸洞穴", 1, 10, 45, "僵尸", 10, 0);
else if(x == 2) zhandoujiemian("骷髅山巅", 5, 14, 35, "骷髅", 20, 1);
else if(x == 3) zhandoujiemian("史莱姆城", 9, 18, 30, "史莱姆", 40, 2);
else if(x == 4) zhandoujiemian("潮湿沼泽", 13, 22, 25, "女巫", 80, 3);
else if(x == 5) zhandoujiemian("古城回响", 17, 26, 25, "幽暗僵尸", 160, 4);
else if(x == 6 && fuwen[0] && fuwen[1] && fuwen[2] && fuwen[3] && fuwen[4])
{
bool x = pk("循声守卫", 20 * powld(1.2, 40), 2 * powld(1.2, 40), 30);
if(x) boss[0] = true;
else boss[0] = false;
}
else if(x == 7) return;
}
}
void fuben()
{
while(1)
{
cout << endl << "???Craft1.0 副本" << endl;
cout << "[折叠] 1 主世界" << endl;
cout << "[折叠] 2 下界" << endl;
cout << "[折叠] 3 末地" << endl;
cout << "4 返回上一级" << endl;
int x;
cin >> x;
if(x == 1)
{
zhushijie();
}
else if(x == 4)
{
return;
}
}
}
void shangdian()
{
while(1)
{
OUTS();
cout << endl << "???Craft1.0 商店" << endl;
cout << "你的金币数量: " << print(money) << endl;
cout << endl;
cout << "1 升级符文掉落概率(当前" << fuwen_gailv << "%)+1% 需要" << pow(2, fuwen_gailv) * 10 << endl;
cout << "2 升级战斗时血量(当前" << zengfu_hp << "X)+10% 需要" << pow(2, zengfu_hp) * 10 << endl;
cout << "3 升级战斗时伤害(当前" << zengfu_ap << "X)+10% 需要" << pow(2, zengfu_ap) * 10 << endl;
cout << "4 离开" << endl;
int x;
cin >> x;
if(x == 1 && money >= pow(2, fuwen_gailv) * 10)
{
if(fuwen_gailv >= 30)
{
cout << "已经达到最高!" << endl;
}
else
{
money -= pow(2, fuwen_gailv) * 10;
fuwen_gailv++;
}
}
else if(x == 2 && money >= pow(2, zengfu_hp) * 10)
{
money -= pow(2, zengfu_hp) * 10;
zengfu_hp *= 1.1;
}
else if(x == 3 && money >= pow(2, zengfu_ap) * 10)
{
money -= pow(2, zengfu_ap) * 10;
zengfu_ap *= 1.1;
}
else if(x == 4)
{
return;
}
}
}
int main()
{
srand(time(0));
INS();
while(1)
{
OUTS();
cout << "???Craft奇怪的世界1.0" << endl;
cout << endl;
cout << "金钱 " << print(money) << endl;
cout << "生命值 " << print(hp * zengfu_hp) << ' ' << "攻击力 " << print(ap * zengfu_ap) << endl;
cout << endl;
cout << "1 副本" << endl;
cout << "2 商店" << endl;
cout << "3 开关急速模式(省略大部分战斗细节)" << endl;
int x;
cin >> x;
if(x == 1)
{
fuben();
}
else if(x == 2)
{
shangdian();
}
else if(x == 3)
{
speedup = !speedup;
}
}
}