鱼C论坛

 找回密码
 立即注册

处女作问世

热度 8已有 1509 次阅读2012-12-27 00:07 |个人分类:DELPHI

(*=======================================================
                      游戏开始
=======================================================*)
procedure Game_Start;
var
  H:HWND;
begin
  h:=FindWindow(nil,'对对碰角色版');
  if H <= 0 then
  begin
//    ShowMessage('窗口句柄为0!');
    Exit;
  end
  else
  begin
    PostMessage(h,WM_LBUTTONDOWN,0,MakeLParam(382,385));
    PostMessage(h,WM_LBUTTONUP,0,MakeLParam(382,385));
  end; 
end;
//--------------------
(*=======================================================
                      更新数组
=======================================================*)
procedure UpdateArray;
var
  h:HWND;
  theaId,Pid:THandle;
  Buffer,tt:DWORD;
const
SitNumBase=$00489e40;
begin
  h:=FindWindow(nil,'对对碰角色版');
  if h <= 0 then Exit;//ShowMessage('窗口句柄为空');
  GetWindowThreadProcessId(h,@theaId);
  Pid:=OpenProcess(PROCESS_ALL_ACCESS,False,theaId);
  if Pid = 0 then
  begin
//      ShowMessage('进程ID为空!');
      Exit;
  end
  else
  begin
  ReadProcessMemory(Pid,Pointer(sitnumbase),@Buffer,4,tt);   //读出几号座位
  ReadProcessMemory(Pid,Pointer(SitBase[Buffer]),@Game_array,200,tt);
  end;
end;
(*=======================================================
                      交换两点
=======================================================*)
procedure SwapPoint(twoX:TPoint;twoy:TPoint);
var
   h:HWND;
//   TwoXy:TwoTPoint;
begin
    h:=FindWindow(nil,'对对碰角色版');
    if h <= 0 then
    begin
//    ShowMessage('窗口句柄为空!');
    exit;
    end
    else
    begin
        PostMessage(h,WM_LBUTTONDOWN,0,MakeLParam(twox.X*48+291,twoX.Y*48+116));
        PostMessage(h,WM_LBUTTONUP,0,MakeLParam(twox.X*48+291,twoX.Y*48+116));
        PostMessage(h,WM_LBUTTONDOWN,0,MakeLParam(twoy.X*48+291,twoy.Y*48+116));
        PostMessage(h,WM_LBUTTONUP,0,MakeLParam(twoy.X*48+291,twoy.Y*48+116));
    end;
end;
(*=======================================================
                      测试相联
=======================================================*)
function TestChess(var Temp_Array:Chess_array):BOOL;
var
  x,y,tt:Byte;
  s:string;
