0
加入了:僵尸、剑、苹果、血量与饱食度机制
c++11可用
最好不要连续按住移动键,否则会较卡(1秒内不输入自动跳过)
详细玩法说明和代码如下(开局提问输入yes才能用指令)
一天为2000刻
玩家:
hp:100
饱食度:20(饱食度高于18时立即恢复5hp并扣除1饱食度,高于15时1/5概率立即恢复5hp并扣除1饱食度,每400刻扣除1饱食度,超出上限的饱食度自动转化为5血量)
**亡不会掉落物品
碰到方块自动挖掘
周围有僵尸且手中有剑自动攻击
在开局提问中输入yes即可使用指令
方块: 硬度: 需要挖掘等级:
W(wood) 4 >=0
H(stone) 5 >=1
C(coal) 8 >=2
I(iron) 15 >=2
G(gold) 30 >=2
D(diamond)40 >=2
=(宝箱) 挖不掉 需要先触碰钥匙才能打开
-(钥匙) 挖不掉
食物: 饱食度:获取方式:
apple 2 木头(w)有25%概率掉落
生物:
僵尸 hp:100,攻击范围:四个方向,伤害:20
操作:
wasd 移动 撞到方块自动挖掘
1 吃食物(需要输入食物名称)
e 查看背包(再按任意键退出)
q 丢弃物品
格式:q换行s x
(s:丢弃物品名称,x:丢弃数量)(x=-1表示全部丢弃 x>物品数量默认全部丢弃)
+ 合成物品
格式:+换行s
(s:合成物品名称)
目前可合成物品:
稿子类
名称: 需要: 挖掘等级 耐久 挖掘量
wood_pickaxe wood*5 1 32 1
stone_pickaxe stone*3,wood*2 2 64 2
iron_pickaxe iron*3,wood*2 3 256 3
diamond_pickaxe diamond*3,wood*2 4 1024 4
剑类
名称 需要: 伤害 耐久
wood_sword wood*3 20 32
stone_sword stone*2,wood*1 25 64
iron_sword iron*2,wood*1 30 256
diamond_sword diamond*2,wood*1 35 1024
护甲类(1护甲值=4%减伤,头盔、胸甲、护腿、靴子分别为helmet、chestplate、leggings、boots)
名称 需要 护甲值 耐久
iron_helmet iron*5 2 256
diamond_helmet diamond*5 3 1024
iron_chestplate iron*8 6 256
diamond_chestplate diamond*8 7 1024
iron_leggings iron*6 5 256
diamond_leggings diamond*6 6 1024
iron_boots iron*4 2 256
diamond_boots diamond*4 3 1024
r 切换工具栏(拿的稿子)
注意:每个稿子在合成时会自带独一无二的编号,可以用e查看
格式:r换行s
(s:要换的稿子名称)
/ 作弊指令
传送
(不要传送到x和y接近1或5000的地方,会产生严重的bug)
格式:/换行tp换行x y
(x,y表示传送坐标)
获取
(give指令能够获取几乎任意名字的非法物品,不要随便用)
获取物品 格式:/换行give换行s换行x
(s表示物品名称,x表示想要的数量)
获取稿子 格式:/换行give换行s换行a b c
(s表示稿子名称,a,b,c分别表示挖掘等级/耐久/挖掘量)
时间
(1~1000为白天,1000以上是黑夜,2000以上自动跳到白天)
格式:/换行time换行t
(t表示时间)
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<stack>
#include<map>
#include<queue>
#include<windows.h>
#include<conio.h>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include <chrono>
using namespace std;
struct allnode{
int n0,n1,n2,n3,n4;
};
/*
0属**(0 物品,1 稿子,2剑,3头盔,4胸甲,5护腿,6靴子,7食物)
物品:1数量
工具:1数量,2等级,3耐久,4挖掘量,5效率附魔,6时运附魔
剑:1数量,2伤害,3耐久
头盔:1数量,2护甲值,3耐久
食物:1数量,2饱食度
*/
struct node_start{
int tx,ty,way;
};
struct node_dir{
int dx,dy;
bool operator < (const node_dir &b) const{
if(dx!=b.dx){
return dx<b.dx;
}
return dy>b.dy;
}
};
char a[5200][5200];//地图
int cnt[5200][5200];//挖掘状态
int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}},dir2[8][2]={{1,0},{0,1},{-1,0},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}},x,y;
int lx,ly,rx,ry;
int monster_sum;//怪物生成上限
char wmp;
int movepos;//生物移动标记数值
bool vis[5200][5200],vistart[5200][5200],viscase[5200][5200],opencase[5200][5200];
// 宝箱是否找到钥匙 宝箱是否打开
int vismove[5200][5200],movelast[5200][5200];//生物移动标记数组
node_dir findkey[5200][5200];//对应宝箱/钥匙坐标
stack<node_start> s;
queue<node_dir> q;
map<string,allnode> back;//背包
string use,fight,helmet,chestplate,leggings,boots;//工具栏 武器栏
string usename;
int pos;//工具数量(拼接字符串) 工具编号(打表)
string cl[201]={"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98","99","100","101","102","103","104","105","106","107","108","109","110","111","112","113","114","115","116","117","118","119","120","121","122","123","124","125","126","127","128","129","130","131","132","133","134","135","136","137","138","139","140","141","142","143","144","145","146","147","148","149","150","151","152","153","154","155","156","157","158","159","160","161","162","163","164","165","166","167","168","169","170","171","172","173","174","175","176","177","178","179","180","181","182","183","184","185","186","187","188","189","190","191","192","193","194","195","196","197","198","199","200"};
int hp,hu;//生命 饱食度
vector<node_dir> zombie0;//僵尸列表(未激活)
vector<node_dir> zombie1;//僵尸列表(已激活)
map<node_dir,bool> zombie;//是否有僵尸
double st[5200][5200];//实体列表
int times;//时间
void start(int len,int cx,int cy){//生成地图函数
int x,y,w,k,nx,ny;
srand((unsigned int)time(NULL));
// 初始化
s.push({cx,cy,-1});
vis[cx][cy]=true;
a[cx][cy]=' ';
int step=0;
int max_step=len; // 控制线条总长度
while(!s.empty() && step<max_step){
node_start u=s.top();
x=u.tx;
y=u.ty;
w=u.way;
//寻找一个未访问的方向
bool found=false;
int tmp=0;
// 随机尝试序列
int dirs[4]={0,1,2,3};
for(int i=0;i<4;i++){
int r=rand()%4;
swap(dirs[i],dirs[r]);
}
for(int i=0;i<4;i++){
k=dirs[i];
// 避免直接回头
if(w!=-1 && k==(w+2)%4) continue;
nx=x+dir[k][0];
ny=y+dir[k][1];
if(nx>1 && nx<5000 && ny>1 && ny<5000 && !vis[nx][ny]){
vis[nx][ny]=true;
a[nx][ny]=' ';
s.push({nx,ny,k}); //下一步将继续从新节点延申
found=true;
step++;
break;
}
}
if(!found){
s.pop();
}
}
}
void start_ore(char p,int step,int sx,int sy,int cntp){//生成矿物函数
while(!q.empty()) q.pop();
a[sx][sy]=p;
q.push({sx,sy});
int nx,ny;
while(!q.empty()){
if(step<=0) return ;
node_dir h=q.front();
q.pop();
int dirs[4]={0,1,2,3};
for(int i=0;i<4;i++){
int r=rand()%4;
swap(dirs[i],dirs[r]);
}
for(int i=0;i<4;i++){
if(step<=0) return ;
int k=dirs[i];
nx=h.dx+dir[k][0];
ny=h.dy+dir[k][1];
if(nx>1 && nx<5000 && ny>1 && ny<5000 && (a[nx][ny]==' ' || a[nx][ny]=='H')){
a[nx][ny]=p;
cnt[nx][ny]=cntp;
step--;
if(step<=0) return ;
q.push({nx,ny});
}
}
}
//if(rand()%100) cout<<count<<endl;
}
int move_step(int sx,int sy,int ex,int ey){//怪物寻路函数
if(abs(ex-sx)<=1 && abs(ey-sy)<=1) return 5;
while(!q.empty()) q.pop();
movepos++;
q.push({sx,sy});
vismove[sx][sy]=movepos;
movelast[sx][sy]=-1;
bool found=false;
while(!q.empty()){
node_dir h=q.front();
q.pop();
for(int i=0;i<4;i++){
int nx=h.dx+dir[i][0];
int ny=h.dy+dir[i][1];
if(nx>0 && ny>0 && nx<5000 && ny<5000 && a[nx][ny]==' ' && st[nx][ny]==0 && vismove[nx][ny]!=movepos){
vismove[nx][ny]=movepos;
movelast[nx][ny]=i;
if(nx==ex&&ny==ey){
found=true;
break;
}
q.push({nx,ny});
}
}
if(found) break;
}
if(!found) return -1;
int nx=ex;
int ny=ey;
while(nx!=sx || ny!=sy){
int idx=movelast[nx][ny];
nx-=dir[idx][0];
ny-=dir[idx][1];
if(nx==sx && ny==sy){
return idx;
}
}
}
void hp__(int h){
h*=(1-(back[helmet].n2+back[chestplate].n2+back[leggings].n2+back[boots].n2)*0.04);
back[helmet].n3--;
if(back[helmet].n3<=0){
back[helmet].n1=0;
helmet="";
}
back[chestplate].n3--;
if(back[chestplate].n3<=0){
back[chestplate].n1=0;
chestplate="";
}
back[leggings].n3--;
if(back[leggings].n3<=0){
back[leggings].n1=0;
leggings="";
}
back[boots].n3--;
if(back[boots].n3<=0){
back[boots].n1=0;
boots="";
}
hp-=h;
}
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
void setColor(int color) {
SetConsoleTextAttribute(hOut, color);
}
void Clear(){
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(),'\n');
}
int main(){
string skey;
int zhiling;
cout<<"do you want tu use '/' ?\n(yes/no)\n";
cin>>skey;
if(skey=="yes") zhiling=1;
for(int i=1;i<=5200;i++){
for(int j=1;j<=5200;j++) {
a[i][j]='H';
vis[i][j]=false;
}
}
//初始化
cout<<"start1……\n";
start(5000,2500,2500);
start(5000,2450,2550);
start(5000,2550,2450);
for(int i=1;i<=5000;i++){
for(int j=1;j<=5000;j++){
if(a[i][j]==' ' && rand()%200==0 || rand()%1500==0){
vistart[i][j]=true;
start(rand()%100+1,i,j);
}
}
}
cout<<"start2……\n";
for(int i=1;i<=5000;i++){//生成地形
for(int j=1;j<=5000;j++){
if(vistart[i][j]){
start(rand()%600+1,i,j);
}
cnt[i][j]=5;
}
}
cout<<"start3……\n";
for(int i=1;i<=5000;i++){//生成矿物
for(int j=1;j<=5000;j++){
if(rand()%120==0 && i>10 && i<4990 && j>10 && j<4990){
if(rand()%2){for(int k=i;k<=i+rand()%5+5;k++){a[k][j]='W';cnt[k][j]=4;}}
else{for(int k=j;k<=j+rand()%5+5;k++){a[i][k]='W';cnt[i][k]=4;}}
}else if(rand()%500==0){
a[i][j]='C';
start_ore('C',rand()%8+4,i,j,8);
}else if(rand()%600==0){
a[i][j]='I';
start_ore('I',rand()%8+2,i,j,15);
}else if(rand()%4000==0){
a[i][j]='G';
start_ore('G',rand()%8+1,i,j,30);
}else if(rand()%10000==0){
a[i][j]='D';
start_ore('D',rand()%4+1,i,j,40);
}
}
}
int kx,ky;
for(int i=1;i<=5000;i++){//生成宝箱
for(int j=1;j<=5000;j++){
if(rand()%15000<=2){
a[i][j]='=';
a[i-1][j]='H';
a[i+1][j]='H';
a[i][j-1]='H';
a[i][j+1]='H';
a[i-1][j-1]='H';
a[i-1][j+1]='H';
a[i+1][j-1]='H';
a[i+1][j+1]='H';
while(true){
kx=i+rand()%5*(0-rand()%2);
ky=j+rand()%5*(0-rand()%2);
if(kx>0&&ky>0&&kx<=5000&&ky<=5000 && a[kx][ky]!='=' && a[kx][ky]!='-'){
break;
}
}
a[kx][ky]='-';
viscase[i][j]=false;
findkey[i][j]={kx,ky};
findkey[kx][ky]={i,j};
cnt[i][j]=0x3f3f3f3f;
//cout<<i<<" "<<j<<endl;
}
}
}
system("cls");
for(int i=2470;i<=2530;i++){//地图查看器
for(int j=2450;j<=2550;j++){
if(a[i][j]=='C'){//输出分支3:煤矿(C)
setColor(FOREGROUND_INTENSITY);
cout<<a[i][j];
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}else if(a[i][j]=='I'){//输出分支4:铁矿(I)
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
cout<<a[i][j];
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}else if(a[i][j]=='G'){//输出分支5:金矿(G)
setColor(FOREGROUND_RED | FOREGROUND_GREEN);
cout<<a[i][j];
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}else if(a[i][j]=='D'){//输出分支6:钻石矿(D)
setColor(FOREGROUND_BLUE | FOREGROUND_INTENSITY);
cout<<a[i][j];
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}else if(a[i][j]=='W'){//输出分支7:木头(W)
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
cout<<a[i][j];
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}else if(a[i][j]=='='){//输出分支8:宝箱(=)
setColor(FOREGROUND_BLUE | FOREGROUND_GREEN);
cout<<a[i][j];
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}else{
cout<<a[i][j];
}
}
cout<<endl;
}
Sleep(5000);
system("cls");
map<char,node_dir> m;
m['w']={-1,0};
m['s']={1,0};
m['a']={0,-1};
m['d']={0,1};
x=2500,y=2500;//移动初始化
int fx,fy;
use="gunmu";
back["gunmu"].n0=0x3f3f3f3f;
back["gunmu"].n1=1;
back["gunmu"].n2=0;
back["gunmu"].n3=0x3f3f3f3f;
back["gunmu"].n4=1;
hp=100;
hu=20;
while(true){
system("cls");
times++;
if(times>2000){
times=0;
}
cout<<"当前位置 : "<<x<<","<<y<<endl;
cout<<"时间 :";
if(times<=1000) cout<<"白天"<<times<<endl;
else cout<<"黑夜"<<times<<endl;
lx=x-8;
rx=x+8;
ly=y-16;
ry=y+16;
if(times>1000){//生成僵尸
int monster_cnt=0;
int monster_cntmax=0;
while(monster_cnt<=3 && monster_cntmax<=30 && monster_sum<=300){
int tx=rand()%257-128;
int ty=rand()%257-128;
tx=x+tx;
ty=y+ty;
if(tx>0 && tx<5000 && ty>0 && ty<5000 && (abs(tx-x)>10 || abs(ty-y)>10) && a[tx][ty]==' ' && st[tx][ty]==0){
zombie0.push_back({tx,ty});
st[tx][ty]=100;
zombie[{tx,ty}]=1;
monster_cnt++;
monster_sum++;
cout<<"zombie:"<<tx<<","<<ty<<endl;
}
monster_cntmax++;
}
}
for(int i=0;i<zombie0.size();i++){//正常僵尸移动
if(sqrt((zombie0[i].dx-x)*(zombie0[i].dx-x)+(zombie0[i].dy-y)*(zombie0[i].dy-y))>=128){
st[zombie0[i].dx][zombie0[i].dy]=0;
zombie[{zombie0[i].dx,zombie0[i].dy}]=0;
zombie0.erase(zombie0.begin()+i);
i--;
monster_sum--;
break;
}
if(st[zombie0[i].dx][zombie0[i].dy]<=0){
st[zombie0[i].dx][zombie0[i].dy]=0;
zombie[{zombie0[i].dx,zombie0[i].dy}]=0;
zombie0.erase(zombie0.begin()+i);
cout<<"you kill the zombie in "<<zombie0[i].dx<<","<<zombie0[i].dy<<endl;
i--;
monster_sum--;
break;
}
int dirs[4]={0,1,2,3};
for(int j=0;j<=3;j++){
swap(dirs[j],dirs[rand()%4]);
}
int nx,ny;
for(int j=0;j<=3;j++){
int k=dirs[j];
nx=zombie0[i].dx+dir[k][0];
ny=zombie0[i].dy+dir[k][1];
if(a[nx][ny]==' ' && st[nx][ny]==0 && (x!=nx || y!=ny)){
st[nx][ny]=st[zombie0[i].dx][zombie0[i].dy];
st[zombie0[i].dx][zombie0[i].dy]=0;
zombie[{zombie0[i].dx,zombie0[i].dy}]=0;
zombie[{nx,ny}]=1;
zombie0[i].dx=nx;
zombie0[i].dy=ny;
break;
}
}
}
for(int i=0;i<zombie0.size();i++){//判断僵尸被激怒
int nx=zombie0[i].dx;
int ny=zombie0[i].dy;
if(sqrt((nx-x)*(nx-x)+(ny-y)*(ny-y))<=4){
cout<<"zombie in "<<nx<<","<<ny<<" is angry!\n";
zombie1.push_back({nx,ny});
zombie0.erase(zombie0.begin()+i);
i--;
}
}
for(int i=0;i<zombie1.size();i++){
if(times%5==0) continue;
if(st[zombie1[i].dx][zombie1[i].dy]<=0){
st[zombie1[i].dx][zombie1[i].dy]=0;
zombie[{zombie1[i].dx,zombie1[i].dy}]=0;
zombie1.erase(zombie1.begin()+i);
cout<<"you kill the zombie in "<<zombie1[i].dx<<","<<zombie1[i].dy<<endl;
i--;
monster_sum--;
break;
}
int k=move_step(zombie1[i].dx,zombie1[i].dy,x,y);
if(k==-1 || abs(zombie1[i].dx-x)>=5 && abs(zombie1[i].dx-x)>=5){
zombie0.push_back({zombie1[i].dx,zombie1[i].dy});
zombie1.erase(zombie1.begin()+i);
i--;
}else if(k==5){
hp__(20);
continue;
}else{
st[zombie1[i].dx+dir[k][0]][zombie1[i].dy+dir[k][1]]=st[zombie1[i].dx][zombie1[i].dy];
st[zombie1[i].dx][zombie1[i].dy]=0;
zombie[{zombie1[i].dx,zombie1[i].dy}]=0;
zombie1[i].dx+=dir[k][0];
zombie1[i].dy+=dir[k][1];
zombie[{zombie1[i].dx,zombie1[i].dy}]=1;
}
}
for(int i=lx;i<=rx;i++){
for(int j=ly;j<=ry;j++){
if(i==x && j==y){//输出分支1:玩家(Y)
setColor(FOREGROUND_RED | FOREGROUND_INTENSITY);
cout<<'Y';
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
continue;
}else if(a[i][j]=='H'){//输出分支2:墙壁(H)
if(cnt[i][j]==5){
cout<<a[i][j];
}else if(cnt[i][j]>=3){
setColor(FOREGROUND_INTENSITY);
cout<<a[i][j];
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}else{
setColor(FOREGROUND_RED | FOREGROUND_BLUE);
cout<<a[i][j];
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}
}else if(a[i][j]=='C'){//输出分支3:煤矿(C)
setColor(FOREGROUND_INTENSITY);
cout<<a[i][j];
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}else if(a[i][j]=='I'){//输出分支4:铁矿(I)
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
cout<<a[i][j];
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}else if(a[i][j]=='G'){//输出分支5:金矿(G)
setColor(FOREGROUND_RED | FOREGROUND_GREEN);
cout<<a[i][j];
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}else if(a[i][j]=='D'){//输出分支6:钻石矿(D)
setColor(FOREGROUND_BLUE | FOREGROUND_INTENSITY);
cout<<a[i][j];
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}else if(a[i][j]=='W'){//输出分支7:木头(W)
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
cout<<a[i][j];
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}else if(a[i][j]=='='){//输出分支8:宝箱(=)
setColor(FOREGROUND_BLUE | FOREGROUND_GREEN);
cout<<a[i][j];
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}else if(zombie[{i,j}]){//输出分支9:僵尸(Z)
setColor(FOREGROUND_GREEN);
cout<<'Z';
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}else{
cout<<a[i][j];
}
//正常输出内容
}
cout<<endl;
}//输出地图
if(hp<=0){
setColor(FOREGROUND_RED);
cout<<"you died!";
Sleep(3000);
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
while(_kbhit()){
_getch();
}
hp=100;
hu=20;
x=2500;
y=2500;
continue;
}
if(hp==0){
setColor(FOREGROUND_RED);
cout<<"you did!";
cin>>wmp;
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
continue;
}
int armor=back[helmet].n2+back[chestplate].n2+back[leggings].n2+back[boots].n2;
setColor(FOREGROUND_BLUE);
for(int i=1;i<=armor;i++){
cout<<"#";
}
cout<<armor<<endl;
if((hu>=18 || hu>=15 && rand()%5==0) && hp<100){hp=min(hp+5,100);hu--;}
setColor(FOREGROUND_RED | FOREGROUND_GREEN);
if(times%400==0){hu--;}
for(int i=1;i<=hu;i++){
cout<<"&";
}
cout<<hu<<endl;
int heart=ceil(hp/5.0);
setColor(FOREGROUND_RED);
for(int i=1;i<=heart;i++){
cout<<"■";
}
cout<<hp;
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
cout<<endl;
//cin>>wmp;//原来的低效输入
auto start_time=std::chrono::steady_clock::now();
auto now_time=std::chrono::steady_clock::now();
long long pass=0;
while(true){
if(_kbhit()){
wmp=_getch();
break;
}
now_time=std::chrono::steady_clock::now();
pass=std::chrono::duration_cast<std::chrono::milliseconds>(now_time-start_time).count();
if(pass>=1000){
wmp='{';
break;
}
}
if(wmp=='w' || wmp=='a' || wmp=='s' || wmp=='d'){
fx=x+m[wmp].dx;
fy=y+m[wmp].dy;
if(a[fx][fy]==' ' && st[fx][fy]==0){//输入分支1:移动
x=fx;
y=fy;
}else if(a[fx][fy]=='W' || a[fx][fy]=='H' || a[fx][fy]=='C' || a[fx][fy]=='I' || a[fx][fy]=='G' || a[fx][fy]=='D'){//输入分支2:挖掘
cnt[fx][fy]-=back[use].n4;
if(cnt[fx][fy]<=0){
back[use].n3--;
if(back[use].n3<=0){
cout<<"durability exhausted!";
Sleep(1000);
back[use].n1=0;
back[use].n2=0;
back[use].n3=0;
back[use].n4=0;
use="gunmu";
}
if(a[fx][fy]=='W'){
back["wood"].n0=0;
back["wood"].n1++;
if(rand()%5==0){
back["apple"].n0=7;
back["apple"].n1++;
back["apple"].n2=2;
}
}
if(a[fx][fy]=='H' && back[use].n2>0){
back["stone"].n0=0;
back["stone"].n1++;
}
if(a[fx][fy]=='C' && back[use].n2>1){
back["coal"].n0=0;
back["coal"].n1++;
}
if(a[fx][fy]=='I' && back[use].n2>1){
back["iron"].n0=0;
back["iron"].n1++;
}
if(a[fx][fy]=='G' && back[use].n2>2){
back["gold"].n0=0;
back["gold"].n1++;
}
if(a[fx][fy]=='D' && back[use].n2>2){
back["diamond"].n0=0;
back["diamond"].n1++;
}
a[fx][fy]=' ';
}
//cout<<"you dig"<<"("<<fx<<","<<fy<<")"<<endl;
//Sleep(3000);
}else if(a[fx][fy]=='='){//输入分支3:宝箱
if(opencase[fx][fy]==true){
cout<<"this case has already been opened\n";
Sleep(1000);
}else{
if(viscase[fx][fy]==true){
opencase[fx][fy]=true;
cout<<"you open the case!\n";
Sleep(500);
if(rand()%4<=3){
int k=rand()%10+1;
cout<<"you get "<<k<<" wood\n";
back["wood"].n1+=k;
}
if(rand()%3<=2){
int k=rand()%10+1;
cout<<"you get "<<k<<" stone\n";
back["stone"].n1+=k;
}
if(rand()%3<=2){
int k=rand()%10+1;
cout<<"you get "<<k<<" iron\n";
back["iron"].n1+=k;
}
if(rand()%3<=2){
int k=rand()%10+1;
cout<<"you get "<<k<<" gold\n";
back["gold"].n1+=k;
}
if(rand()%9==0){
int k=rand()%10+1;
cout<<"you get "<<k<<" diamond\n";
back["diamond"].n1+=k;
}
Sleep(1000);
}else{
cout<<"the key is in"<<"("<<findkey[fx][fy].dx<<","<<findkey[fx][fy].dy<<")"<<endl;
Sleep(500);
}
}
}else if(a[fx][fy]=='-'){//输入分支4:钥匙
cout<<"you get the key to the case which is in"<<"("<<findkey[fx][fy].dx<<","<<findkey[fx][fy].dy<<")"<<endl;
Sleep(500);
viscase[findkey[fx][fy].dx][findkey[fx][fy].dy]=true;
}
for(int i=0;i<8;i++){
int nx=x+dir2[i][0];
int ny=y+dir2[i][1];
if(st[nx][ny]!=0){
st[nx][ny]-=back[fight].n2;
back[fight].n3--;
if(back[fight].n3==0){
back[fight].n1=0;
fight="";
}
}
}
}else if(wmp=='e'){//输入分支5:查看
for(map<string,allnode>::iterator it=back.begin();it!=back.end();it++){
if(it->second.n1==0){
continue;
}
if(it->second.n0==0 || it->second.n0==7){
cout<<it->first<<" "<<it->second.n1<<endl;
}else if(it->second.n0==1){
if(use==it->first){
setColor(FOREGROUND_RED | FOREGROUND_GREEN);
}
cout<<it->first;
cout<<" naijiu:"<<it->second.n3<<endl;
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}else if(it->second.n0==2){
if(fight==it->first){
setColor(FOREGROUND_RED);
}
cout<<it->first;
cout<<" shanghai:"<<it->second.n2<<" ";
cout<<" naijiu:"<<it->second.n3<<endl;
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}else if(it->second.n0==3 || it->second.n0==4 || it->second.n0==5 || it->second.n0==6){
if(helmet==it->first || chestplate==it->first || leggings==it->first || boots==it->first){
setColor(FOREGROUND_BLUE);
}
cout<<it->first;
cout<<" hujia:"<<it->second.n2<<" ";
cout<<" naijiu:"<<it->second.n3<<endl;
setColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}
}
int tmp;
cin>>tmp;
}else if(wmp=='q'){//输入分支6:丢弃
string s;
int t;
cin>>s>>t;
if(t==-1){
back[s].n0=0;
back[s].n1=0;
back[s].n2=0;
back[s].n3=0;
back[s].n4=0;
}else{
back[s].n1=max(back[s].n1-t,0);
}
}else if(wmp=='+'){//输入分支7:合成
string s;
Clear();
cin>>s;
if(s=="wood_pickaxe"){
cout<<1;
if(back["wood"].n1>=5){
pos++;
back["wood"].n1-=5;
back["wood_pickaxe"+cl[pos]]={1,1,1,32,1};
use="wood_pickaxe"+cl[pos];
}else{
cout<<"you don't have enouth thing";
}
}else if(s=="stone_pickaxe"){
if(back["stone"].n1>=3 && back["wood"].n1>=2){
pos++;
back["stone"].n1-=3;
back["wood"].n1-=2;
back["stone_pickaxe"+cl[pos]]={1,1,2,64,2};
use="stone_pickaxe"+cl[pos];
}else{
cout<<"you don't have enouth thing";
}
}else if(s=="iron_pickaxe"){
if(back["iron"].n1>=3 && back["wood"].n1>=2){
pos++;
back["iron"].n1-=3;
back["wood"].n1-=2;
back["iron_pickaxe"+cl[pos]]={1,1,3,256,3};
use="iron_pickaxe"+cl[pos];
}else{
cout<<"you don't have enouth thing";
}
}else if(s=="diamond_pickaxe"){
if(back["diamond"].n1>=3 && back["wood"].n1>=2){
pos++;
back["diamond"].n1-=3;
back["wood"].n1-=2;
back["diamond_pickaxe"+cl[pos]]={1,1,4,1024,4};
use="diamond_pickaxe"+cl[pos];
}else{
cout<<"you don't have enouth thing";
}
}else if(s=="wood_sword"){
if(back["wood"].n1>=3){
pos++;
back["wood"].n1-=3;
back["wood_sword"+cl[pos]]={2,1,20,32,0};
fight="wood_sword"+cl[pos];
}else{
cout<<"you don't have enouth thing";
}
}else if(s=="stone_sword"){
if(back["stone"].n1>=3 && back["wood"].n1>=1){
pos++;
back["stone"].n1-=3;
back["wood"].n1-=1;
back["stone_sword"+cl[pos]]={2,1,25,64,0};
fight="stone_sword"+cl[pos];
}
else{
cout<<"you don't have enouth thing";
}
}else if(s=="iron_sword"){
if(back["iron"].n1>=3 && back["wood"].n1>=1){
pos++;
back["iron"].n1-=3;
back["wood"].n1-=1;
back["iron_sword"+cl[pos]]={2,1,30,256,0};
fight="iron_sword"+cl[pos];
}else{
cout<<"you don't have enouth thing";
}
}else if(s=="diamond_sword"){
if(back["diamond"].n1>=3 && back["wood"].n1>=1){
pos++;
back["diamond"].n1-=3;
back["wood"].n1-=1;
back["diamond_sword"+cl[pos]]={2,1,35,1024,0};
fight="diamond_sword"+cl[pos];
}else{
cout<<"you don't have enouth thing";
}
}else if(s=="iron_helmet"){
if(back["iron"].n1>=5){
pos++;
back["iron"].n1-=5;
back["iron_helmet"+cl[pos]]={3,1,2,256,0};
helmet="iron_helmet"+cl[pos];
}
}else if(s=="diamond_helmet"){
if(back["diamond"].n1>=5){
pos++;
back["diamond"].n1-=5;
back["diamond_helmet"+cl[pos]]={3,1,3,1024,0};
helmet="diamond_helmet"+cl[pos];
}
}else if(s=="iron_chestplate"){
if(back["iron"].n1>=8){
pos++;
back["iron"].n1-=8;
back["iron_chestplate"+cl[pos]]={4,1,6,256,0};
chestplate="iron_chestplate"+cl[pos];
}
}else if(s=="diamond_chestplate"){
if(back["diamond"].n1>=8){
pos++;
back["diamond"].n1-=8;
back["diamond_chestplate"+cl[pos]]={4,1,8,1024,0};
chestplate="diamond_chestplate"+cl[pos];
}
}else if(s=="iron_leggings"){
if(back["iron"].n1>=6){
pos++;
back["iron"].n1-=6;
back["iron_leggings"+cl[pos]]={5,1,5,256,0};
leggings="iron_leggings"+cl[pos];
}
}else if(s=="diamond_leggings"){
if(back["diamond"].n1>=6){
pos++;
back["diamond"].n1-=6;
back["diamond_leggings"+cl[pos]]={5,1,6,1024,0};
leggings="diamond_leggings"+cl[pos];
}
}else if(s=="iron_boots"){
if(back["iron"].n1>=4){
pos++;
back["iron"].n1-=4;
back["iron_boots"+cl[pos]]={6,1,2,256,0};
boots="iron_boots"+cl[pos];
}
}
else if(s=="diamond_boots"){
if(back["diamond"].n1>=4){
pos++;
back["diamond"].n1-=4;
back["diamond_boots"+cl[pos]]={6,1,3,1024,0};
boots="diamond_boots"+cl[pos];
}
}
Sleep(500);
cout<<endl;
}else if(wmp=='r'){//输入分支8:切换
string s;
Clear();
cin>>s;
if(back[s].n1==0){
cout<<"there isn't this thing";
Sleep(1000);
continue;
}
if(s.find("pickaxe")!=-1){
use=s;
}else if(s.find("sword")!=-1){
fight=s;
}else if(s.find("helmet")!=-1){
helmet=s;
}else if(s.find("chestplate")!=-1){
chestplate=s;
}else if(s.find("boots")!=-1){
boots=s;
}
}else if(wmp=='/' && zhiling){//输入分支9:指令
string s;
Clear();
cin>>s;
if(s=="tp"){
int fx,fy;
cin>>fx>>fy;
a[fx][fy]=' ';
x=fx;
y=fy;
}else if(s=="give"){
cin>>s;
int t1,t2,t3,t4;
if(s.find("pickaxe")!=-1){
pos++;
s=s+cl[pos];
Clear();
cin>>t2>>t3>>t4;
back[s]={1,1,t2,t3,t4};
use=s;
}else if(s.find("sword")!=-1){
pos++;
s=s+cl[pos];
Clear();
cin>>t2>>t3;
back[s]={2,1,t2,t3,0};
fight=s;
}else if(s.find("helmet")!=-1){
pos++;
s=s+cl[pos];
Clear();
cin>>t2>>t3;
back[s]={3,1,t2,t3,0};
helmet=s;
}else if(s.find("chestplate")!=-1){
pos++;
s=s+cl[pos];
Clear();
cin>>t2>>t3;
back[s]={3,1,t2,t3,0};
chestplate=s;
}else if(s.find("leggings")!=-1){
pos++;
s=s+cl[pos];
Clear();
cin>>t2>>t3;
back[s]={3,1,t2,t3,0};
leggings=s;
}else if(s.find("boots")!=-1){
pos++;
s=s+cl[pos];
Clear();
cin>>t2>>t3;
back[s]={3,1,t2,t3,0};
boots=s;
}else{
Clear();
cin>>t1;
back[s].n0=0;
back[s].n1+=t1;
}
}else if(s=="time"){
int x;
Clear();
cin>>x;
times=x;
}
}else if(wmp=='1'){//输入分支10:吃东西
string s;
Clear();
cin>>s;
if(back[s].n1>0 && back[s].n0==7){
hu+=back[s].n2;
back[s].n1--;
if(hu>20){
hp=min(hp+(hu-20)*5,100);
hu=20;
}
}else{
cout<<"there isn't this food";
}
}
}
return 0;
}
