Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
修复bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Rratic committed Feb 28, 2021
1 parent 1f3608b commit ff68c67
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cpp11/maze-base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void block::settext(char in){
info=in;
}
bool block::issolid(){
if(id%100==wall||id%100==texts)return true;
if(id/100==wall||id/100==text)return true;
return false;
}
const unsigned short entity::healthcon[]={
Expand Down
2 changes: 2 additions & 0 deletions cpp11/maze-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ enum blocktype{
machine=5,
upstairs=500,
downstairs,
gate_east_west,//-
gate_north_south,//|
portal,
button,
entrance,
Expand Down
21 changes: 15 additions & 6 deletions cpp11/maze-chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ bool chunk::toline(string s,unsigned short line){
return true;
}
bool chunk::canmove(short x,short y,short xx,short yy){
xx+=x;yy+=y;
if(xx<0||yy<0||xx>=l||yy>=w||blocks[xx][yy].issolid()||blocks[x][y].issolid())return false;
x+=xx;y+=yy;
if(x<0||y<0||x>=l||y>=w||blocks[x][y].issolid()\
||(blocks[x][y].id==gate_east_west&&xx!=0)\
||(blocks[x][y].id==gate_north_south&&yy!=0))return false;
return true;
}
bool chunk::workmonsters(entity &i){
Expand Down Expand Up @@ -139,13 +141,19 @@ bool chunk::workmonsters(entity &i){
if(face==4)face=0;
xx=mox[face];
yy=moy[face];
if(j==3)return true;
if(j==3){
blocks[i.x][i.y].id=texts;
blocks[i.x][i.y].info=i.name[pos];
return true;
}
++j;
}
blocks[i.x][i.y].id=texts;
blocks[i.x][i.y].info=i.name[pos];
++pos;
if(pos==i.name.length())return true;
if(pos==i.name.length()){
return true;
}
i.x+=xx;i.y+=yy;
i.memory[0]=pos;
i.memory[1]=face;
Expand Down Expand Up @@ -181,13 +189,13 @@ unsigned short chunk::work(unsigned short &info,string words){
info=0;
return 1;
}
if(blocks[x][y].id/100==wall)continue;
if(blocks[x][y].id/100==wall)goto movemonsters;
if(blocks[x][y].id==money){
++info;
blocks[x][y].id=air;
}
if(blocks[x][y].id==texts){
if(blocks[x+xx][y+yy].id/100!=space)continue;
if(blocks[x+xx][y+yy].id/100!=space)goto movemonsters;
blocks[x+xx][y+yy]=blocks[x][y];
blocks[x][y].id=air;
}
Expand All @@ -198,6 +206,7 @@ unsigned short chunk::work(unsigned short &info,string words){
q quit
e "use"
*/
movemonsters:;
for(vector<entity>::iterator it=monsters.begin();it!=monsters.end();++it){
if(workmonsters(*it)){
monsters.erase(it);
Expand Down

0 comments on commit ff68c67

Please sign in to comment.