/* *函数名称:DoMsg(int x, int y, int action) *函数介绍:用户消息响应函数 *输入参数:(x,y)棋盘位置 action 动作 0鼠标经过 1鼠标左键 *输出参数:无 *返回值 :无 */ bool Managers::DoMsg(int x, int y, int action) { if(PAUSE) return false; if(Game_State<0 || Game_State>1) return false; if(action==1 && (Game_State==PlayerAc || !Game_Type)) { if(PointCh==NULL) { if(map[x][y]-1==Game_State) { PointCh=Search(x,y); return true; } else return false; } else if((PointCh->color && Game_State==1) ||(!PointCh->color && Game_State==0)) { if(PointCh->x==x && PointCh->y==y) { PointCh=NULL; return true; }else if(Moveto(PointCh,x,y,true)) { Updata(); return true; } else if(map[x][y]==Game_State+1) { PointCh=Search(x,y); return true; } else { PointCh=NULL; return false; } } else { PointCh=NULL; return false; } } else if(action==0 && (Game_State==PlayerAc || !Game_Type)) { if(PointCh!=NULL) { if(Moveto(PointCh,x,y,false)) { return true; //在(x,y)处高亮显示 } } } return false; }
void read_and_draw() { char lineSize[10]; char *token; int count=0; FILE *fp; fp=fopen("./input.txt","r"); if(fp!=NULL) { while(fgets(lineSize,10,fp)) { printf("hole line=%s",lineSize); token = strtok(lineSize," "); printf("getx=%s\n",token); int x=atoi(token); printf("x=%d\n",x); token = strtok(NULL,"\n"); printf("gety=%s\n",token); int y=atoi(token); printf("y=%d\n",y); Moveto(x); if(abs(x)<=abs(y)) { Delay(32*(abs(y)-abs(x))); } count++; printf("count=%d\n",count); } } }
//判断将军 bool Managers::Check(bool color) { int i; if(color) { for(i=16;i<31;i++) if(nChessinfo[i].type<=7 && Moveto(nChessinfo+i,nChessinfo[15].x,nChessinfo[15].y,false)) return true; } else { for(i=0;i<15;i++) if(nChessinfo[i].type<=7 && Moveto(nChessinfo+i,nChessinfo[31].x,nChessinfo[31].y,false)) return true; } return false; }
void pad_init() { Moveto(-65); Delay(500); }