#include<bits/stdc++.h>
#include<setjmp.h>
jmp_buf jmpbuffer;
using namespace std;
const int maxn = 30;
const int maxm = 30;
char maps[30][30];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
bool boom = false;
bool stop_fall = false;
int blood = 100;
int res;
int cnt = 0;
int speed = 1600000;
string moves;
string nothing;
string oper1 = "为蛇加血量消耗了:";
string oper2 = "为账户充值增加了:";
string oper3 = "为蛇变换头尾消耗了:";
int count_num;
int u;
struct fg {
string codes;
int money;
}ff;
struct ffg {
string operations;
int changes;
int moneys;
};
map<string, fg> kk;
map<string, vector<ffg> > kkk;
string str1, str2, op;
bool need_to_put = true;
int aaa, bbb, aa;
int head, tail;
int num = 0;
int total_num = maxn * maxm;
struct no {
int x;
int y;
int next;
}node[maxn * maxm];
bool IO(char c) {
if(c == 'a') return true;
if(c == 'w') return true;
if(c == 'd') return true;
if(c == 's') return true;
return false;
}
struct bo {
int x;
int y;
}bombs[200];
int bombs_num;
int ccc, ddd, cc;
int dist(int i, int j, int x, int y) {
return abs(i - x) + abs(j - y);
}
int swaps(int t) {
if(t == -1 || (node[t].next == -1))
return t;
//蛇头蛇尾互换,但返回值有wen'ti
else {
int tt = swaps(node[t].next);
node[node[t].next].next = t;
node[t].next = -1;
return tt;
}
}
bool lk = true;
int main() {
while(1) {
if(setjmp(jmpbuffer) != 0) {}
cout << "请输入账户:";
cin >> str1;
if(!kk.count(str1)) {
cout << "该用户不存在,请注册" << endl;
cout << "请输入账户:";
cin >> str1;
if(kk.count(str1)) {
cout << "该账户已经存在!" << endl;
goto ppp;
}
cout << "请输入密码:";
cin >> str2;
cout << "请输入充值点数:";
lk = false;
int u;
cin >> u;
kk[str1].codes = str2;
kk[str1].money = u;
kkk[str1].push_back({oper2, u, kk[str1].money});
cout << "账户" << str1 << "的花费记录" << endl;
for(int i = 0; i < kkk[str1].size(); i ++) {
cout << i + 1 << " " << kkk[str1][i].operations << kkk[str1][i].changes;
cout << "这个时候账户余额为:" << kkk[str1][i].moneys << endl;
}
cout << "按1继续" << endl;
cin >> nothing;
}
else {
ppp:
cout << "请输入密码:";
cin >> str2;
}
while(kk[str1].codes != str2) {
cout << "密码错误" << endl;
cout << "按1再次输入密码, 按2重新注册" << endl;
while(cin >> op) {
if(op[0] != '1' && op[0] != '2') continue;
else break;
}
if(op[0] == '1') {
cout << "请输入密码:";
cin >> str2;
continue;
}
else if(op[0] == '2') {
cout << "请输入账户:";
cin >> str1;
if(kk.count(str1)) {
cout << "该账户已经存在!" << endl;
goto ppp;
}
cout << "请输入密码:";
cin >> str2;
cout << "请输入充值点数:";
int u;
cin >> u;
kk[str1].codes = str2;
kk[str1].money = u;
kkk[str1].push_back({oper2, u, kk[str1].money});
cout << "账户" << str1 << "的花费记录" << endl;
for(int i = 0; i < kkk[str1].size(); i ++) {
cout << i + 1 << " " << kkk[str1][i].operations << kkk[str1][i].changes;
cout << "这个时候账户余额为:" << kkk[str1][i].moneys << endl;
}
cout << "按1继续" << endl;
cin >> nothing;
break;
}
}
if(1 == 1) { // games1();
node[++ num].next = -1;
node[num].x = 5;
node[num].y = 6;
head = num; tail = num;
maps[5][6] = 'h';
if(1 == 1) { // puts_one();
while(1) {
aaa = 1, bbb = rand() * 37 % maxm;
if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
continue;
if(maps[aaa][bbb] == 'o') continue;
if(maps[aaa][bbb] == 'h') continue;
if(maps[aaa][bbb] == 'w') continue;
maps[aaa][bbb] = 'm';
break;
}
need_to_put = false;
}
if(1 == 1) { //outs();
for(int i = 0; i < maxn; i ++) {
for(int j = 0; j < maxm; j ++) {
if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
maps[i][j] = '#';
cout << maps[i][j];
continue;
}
cout << maps[i][j];
}
cout << endl;
}
}
while(1) {
if(1 == 1) { // works()
int dis = 0x3f, pos = -1;
int xx = node[head].x, yy = node[head].y;
for(int k = 0; k < 4; k ++) {
int xxx = xx + dx[k], yyy = yy + dy[k];
if(xxx == 0 || xxx == maxn - 1 || yyy == 0 || yyy == maxm - 1)
continue;
if(maps[xxx][yyy] == 'o') continue;
if(maps[xxx][yyy] == 'w') continue;
if(maps[xxx][yyy] == 'b') continue;
if(dist(xxx, yyy, aaa, bbb) < dis) {
dis = dist(xxx, yyy, aaa, bbb);
pos = k;
}
}
if(pos == -1) {
cout << "it is time to swap the tail and head" << endl;
cout << "是否为这条蛇续命;按1继续,且至少充1000金币,按2就只能重新开始了" << endl;
cin >> u;
if(u == 2) {
bombs_num = 0;
memset(maps, ' ', sizeof(maps));
num = 0;
blood = 100;
node[++ num].next = -1;
node[num].x = 5;
node[num].y = 6;
speed = 16000000;
head = num; tail = num;
maps[5][6] = 'h';
if(1 == 1) { // puts_one();
while(1) {
aaa = 1, bbb = rand() * 37 % maxm;
if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
continue;
if(maps[aaa][bbb] == 'o') continue;
if(maps[aaa][bbb] == 'h') continue;
if(maps[aaa][bbb] == 'w') continue;
maps[aaa][bbb] = 'm';
break;
}
need_to_put = false;
}
if(1 == 1) { //outs();
for(int i = 0; i < maxn; i ++) {
for(int j = 0; j < maxm; j ++) {
if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
maps[i][j] = '#';
cout << maps[i][j];
continue;
}
cout << maps[i][j];
}
cout << endl;
}
}
boom = false;
}
else if(u == 1) {
int uu;
while(1) {
cout << "请输入充血量值的点数:";
cin >> u;
while(u < 1000) {
cout << "金币少于1000,请再次输入合法的值" << endl;
cin >> u;
}
while(u > kk[str1].money) {
cout << "余额不足哎" << endl;
cout << "接下来按1准备向账户充值,2是刚才充值的血量点数" << endl;
cin >> u;
if(u == 1) {
cout << "请输入向账户增加的值数" << endl;
int uu;
cin >> uu;
kk[str1].money += uu;
kkk[str1].push_back({oper2, uu, kk[str1].money});
u = 2;
}
if(u == 2) {
cout << "请输入首尾变换的费用" << endl;
cin >> u;
while(u < 1000) {
cout << "金币少于1000,请再次输入合法的值" << endl;
cin >> u;
}
if(u > kk[str1].money) continue;
else
break;
}
}
cout << "蛇可以首尾交换了" << endl;
kk[str1].money -= u;
boom = false;
kkk[str1].push_back({oper3, u, kk[str1].money});
cout << "账户" << str1 << "的花费记录" << endl;
for(int i = 0; i < kkk[str1].size(); i ++) {
cout << i + 1 << " " << kkk[str1][i].operations << kkk[str1][i].changes;
cout << "这个时候账户余额为:" << kkk[str1][i].moneys << endl;
}
cout << "按1继续" << endl;
cin >> nothing;
break;
}
head = tail;
tail = swaps(tail);
maps[node[head].x][node[head].y] = 'h';
maps[node[tail].x][node[tail].y] = 'o';
int dis = 0x3f, pos = -1;
int xx = node[head].x, yy = node[head].y;
for(int k = 0; k < 4; k ++) {
int xxx = xx + dx[k], yyy = yy + dy[k];
if(xxx == 0 || xxx == maxn - 1 || yyy == 0 || yyy == maxm - 1)
continue;
if(maps[xxx][yyy] == 'o') continue;
if(maps[xxx][yyy] == 'w') continue;
if(dist(xxx, yyy, aaa, bbb) < dis) {
dis = dist(xxx, yyy, aaa, bbb);
pos = k;
}
}
}
}
if(pos == 0) { //work('w');
if(1 == 1) {
char c; c = 'w';
res ++;
int uio = speed;
if(res % 300 == 299) {
cout << "是否需要变速:";
cout << "按0原样继续,1慢速,2中速,3快速" << endl;
cin >> speed;
}
if(speed == 0) speed = uio;
else if(speed == 1) speed = 160000000;
else if(speed == 2) speed = 16000000;
else if(speed == 3) speed = 1600000;
for(int ik = 0; ik < speed; ik ++) {} // 降速
if(1 == 1) { // head_move(c);
char temp; temp = c;
cnt ++;
cout << cnt << endl;
int x = node[head].x, y = node[head].y;
if(temp == 'a') y --;
if(temp == 'd') y ++;
if(temp == 'w') x --;
if(temp == 's') x ++;
if(x == 0 || x == maxn - 1 || y == 0 || y == maxm - 1) boom = 1;
if(!boom) {
if(x == aaa && y == bbb) {
num ++;
num = num % total_num;
// num 有越界的危险,故%,不影响结果
node[num].x = x;
node[num].y = y;
node[num].next = -1;
node[head].next = num;
maps[node[head].x][node[head].y] = 'o';
head = node[head].next;
maps[node[head].x][node[head].y] = 'h';
aaa = -1; bbb = -1;
need_to_put = true;
stop_fall = false;
}
else {
if(maps[x][y] == 'o') boom = true;
if(!boom) {
num ++;
num = num % total_num;
node[num].x = x;
node[num].y = y;
node[num].next = -1;
node[head].next = num;
maps[node[tail].x][node[tail].y] = ' ';
if(tail != head)
maps[node[head].x][node[head].y] = 'o';
tail = node[tail].next;
head = node[head].next;
maps[node[head].x][node[head].y] = 'h';
}
}
}
}
if(1 == 1) { // stone_move
aa = aaa - 1;
if(aaa < maxn - 2 && !stop_fall) {
maps[aaa][bbb] = ' ';
aa ++; aaa ++;
}
if(maps[aaa][bbb] == 'o' || maps[aaa][bbb] == 'h') {
need_to_put = true;
//return;
}
else if(maps[aaa][bbb] == 'w') {
maps[aa][bbb] = 'm';
aaa = aa;
stop_fall = true;
}
else
maps[aaa][bbb] = 'm';
}
for(int io = 0; io < bombs_num; io ++) {
//bomb_fall_one(io);
int i = io;
int ccc = bombs[i].x, ddd = bombs[i].y;
if(!ccc && !ddd) continue;
if(ccc < maxn - 1) {
maps[ccc][ddd] = ' ';
ccc ++;
bombs[i].x ++;
}
char temps = maps[ccc][ddd];
if(temps == '#' || temps == 'w' || temps == 'o' || temps == 'm' || temps == 'h') {
if(1 == 1) { //bomb_boom(i);
int ccc = bombs[i].x, ddd = bombs[i].y;
cout << "hjk" << " " << i << " " << ccc << " " << ddd << endl;
for(int id = ccc - 1; id <= ccc + 1; id ++) {
for(int jd = ddd - 1; jd <= ddd + 1; jd ++) {
if(maps[id][jd] == '#') continue;
if(maps[id][jd] == 'w') maps[id][jd] = ' ';
if(maps[id][jd] == 'm') {
maps[id][jd] = ' ';
//need_to_put = true;
}
if(maps[id][jd] == 'o' || maps[id][jd] == 'h') {
blood -= 10;
cout << "the blood of the snake has deleted 10!" << endl;
cout << "蛇剩下的血量为:" << blood << endl;
}
}
}
bombs[i].x = 0, bombs[i].y = 0;
}
//return;
}
else
maps[ccc][ddd] = 'b';
}
if(res % 57 == 1) {
while(1) {
int fx = rand() * 18 % maxn, fy = rand() * 18 % maxm;
char temps = maps[fx][fy];
if(temps == 'm' || temps == 'h' || temps == 'o')
continue;
if(fx == 0 || fx == maxn - 1 || fy == 0 || fy == maxm - 1)
continue;
maps[fx][fy] = 'w';
break;
}
}
if(res % 10 == 1) {
int fx, fy;
while(1) {
fx = 1, fy = rand() * 57 % maxm;
if(fy == 0 || fy == maxm - 1)
continue;
if(maps[fx][fy] == 'o') continue;
if(maps[fx][fy] == 'h') continue;
if(maps[fx][fy] == 'w') continue;
if(maps[fx][fy] == 'm') continue;
break;
}
maps[fx][fy] = 'b';
bombs[bombs_num].x = fx;
bombs[bombs_num].y = fy;
bombs_num ++;
}
if(blood <= 0) boom = true;
if(boom) {
cout << "game over" << endl;
cout << str1 << " " << str2 << endl;
cout << "是否为这条蛇续命;按1继续,按2就只能重新开始了";
cout << ",按3重新跳到最初始的输入账户的界面,可以可以更换账户!" << endl;
cin >> u;
if(u == 3) {
bombs_num = 0;
memset(maps, ' ', sizeof(maps));
blood = 100;
speed = 16000000;
head = num; tail = num;
boom = false;
longjmp(jmpbuffer, 1);
}
if(u == 2) {
bombs_num = 0;
memset(maps, ' ', sizeof(maps));
num = 0;
blood = 100;
node[++ num].next = -1;
node[num].x = 5;
node[num].y = 6;
speed = 16000000;
head = num; tail = num;
maps[5][6] = 'h';
if(1 == 1) { //puts_one();
while(1) {
aaa = 1, bbb = rand() * 37 % maxm;
if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
continue;
if(maps[aaa][bbb] == 'o') continue;
if(maps[aaa][bbb] == 'h') continue;
if(maps[aaa][bbb] == 'w') continue;
maps[aaa][bbb] = 'm';
break;
}
need_to_put = false;
}
if(1 == 1) { //outs();
for(int i = 0; i < maxn; i ++) {
for(int j = 0; j < maxm; j ++) {
if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
maps[i][j] = '#';
cout << maps[i][j];
continue;
}
cout << maps[i][j];
}
cout << endl;
}
}
boom = false;
}
else if(u == 1) {
int uu;
while(1) {
cout << "请输入充血量值的点数:";
cin >> u;
while(u > kk[str1].money) {
cout << "余额不足哎" << endl;
cout << "接下来按1准备向账户充值,2是刚才充值的血量点数" << endl;
cin >> u;
if(u == 1) {
cout << "请输入向账户增加的值数" << endl;
int uu;
cin >> uu;
kk[str1].money += uu;
kkk[str1].push_back({oper2, uu, kk[str1].money});
u = 2;
}
if(u == 2) {
cout << "请输入向蛇增加的值数" << endl;
cin >> u;
if(u > kk[str1].money) continue;
else
break;
}
}
cout << "蛇的血量重新变为:" << " " << u << endl;
kk[str1].money -= u;
blood = u;
boom = false;
kkk[str1].push_back({oper1, u, kk[str1].money});
cout << "账户" << str1 << "的花费记录" << endl;
for(int i = 0; i < kkk[str1].size(); i ++) {
cout << i + 1 << " " << kkk[str1][i].operations << kkk[str1][i].changes;
cout << "这个时候账户余额为:" << kkk[str1][i].moneys << endl;
}
cout << "按1继续" << endl;
cin >> nothing;
break;
}
}
}
else { // outss();
for(int i = 0; i < maxn; i ++) {
for(int j = 0; j < maxm; j ++) {
if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
maps[i][j] = '#';
cout << maps[i][j];
continue;
}
cout << maps[i][j];
}
cout << endl;
}
}
if(need_to_put) { //puts_one();
while(1) {
aaa = 1, bbb = rand() * 37 % maxm;
if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
continue;
if(maps[aaa][bbb] == 'o') continue;
if(maps[aaa][bbb] == 'h') continue;
if(maps[aaa][bbb] == 'w') continue;
maps[aaa][bbb] = 'm';
break;
}
need_to_put = false;
}
}
}
if(pos == 1) { //work('a');
if(1 == 1) {
char c; c = 'a';
res ++;
int uio = speed;
if(res % 300 == 299) {
cout << "是否需要变速:";
cout << "按0原样继续,1慢速,2中速,3快速" << endl;
cin >> speed;
}
if(speed == 0) speed = uio;
else if(speed == 1) speed = 160000000;
else if(speed == 2) speed = 16000000;
else if(speed == 3) speed = 1600000;
for(int ik = 0; ik < speed; ik ++) {} // 降速
if(1 == 1) { // head_move(c);
char temp; temp = c;
cnt ++;
cout << cnt << endl;
int x = node[head].x, y = node[head].y;
if(temp == 'a') y --;
if(temp == 'd') y ++;
if(temp == 'w') x --;
if(temp == 's') x ++;
if(x == 0 || x == maxn - 1 || y == 0 || y == maxm - 1) boom = 1;
if(!boom) {
if(x == aaa && y == bbb) {
num ++;
num = num % total_num;
// num 有越界的危险,故%,不影响结果
node[num].x = x;
node[num].y = y;
node[num].next = -1;
node[head].next = num;
maps[node[head].x][node[head].y] = 'o';
head = node[head].next;
maps[node[head].x][node[head].y] = 'h';
aaa = -1; bbb = -1;
need_to_put = true;
stop_fall = false;
}
else {
if(maps[x][y] == 'o') boom = true;
if(!boom) {
num ++;
num = num % total_num;
node[num].x = x;
node[num].y = y;
node[num].next = -1;
node[head].next = num;
maps[node[tail].x][node[tail].y] = ' ';
if(tail != head)
maps[node[head].x][node[head].y] = 'o';
tail = node[tail].next;
head = node[head].next;
maps[node[head].x][node[head].y] = 'h';
}
}
}
}
if(1 == 1) { // stone_move
aa = aaa - 1;
if(aaa < maxn - 2 && !stop_fall) {
maps[aaa][bbb] = ' ';
aa ++; aaa ++;
}
if(maps[aaa][bbb] == 'o' || maps[aaa][bbb] == 'h') {
need_to_put = true;
//return;
}
else if(maps[aaa][bbb] == 'w') {
maps[aa][bbb] = 'm';
aaa = aa;
stop_fall = true;
}
else
maps[aaa][bbb] = 'm';
}
for(int io = 0; io < bombs_num; io ++) {
//bomb_fall_one(io);
int i = io;
int ccc = bombs[i].x, ddd = bombs[i].y;
if(!ccc && !ddd) continue;
if(ccc < maxn - 1) {
maps[ccc][ddd] = ' ';
ccc ++;
bombs[i].x ++;
}
char temps = maps[ccc][ddd];
if(temps == '#' || temps == 'w' || temps == 'o' || temps == 'm' || temps == 'h') {
if(1 == 1) { //bomb_boom(i);
int ccc = bombs[i].x, ddd = bombs[i].y;
cout << "hjk" << " " << i << " " << ccc << " " << ddd << endl;
for(int id = ccc - 1; id <= ccc + 1; id ++) {
for(int jd = ddd - 1; jd <= ddd + 1; jd ++) {
if(maps[id][jd] == '#') continue;
if(maps[id][jd] == 'w') maps[id][jd] = ' ';
if(maps[id][jd] == 'm') {
maps[id][jd] = ' ';
//need_to_put = true;
}
if(maps[id][jd] == 'o' || maps[id][jd] == 'h') {
blood -= 10;
cout << "the blood of the snake has deleted 10!" << endl;
cout << "蛇剩下的血量为:" << blood << endl;
}
}
}
bombs[i].x = 0, bombs[i].y = 0;
}
//return;
}
else
maps[ccc][ddd] = 'b';
}
if(res % 57 == 1) {
while(1) {
int fx = rand() * 18 % maxn, fy = rand() * 18 % maxm;
char temps = maps[fx][fy];
if(temps == 'm' || temps == 'h' || temps == 'o')
continue;
if(fx == 0 || fx == maxn - 1 || fy == 0 || fy == maxm - 1)
continue;
maps[fx][fy] = 'w';
break;
}
}
if(res % 10 == 1) {
int fx, fy;
while(1) {
fx = 1, fy = rand() * 57 % maxm;
if(fy == 0 || fy == maxm - 1)
continue;
if(maps[fx][fy] == 'o') continue;
if(maps[fx][fy] == 'h') continue;
if(maps[fx][fy] == 'w') continue;
if(maps[fx][fy] == 'm') continue;
break;
}
maps[fx][fy] = 'b';
bombs[bombs_num].x = fx;
bombs[bombs_num].y = fy;
bombs_num ++;
}
if(blood <= 0) boom = true;
if(boom) {
cout << "game over" << endl;
cout << str1 << " " << str2 << endl;
cout << "是否为这条蛇续命;按1继续,按2就只能重新开始了";
cout << ",按3重新跳到最初始的输入账户的界面,可以可以更换账户!" << endl;
cin >> u;
if(u == 3) {
bombs_num = 0;
memset(maps, ' ', sizeof(maps));
blood = 100;
speed = 16000000;
head = num; tail = num;
boom = false;
longjmp(jmpbuffer, 1);
}
if(u == 2) {
bombs_num = 0;
memset(maps, ' ', sizeof(maps));
num = 0;
blood = 100;
node[++ num].next = -1;
node[num].x = 5;
node[num].y = 6;
speed = 16000000;
head = num; tail = num;
maps[5][6] = 'h';
if(1 == 1) { //puts_one();
while(1) {
aaa = 1, bbb = rand() * 37 % maxm;
if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
continue;
if(maps[aaa][bbb] == 'o') continue;
if(maps[aaa][bbb] == 'h') continue;
if(maps[aaa][bbb] == 'w') continue;
maps[aaa][bbb] = 'm';
break;
}
need_to_put = false;
}
if(1 == 1) { //outs();
for(int i = 0; i < maxn; i ++) {
for(int j = 0; j < maxm; j ++) {
if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
maps[i][j] = '#';
cout << maps[i][j];
continue;
}
cout << maps[i][j];
}
cout << endl;
}
}
boom = false;
}
else if(u == 1) {
int uu;
while(1) {
cout << "请输入充血量值的点数:";
cin >> u;
while(u > kk[str1].money) {
cout << "余额不足哎" << endl;
cout << "接下来按1准备向账户充值,2是刚才充值的血量点数" << endl;
cin >> u;
if(u == 1) {
cout << "请输入向账户增加的值数" << endl;
int uu;
cin >> uu;
kk[str1].money += uu;
kkk[str1].push_back({oper2, uu, kk[str1].money});
u = 2;
}
if(u == 2) {
cout << "请输入向蛇增加的值数" << endl;
cin >> u;
if(u > kk[str1].money) continue;
else
break;
}
}
cout << "蛇的血量重新变为:" << " " << u << endl;
kk[str1].money -= u;
blood = u;
boom = false;
kkk[str1].push_back({oper1, u, kk[str1].money});
cout << "账户" << str1 << "的花费记录" << endl;
for(int i = 0; i < kkk[str1].size(); i ++) {
cout << i + 1 << " " << kkk[str1][i].operations << kkk[str1][i].changes;
cout << "这个时候账户余额为:" << kkk[str1][i].moneys << endl;
}
cout << "按1继续" << endl;
cin >> nothing;
break;
}
}
}
else { // outss();
for(int i = 0; i < maxn; i ++) {
for(int j = 0; j < maxm; j ++) {
if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
maps[i][j] = '#';
cout << maps[i][j];
continue;
}
cout << maps[i][j];
}
cout << endl;
}
}
if(need_to_put) { //puts_one();
while(1) {
aaa = 1, bbb = rand() * 37 % maxm;
if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
continue;
if(maps[aaa][bbb] == 'o') continue;
if(maps[aaa][bbb] == 'h') continue;
if(maps[aaa][bbb] == 'w') continue;
maps[aaa][bbb] = 'm';
break;
}
need_to_put = false;
}
}
}
if(pos == 2) {//work('s');
if(1 == 1) {
char c; c = 's';
res ++;
int uio = speed;
if(res % 300 == 299) {
cout << "是否需要变速:";
cout << "按0原样继续,1慢速,2中速,3快速" << endl;
cin >> speed;
}
if(speed == 0) speed = uio;
else if(speed == 1) speed = 160000000;
else if(speed == 2) speed = 16000000;
else if(speed == 3) speed = 1600000;
for(int ik = 0; ik < speed; ik ++) {} // 降速
if(1 == 1) { // head_move(c);
char temp; temp = c;
cnt ++;
cout << cnt << endl;
int x = node[head].x, y = node[head].y;
if(temp == 'a') y --;
if(temp == 'd') y ++;
if(temp == 'w') x --;
if(temp == 's') x ++;
if(x == 0 || x == maxn - 1 || y == 0 || y == maxm - 1) boom = 1;
if(!boom) {
if(x == aaa && y == bbb) {
num ++;
num = num % total_num;
// num 有越界的危险,故%,不影响结果
node[num].x = x;
node[num].y = y;
node[num].next = -1;
node[head].next = num;
maps[node[head].x][node[head].y] = 'o';
head = node[head].next;
maps[node[head].x][node[head].y] = 'h';
aaa = -1; bbb = -1;
need_to_put = true;
stop_fall = false;
}
else {
if(maps[x][y] == 'o') boom = true;
if(!boom) {
num ++;
num = num % total_num;
node[num].x = x;
node[num].y = y;
node[num].next = -1;
node[head].next = num;
maps[node[tail].x][node[tail].y] = ' ';
if(tail != head)
maps[node[head].x][node[head].y] = 'o';
tail = node[tail].next;
head = node[head].next;
maps[node[head].x][node[head].y] = 'h';
}
}
}
}
if(1 == 1) { // stone_move
aa = aaa - 1;
if(aaa < maxn - 2 && !stop_fall) {
maps[aaa][bbb] = ' ';
aa ++; aaa ++;
}
if(maps[aaa][bbb] == 'o' || maps[aaa][bbb] == 'h') {
need_to_put = true;
//return;
}
else if(maps[aaa][bbb] == 'w') {
maps[aa][bbb] = 'm';
aaa = aa;
stop_fall = true;
}
else
maps[aaa][bbb] = 'm';
}
for(int io = 0; io < bombs_num; io ++) {
//bomb_fall_one(io);
int i = io;
int ccc = bombs[i].x, ddd = bombs[i].y;
if(!ccc && !ddd) continue;
if(ccc < maxn - 1) {
maps[ccc][ddd] = ' ';
ccc ++;
bombs[i].x ++;
}
char temps = maps[ccc][ddd];
if(temps == '#' || temps == 'w' || temps == 'o' || temps == 'm' || temps == 'h') {
if(1 == 1) { //bomb_boom(i);
int ccc = bombs[i].x, ddd = bombs[i].y;
cout << "hjk" << " " << i << " " << ccc << " " << ddd << endl;
for(int id = ccc - 1; id <= ccc + 1; id ++) {
for(int jd = ddd - 1; jd <= ddd + 1; jd ++) {
if(maps[id][jd] == '#') continue;
if(maps[id][jd] == 'w') maps[id][jd] = ' ';
if(maps[id][jd] == 'm') {
maps[id][jd] = ' ';
//need_to_put = true;
}
if(maps[id][jd] == 'o' || maps[id][jd] == 'h') {
blood -= 10;
cout << "the blood of the snake has deleted 10!" << endl;
cout << "蛇剩下的血量为:" << blood << endl;
}
}
}
bombs[i].x = 0, bombs[i].y = 0;
}
//return;
}
else
maps[ccc][ddd] = 'b';
}
if(res % 57 == 1) {
while(1) {
int fx = rand() * 18 % maxn, fy = rand() * 18 % maxm;
char temps = maps[fx][fy];
if(temps == 'm' || temps == 'h' || temps == 'o')
continue;
if(fx == 0 || fx == maxn - 1 || fy == 0 || fy == maxm - 1)
continue;
maps[fx][fy] = 'w';
break;
}
}
if(res % 10 == 1) {
int fx, fy;
while(1) {
fx = 1, fy = rand() * 57 % maxm;
if(fy == 0 || fy == maxm - 1)
continue;
if(maps[fx][fy] == 'o') continue;
if(maps[fx][fy] == 'h') continue;
if(maps[fx][fy] == 'w') continue;
if(maps[fx][fy] == 'm') continue;
break;
}
maps[fx][fy] = 'b';
bombs[bombs_num].x = fx;
bombs[bombs_num].y = fy;
bombs_num ++;
}
if(blood <= 0) boom = true;
if(boom) {
cout << "game over" << endl;
cout << str1 << " " << str2 << endl;
cout << "是否为这条蛇续命;按1继续,按2就只能重新开始了";
cout << ",按3重新跳到最初始的输入账户的界面,可以可以更换账户!" << endl;
cin >> u;
if(u == 3) {
bombs_num = 0;
memset(maps, ' ', sizeof(maps));
blood = 100;
speed = 16000000;
head = num; tail = num;
boom = false;
longjmp(jmpbuffer, 1);
}
if(u == 2) {
bombs_num = 0;
memset(maps, ' ', sizeof(maps));
num = 0;
blood = 100;
node[++ num].next = -1;
node[num].x = 5;
node[num].y = 6;
speed = 16000000;
head = num; tail = num;
maps[5][6] = 'h';
if(1 == 1) { //puts_one();
while(1) {
aaa = 1, bbb = rand() * 37 % maxm;
if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
continue;
if(maps[aaa][bbb] == 'o') continue;
if(maps[aaa][bbb] == 'h') continue;
if(maps[aaa][bbb] == 'w') continue;
maps[aaa][bbb] = 'm';
break;
}
need_to_put = false;
}
if(1 == 1) { //outs();
for(int i = 0; i < maxn; i ++) {
for(int j = 0; j < maxm; j ++) {
if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
maps[i][j] = '#';
cout << maps[i][j];
continue;
}
cout << maps[i][j];
}
cout << endl;
}
}
boom = false;
}
else if(u == 1) {
int uu;
while(1) {
cout << "请输入充血量值的点数:";
cin >> u;
while(u > kk[str1].money) {
cout << "余额不足哎" << endl;
cout << "接下来按1准备向账户充值,2是刚才充值的血量点数" << endl;
cin >> u;
if(u == 1) {
cout << "请输入向账户增加的值数" << endl;
int uu;
cin >> uu;
kk[str1].money += uu;
kkk[str1].push_back({oper2, uu, kk[str1].money});
u = 2;
}
if(u == 2) {
cout << "请输入向蛇增加的值数" << endl;
cin >> u;
if(u > kk[str1].money) continue;
else
break;
}
}
cout << "蛇的血量重新变为:" << " " << u << endl;
kk[str1].money -= u;
blood = u;
boom = false;
kkk[str1].push_back({oper1, u, kk[str1].money});
cout << "账户" << str1 << "的花费记录" << endl;
for(int i = 0; i < kkk[str1].size(); i ++) {
cout << i + 1 << " " << kkk[str1][i].operations << kkk[str1][i].changes;
cout << "这个时候账户余额为:" << kkk[str1][i].moneys << endl;
}
cout << "按1继续" << endl;
cin >> nothing;
break;
}
}
}
else { // outss();
for(int i = 0; i < maxn; i ++) {
for(int j = 0; j < maxm; j ++) {
if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
maps[i][j] = '#';
cout << maps[i][j];
continue;
}
cout << maps[i][j];
}
cout << endl;
}
}
if(need_to_put) { //puts_one();
while(1) {
aaa = 1, bbb = rand() * 37 % maxm;
if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
continue;
if(maps[aaa][bbb] == 'o') continue;
if(maps[aaa][bbb] == 'h') continue;
if(maps[aaa][bbb] == 'w') continue;
maps[aaa][bbb] = 'm';
break;
}
need_to_put = false;
}
}
}
if(pos == 3) { //work('d');
if(1 == 1) {
char c; c = 'd';
res ++;
int uio = speed;
if(res % 300 == 299) {
cout << "是否需要变速:";
cout << "按0原样继续,1慢速,2中速,3快速" << endl;
cin >> speed;
}
if(speed == 0) speed = uio;
else if(speed == 1) speed = 160000000;
else if(speed == 2) speed = 16000000;
else if(speed == 3) speed = 1600000;
for(int ik = 0; ik < speed; ik ++) {} // 降速
if(1 == 1) { // head_move(c);
char temp; temp = c;
cnt ++;
cout << cnt << endl;
int x = node[head].x, y = node[head].y;
if(temp == 'a') y --;
if(temp == 'd') y ++;
if(temp == 'w') x --;
if(temp == 's') x ++;
if(x == 0 || x == maxn - 1 || y == 0 || y == maxm - 1) boom = 1;
if(!boom) {
if(x == aaa && y == bbb) {
num ++;
num = num % total_num;
// num 有越界的危险,故%,不影响结果
node[num].x = x;
node[num].y = y;
node[num].next = -1;
node[head].next = num;
maps[node[head].x][node[head].y] = 'o';
head = node[head].next;
maps[node[head].x][node[head].y] = 'h';
aaa = -1; bbb = -1;
need_to_put = true;
stop_fall = false;
}
else {
if(maps[x][y] == 'o') boom = true;
if(!boom) {
num ++;
num = num % total_num;
node[num].x = x;
node[num].y = y;
node[num].next = -1;
node[head].next = num;
maps[node[tail].x][node[tail].y] = ' ';
if(tail != head)
maps[node[head].x][node[head].y] = 'o';
tail = node[tail].next;
head = node[head].next;
maps[node[head].x][node[head].y] = 'h';
}
}
}
}
if(1 == 1) { // stone_move
aa = aaa - 1;
if(aaa < maxn - 2 && !stop_fall) {
maps[aaa][bbb] = ' ';
aa ++; aaa ++;
}
if(maps[aaa][bbb] == 'o' || maps[aaa][bbb] == 'h') {
need_to_put = true;
//return;
}
else if(maps[aaa][bbb] == 'w') {
maps[aa][bbb] = 'm';
aaa = aa;
stop_fall = true;
}
else
maps[aaa][bbb] = 'm';
}
for(int io = 0; io < bombs_num; io ++) {
//bomb_fall_one(io);
int i = io;
int ccc = bombs[i].x, ddd = bombs[i].y;
if(!ccc && !ddd) continue;
if(ccc < maxn - 1) {
maps[ccc][ddd] = ' ';
ccc ++;
bombs[i].x ++;
}
char temps = maps[ccc][ddd];
if(temps == '#' || temps == 'w' || temps == 'o' || temps == 'm' || temps == 'h') {
if(1 == 1) { //bomb_boom(i);
int ccc = bombs[i].x, ddd = bombs[i].y;
cout << "hjk" << " " << i << " " << ccc << " " << ddd << endl;
for(int id = ccc - 1; id <= ccc + 1; id ++) {
for(int jd = ddd - 1; jd <= ddd + 1; jd ++) {
if(maps[id][jd] == '#') continue;
if(maps[id][jd] == 'w') maps[id][jd] = ' ';
if(maps[id][jd] == 'm') {
maps[id][jd] = ' ';
//need_to_put = true;
}
if(maps[id][jd] == 'o' || maps[id][jd] == 'h') {
blood -= 10;
cout << "the blood of the snake has deleted 10!" << endl;
cout << "蛇剩下的血量为:" << blood << endl;
}
}
}
bombs[i].x = 0, bombs[i].y = 0;
}
//return;
}
else
maps[ccc][ddd] = 'b';
}
if(res % 57 == 1) {
while(1) {
int fx = rand() * 18 % maxn, fy = rand() * 18 % maxm;
char temps = maps[fx][fy];
if(temps == 'm' || temps == 'h' || temps == 'o')
continue;
if(fx == 0 || fx == maxn - 1 || fy == 0 || fy == maxm - 1)
continue;
maps[fx][fy] = 'w';
break;
}
}
if(res % 10 == 1) {
int fx, fy;
while(1) {
fx = 1, fy = rand() * 57 % maxm;
if(fy == 0 || fy == maxm - 1)
continue;
if(maps[fx][fy] == 'o') continue;
if(maps[fx][fy] == 'h') continue;
if(maps[fx][fy] == 'w') continue;
if(maps[fx][fy] == 'm') continue;
break;
}
maps[fx][fy] = 'b';
bombs[bombs_num].x = fx;
bombs[bombs_num].y = fy;
bombs_num ++;
}
if(blood <= 0) boom = true;
if(boom) {
cout << "game over" << endl;
cout << str1 << " " << str2 << endl;
cout << "是否为这条蛇续命;按1继续,按2就只能重新开始了";
cout << ",按3重新跳到最初始的输入账户的界面,可以可以更换账户!" << endl;
cin >> u;
if(u == 3) {
bombs_num = 0;
memset(maps, ' ', sizeof(maps));
blood = 100;
speed = 16000000;
head = num; tail = num;
boom = false;
longjmp(jmpbuffer, 1);
}
if(u == 2) {
bombs_num = 0;
memset(maps, ' ', sizeof(maps));
num = 0;
blood = 100;
node[++ num].next = -1;
node[num].x = 5;
node[num].y = 6;
speed = 16000000;
head = num; tail = num;
maps[5][6] = 'h';
if(1 == 1) { //puts_one();
while(1) {
aaa = 1, bbb = rand() * 37 % maxm;
if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
continue;
if(maps[aaa][bbb] == 'o') continue;
if(maps[aaa][bbb] == 'h') continue;
if(maps[aaa][bbb] == 'w') continue;
maps[aaa][bbb] = 'm';
break;
}
need_to_put = false;
}
if(1 == 1) { //outs();
for(int i = 0; i < maxn; i ++) {
for(int j = 0; j < maxm; j ++) {
if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
maps[i][j] = '#';
cout << maps[i][j];
continue;
}
cout << maps[i][j];
}
cout << endl;
}
}
boom = false;
}
else if(u == 1) {
int uu;
while(1) {
cout << "请输入充血量值的点数:";
cin >> u;
while(u > kk[str1].money) {
cout << "余额不足哎" << endl;
cout << "接下来按1准备向账户充值,2是刚才充值的血量点数" << endl;
cin >> u;
if(u == 1) {
cout << "请输入向账户增加的值数" << endl;
int uu;
cin >> uu;
kk[str1].money += uu;
kkk[str1].push_back({oper2, uu, kk[str1].money});
u = 2;
}
if(u == 2) {
cout << "请输入向蛇增加的值数" << endl;
cin >> u;
if(u > kk[str1].money) continue;
else
break;
}
}
cout << "蛇的血量重新变为:" << " " << u << endl;
kk[str1].money -= u;
blood = u;
boom = false;
kkk[str1].push_back({oper1, u, kk[str1].money});
cout << "账户" << str1 << "的花费记录" << endl;
for(int i = 0; i < kkk[str1].size(); i ++) {
cout << i + 1 << " " << kkk[str1][i].operations << kkk[str1][i].changes;
cout << "这个时候账户余额为:" << kkk[str1][i].moneys << endl;
}
cout << "按1继续" << endl;
cin >> nothing;
break;
}
}
}
else { // outss();
for(int i = 0; i < maxn; i ++) {
for(int j = 0; j < maxm; j ++) {
if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
maps[i][j] = '#';
cout << maps[i][j];
continue;
}
cout << maps[i][j];
}
cout << endl;
}
}
if(need_to_put) { //puts_one();
while(1) {
aaa = 1, bbb = rand() * 37 % maxm;
if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
continue;
if(maps[aaa][bbb] == 'o') continue;
if(maps[aaa][bbb] == 'h') continue;
if(maps[aaa][bbb] == 'w') continue;
maps[aaa][bbb] = 'm';
break;
}
need_to_put = false;
}
}
}
}
}
}
}
return 0;
}