begin
  x:=0;
  y:=0;
  s:='';
  Result :=False;
  while x <= 7 do
  begin
       tt:=1 ;
       while y <= 6 do
       begin
           if Temp_array[x][y] = Temp_array[x][y+1] then
           begin
                tt:=tt+1;
                if tt >= 3 then
                begin
                   { case Temp_Array[x][y] of
                      0:ShowMessage('TEMP_ARRAY为0!');
                      1:ShowMessage(inttostr(x + 1)+'列'+inttostr(y+1)+'行'+'与'+inttostr(y+2)+'行'+'交换  青蛙  1');
                      2:ShowMessage(inttostr(x+1)+'列'+inttostr(y+1)+'行'+'与'+inttostr(y+2)+'行'+'交换 小鸟  2');
                      3:ShowMessage(inttostr(x+1)+'列'+inttostr(y+1)+'行'+'与'+inttostr(y+2)+'行'+'交换 猫   3');
                      4:ShowMessage(inttostr(x+1)+'列'+inttostr(y+1)+'行'+'与'+inttostr(y+2)+'行'+'交换 熊猫  4');
                      5:ShowMessage(inttostr(x+1)+'列'+inttostr(y+1)+'行'+'与'+inttostr(y+2)+'行'+'交换 狐狸  5');
                      6:ShowMessage(inttostr(x+1)+'列'+inttostr(y+1)+'行'+'与'+inttostr(y+2)+'行'+'交换 牛  6');
                      7:ShowMessage(inttostr(x+1)+'列'+inttostr(y+1)+'行'+'与'+inttostr(y+2)+'行'+'交换 猴子  7');
                    end; }
                    Result:=True;
                    EXIT;
                end;
           end
           else
           begin
             tt:=1;
           end; 
           y:=y+1;
       end;
       x:=x + 1;
       y:=0;
  end;
  X:=0;
  Y:=0;
  while y <= 7 do
  begin
       tt:=1 ;
       while x <= 6 do
       begin
           if Temp_array[x][y]=temp_array[x+1][y] then
           begin
                tt:=tt+1;
                if tt >= 3 then
                begin
                   { case Temp_Array[x][y] of
                      0:ShowMessage('TEMP_ARRAY为0!');
                      1:ShowMessage(inttostr(x)+'行'+inttostr(y)+'列'+'与'+inttostr(x+1)+'行'+'交换  青蛙');
                      2:ShowMessage(inttostr(x)+'行'+inttostr(y)+'列'+'与'+inttostr(x+1)+'行'+'交换 小鸟');
                      3:ShowMessage(inttostr(x)+'行'+inttostr(y)+'列'+'与'+inttostr(x+1)+'行'+'交换 猫');
                      4:ShowMessage(inttostr(x)+'行'+inttostr(y)+'列'+'与'+inttostr(x+1)+'行'+'交换 熊猫');
                      5:ShowMessage(inttostr(x)+'行'+inttostr(y)+'列'+'与'+inttostr(x+1)+'行'+'交换 狐狸');
                      6:ShowMessage(inttostr(x)+'行'+inttostr(y)+'列'+'与'+inttostr(x+1)+'行'+'交换 牛');
                      7:ShowMessage(inttostr(x)+'行'+inttostr(y)+'列'+'与'+inttostr(x+1)+'行'+'交换 猴子');
                    end; }
                    Result:=True;
                    Exit;
                end;
           end
           else
           begin
             tt:=1;
           end;
           x:=x+1;
       end;
       y:=y + 1;
       x:=0;
  end;
end;
(*=======================================================
                      实现单消
=======================================================*)
procedure ClearOne;
var
  Temp_array:Chess_array;
  x,y,temp:Byte;
  TwoXy:TwoTPoint;
begin
  x:=0;
  y:=0;
(*
交换两个点,遍历是否有三连,有,鼠标点鸡
*)
//第一步遍历数组
  while x <= 7 do
  begin
      UpdateArray;
      Temp_array:=Game_array;
      while y <= 6 do
      begin
          temp:=temp_array[x][y];
          Temp_array[x][y]:=temp_array[x][y+1];
          Temp_array[x][y+1]:=temp;
//          btn2Click(Sender);
          if (TestChess(Temp_array)) then//判断是否有三连
          begin
              TwoXy[0].X:=x;
              TwoXy[0].Y:=y;
              TwoXy[1].X:=x;
              TwoXy[1].Y:=y+1;
              SwapPoint(twoxy[0],TWOXY[1]);
              Exit; 
          end
          else
          begin  //交换回来
              temp:=temp_array[x][y+1];
              Temp_array[x][y+1]:=temp_array[x][y];
              Temp_array[x][y]:=temp;
          end;
          Y:=Y+1;
      end;
      X:=X+1;
      Y:=0;
  end;
  x:=0;
  y:=0;
  while y <= 7 do
  begin
      UpdateArray;
      Temp_array:=Game_array;
      while x <= 6 do                // X
      begin
          temp:=temp_array[x][y];
          Temp_array[x][y]:=temp_array[x+1][y];
          Temp_array[x+1][y]:=temp;
          if TestChess(Temp_array) then//判断是否有三连
          begin
              TwoXy[0].X:=x;
              TwoXy[0].Y:=y;
              TwoXy[1].X:=x+1;
              TwoXy[1].Y:=y;
              SwapPoint(twoxy[0],TWOXY[1]);
              Exit;
          end
          else
          begin  //交换回来
              temp:=temp_array[x+1][y];
              Temp_array[x+1][y]:=temp_array[x][y];
              Temp_array[x][y]:=temp;
          end;
          X:=X+1;
      end;
      y:=Y+1;
      X:=0;
  end;
end;
7

路过

雷人

握手

鲜花

鸡蛋

刚表态过的朋友 (7 人)

发表评论 评论 (2 个评论)

回复 s0512 2012-12-27 00:08
晕。。。字体怎么会是白色的
回复 zzouc 2013-1-6 10:47
是啊 字体都是白色 楼主还是把整个工程项目放到网盘上吧

facelist

您需要登录后才可以评论 登录 | 立即注册

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-3 02:35

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

返回顶部