本次增加:
反修改机制
本次修改:
三个bug
这一次没有更太多,只是更了0.6版本说的反修改机制——如果你修改了信息且存储的验证码与实际验证码不同,则会抹掉存档。
至于三个bug,一个是因为条件有问题,导致无法向右挖;第二个是在增加了反修改机制后抹掉存档后提示信息错误;至于第三个……是我自己为了直观看到抽取的随机数加了一句,而上次挂代码的时候……忘删了。
如果还有其它bug,欢迎私信。
#include <iostream>
#include <fstream>
#include <ctime>
#include <string>
using namespace std;
int planet = 1, depth = 0, coins = 0, pointofskills = 0, playerlifevalue = 10, playeraggressivity = 1, headarmorvalue = 0, bodyarmorvalue = 0, legarmorvalue = 0, check;
int knapsack[15] = { 0 };
string instructions;
int auxiliary = 0;
void rne(int minimum_1_1, int biggest_1_1, int minimum_1_2, int biggest_1_2, int minimum_2_1, int biggest_2_1, int minimum_2_2, int biggest_2_2, int minimum_3_1, int biggest_3_1, int minimum_3_2, int biggest_3_2, int minimum_4, int biggest_4, int monsterhealthvalue, int monsteraggressivity/*金币:1,技能点:2,炸弹:3*/)
{
auxiliary = rand() % 100 + 1;
if (auxiliary >= minimum_1_1 && auxiliary <= biggest_1_1)
{
srand(time(0));
auxiliary = rand() % (biggest_1_2 - minimum_1_2 + 1) + minimum_1_2;
cout << "你挖到了" << auxiliary << "个金币。" << endl;
coins += auxiliary;
}
if (auxiliary >= minimum_2_1 && auxiliary <= biggest_2_1)
{
srand(time(0));
auxiliary = rand() % (biggest_2_2 - minimum_2_2 + 1) + minimum_2_2;
cout << "你找到了" << auxiliary << "个技能点。" << endl;
pointofskills += auxiliary;
}
if (auxiliary >= minimum_3_1 && auxiliary <= biggest_3_1)
{
srand(time(0));
auxiliary = rand() % (biggest_3_2 - minimum_3_2 + 1) + minimum_3_2;
if (auxiliary > coins)auxiliary = coins;
if (auxiliary == 0)
{
cout << "你挖到了一个空箱子。" << endl;
}
else
{
cout << "你踩到了一个炸弹,丢了" << auxiliary << "个金币。" << endl;
coins -= auxiliary;
}
}
if (auxiliary >= minimum_4 && auxiliary <= biggest_4)
{
if (monsterhealthvalue / playeraggressivity <= (playerlifevalue + headarmorvalue + bodyarmorvalue + legarmorvalue) / monsteraggressivity)
{
auxiliary = (monsterhealthvalue / playeraggressivity) * monsteraggressivity - (headarmorvalue + bodyarmorvalue + legarmorvalue);
if (auxiliary < 0)auxiliary = 0;
cout << "你遇到了一只怪兽,你杀死了它,获得了" << playerlifevalue + playeraggressivity + headarmorvalue + bodyarmorvalue + legarmorvalue << "个金币,剩余" << playerlifevalue - auxiliary << "点生命。" << endl;
playerlifevalue -= auxiliary;
coins += (playerlifevalue + playeraggressivity + headarmorvalue + bodyarmorvalue + legarmorvalue);
}
else
{
cout << "你在与怪兽战斗时死了。" << endl;
planet = 1, depth = 0, coins = 0, pointofskills = 0, playerlifevalue = 10, playeraggressivity = 1, headarmorvalue = 0, bodyarmorvalue = 0, legarmorvalue = 0;
}
}
}
bool in(string str_chatter, string str_chatterBot)
{
if (str_chatter.find(str_chatterBot) != string::npos)
{
return true;
}
else
{
return false;
}
}
void gt(int dplanet)
{
if (coins >= dplanet * 2000)
{
cout << "去" << (dplanet == 1 ? "地球" : "") << (dplanet == 2 ? "月球" : "") << (dplanet == 3 ? "火星" : "") << (dplanet == 4 ? "泰坦星" : "") << (dplanet == 5 ? "金银星" : "") << "需要" << (dplanet == 1 ? "2000" : "") << (dplanet == 2 ? "4000" : "") << (dplanet == 3 ? "6000" : "") << (dplanet == 4 ? "8000" : "") << (dplanet == 5 ? "10000" : "") << "个金币,你有" << coins << "个金币,要前往吗?" << endl;
cin >> instructions;
if (in(instructions, "是") || in(instructions, "好") || in(instructions, "要"))
{
system("cls");
coins -= dplanet * 2000;
planet = dplanet;
cout << "您已到达" << (planet == 1 ? "地球" : "") << (planet == 2 ? "月球" : "") << (planet == 3 ? "火星" : "") << (planet == 4 ? "泰坦星" : "") << (planet == 5 ? "金银星" : "") << "!" << endl;
}
else
{
system("cls");
cout << "好的!" << endl;
}
}
else
{
cout << "去" << (dplanet == 1 ? "地球" : "") << (dplanet == 2 ? "月球" : "") << (dplanet == 3 ? "火星" : "") << (dplanet == 4 ? "泰坦星" : "") << (dplanet == 5 ? "金银星" : "") << "需要" << dplanet * 2000 << "个金币,你只有" << coins << "个金币,无法前往!" << endl;
}
}
void save()
{
ofstream out("save.dll");
check = (planet + depth + coins + pointofskills) % (playerlifevalue + playeraggressivity + headarmorvalue + bodyarmorvalue + legarmorvalue);
out << planet << " " << depth << " " << coins << " " << pointofskills << " " << playerlifevalue << " " << playeraggressivity << " " << headarmorvalue << " " << bodyarmorvalue << " " << legarmorvalue << " " << check;
out.close();
}
void read()
{
ifstream in("save.dll");
in >> planet >> depth >> coins >> pointofskills >> playerlifevalue >> playeraggressivity >> headarmorvalue >> bodyarmorvalue >> legarmorvalue >> check;
in.close();
if (check != (planet + depth + coins + pointofskills) % (playerlifevalue + playeraggressivity + headarmorvalue + bodyarmorvalue + legarmorvalue))
{
ofstream out("save.dll");
out.close();
planet = 1, depth = 0, coins = 0, pointofskills = 0, playerlifevalue = 10, playeraggressivity = 1, headarmorvalue = 0, bodyarmorvalue = 0, legarmorvalue = 0;
save();
cout << "呵呵,被发现了吧!我不喜欢作弊的人哦!" << endl;
system("pause");
system("cls");
}
}
int main()
{
system("color F0");
srand((unsigned int)time(NULL));
while (true)
{
read();
cout << "欢迎来到冒险挖矿!" << endl;
cout << "你现在在" << (planet == 1 ? "地球" : "") << (planet == 2 ? "月球" : "") << (planet == 3 ? "火星" : "") << (planet == 4 ? "泰坦星" : "") << (planet == 5 ? "金银星" : "") << ",挖了" << depth << "米" << ",有" << coins << "个金币" << "和" << pointofskills << "个技能点" << endl;
cout << "请问你想干什么?" << endl;
cin >> instructions;
if (in(instructions, "下") || in(instructions, "左") || in(instructions, "右"))
{
if (depth == 0 && (in(instructions, "左") || in(instructions, "右")))
{
system("pause");
system("cls");
save();
continue;
}
if (in(instructions, "下"))
{
depth++;
}
if (planet == 1)
{
if (depth <= 50)
{
rne(1, 70, 1, 10, 71, 80, 1, 10, 81, 95, 1, 10, 96, 100, 2, 1);
}
else
{
rne(1, 60, 1, 15, 61, 80, 1, 15, 81, 95, 1, 20, 96, 100, 5, 2);
}
}
if (planet == 2)
{
if (depth <= 50)
{
rne(1, 65, 10, 20, 66, 75, 10, 20, 76, 90, 15, 20, 91, 100, 8, 3);
}
else
{
rne(1, 60, 10, 25, 61, 75, 10, 25, 76, 90, 20, 30, 91, 100, 10, 3);
}
}
if (planet == 3)
{
if (depth <= 50)
{
rne(1, 60, 30, 100, 61, 80, 1, 20, 81, 95, 1, 80, 96, 100, 30, 5);
}
else
{
rne(1, 75, 40, 110, 76, 85, 20, 50, 86, 99, 1, 30, 100, 100, 50, 10);
}
}
if (planet == 4)
{
if (depth <= 50)
{
rne(1, 60, 55, 120, 56, 65, 30, 60, 66, 80, 50, 100, 81, 100, 100, 15);
}
else
{
rne(1, 40, 80, 150, 41, 60, 50, 80, 61, 80, 80, 100, 81, 100, 150, 20);
}
}
if (planet == 5)
{
if (depth <= 50)
{
rne(1, 10, 100, 200, 11, 20, 100, 200, 21, 80, 150, 250, 81, 100, 200, 20);
}
else
{
rne(1, 10, 150, 250, 11, 20, 150, 250, 21, 80, 200, 400, 81, 100, 500, 100);
}
}
}
else if (in(instructions, "去"))
{
if (in(instructions, "地球"))
{
if (planet == 1)
{
cout << "你已经在地球了哦!" << endl;
}
else
{
system("cls");
gt(1);
}
}
if (in(instructions, "月球"))
{
if (planet == 2)
{
cout << "你已经在月球了哦!" << endl;
}
else
{
system("cls");
gt(2);
}
}
if (in(instructions, "火星"))
{
if (planet == 3)
{
cout << "你已经在火星了哦!" << endl;
}
else
{
system("cls");
gt(3);
}
}
if (in(instructions, "泰坦星"))
{
if (planet == 4)
{
cout << "你已经在泰坦星了哦!" << endl;
}
else
{
system("cls");
gt(4);
}
}
if (in(instructions, "金银星"))
{
if (planet == 5)
{
cout << "你已经在金银星了哦!" << endl;
}
else
{
system("cls");
gt(5);
}
}
}
else if (in(instructions, "抹掉"))
{
cout << "确定要抹掉存档吗?" << endl;
cin >> instructions;
if (in(instructions, "是") || in(instructions, "好") || in(instructions, "要"))
{
ofstream in("save.dll");
in.close();
planet = 1, depth = 0, coins = 0, pointofskills = 0, playerlifevalue = 10, playeraggressivity = 1, headarmorvalue = 0, bodyarmorvalue = 0, legarmorvalue = 0;
save();
cout << "已抹掉!" << endl;
}
system("pause");
system("cls");
continue;
}
else if (in(instructions, "帮助"))
{
cout << "一.关键词" << endl;
cout << "1.向下、向左、向右:下、左、右" << endl;
cout << "2.去某个星球:去(哪里,星球分别有地球、月球、火星、泰坦星、金银星,此处按危险程度排序,在越危险的地方遇到金币,金币将会更多)" << endl;
cout << "3.抹掉存档:抹掉" << endl;
cout << "4.确认:是、好、要\t取消:其它短语均可" << endl;
cout << "5.帮助:帮助" << endl;
cout << "6.输入无关内容,将跳过" << endl;
cout << "二.关于挖矿" << endl;
cout << "1.在第0米处只能往下挖" << endl;
cout << "三.其它" << endl;
cout << "1.游戏将自动保存!" << endl;
}
system("pause");
system("cls");
save();
}
}