⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frminsert_p.pas

📁 斗地主源代码.Delphi编写.....
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    //擦除多余的牌位
    for I := AllOtherCardHistory.Count to 37 - 1 do //其他人手中所有的牌最多为37张
      DrawOnePoke(-1, PokeNone, ImgLeftExcursion + I * MyPokeWidth, ImgAllOtherPokeTop);
  end;
end;


{-------------------------------------------------------------------------------
  过程名:    TfrmInsertType.DrawSideCardHistory
  说明:      绘制其他两方出牌牌面记录。
  作者:      who&who
  日期:      2005.03.11
  参数:      无
  返回值:    无
-------------------------------------------------------------------------------}
procedure TfrmInsertType.DrawSideCardHistory;
var
  I: Integer;
  TempStr: string;
begin
  TempStr := LeftCardHistory.CommaText;
  if TempStr <> PrevLeftSideHistory then
  begin
    PrevLeftSideHistory := TempStr;
    for I := 0 to LeftCardHistory.Count - 1 do
      DrawOnePoke(StrToInt(LeftCardHistory[I]), PokeFace, ImgLeftExcursion + I * MyPokeWidth, ImgLeftPokeTop);
    for I := LeftCardHistory.Count to LeftSideCardCount - 1 do
      DrawOnePoke(-1, PokeInverse, ImgLeftExcursion + I * MyPokeWidth, ImgLeftPokeTop);
  end;
  TempStr := RightCardHistory.CommaText;
  if TempStr <> PrevRightSideHistory then
  begin
    PrevRightSideHistory := TempStr;
    for I := 0 to RightCardHistory.Count - 1 do
      DrawOnePoke(StrToInt(RightCardHistory[I]), PokeFace, ImgLeftExcursion + I * MyPokeWidth, ImgRightPokeTop);
    for I := RightCardHistory.Count to RightSideCardCount - 1 do
      DrawOnePoke(-1, PokeInverse, ImgLeftExcursion + I * MyPokeWidth, ImgRightPokeTop);
  end;
end;


{-------------------------------------------------------------------------------
  过程名:    TfrmInsertType.CheckPokeType
  说明:      获取单一牌面花色。
  作者:      who&who
  日期:      2005.03.11
  参数:      PokeData: string
  返回值:    TPokeMarks
-------------------------------------------------------------------------------}
function TfrmInsertType.CheckPokeType(PokeData: string): TPokeMarks;
begin
  Result := TPokeMarks(Lo(PokeTemplet[StrToInt(PokeData)]));
end;


{-------------------------------------------------------------------------------
  过程名:    TfrmInsertType.CheckPokeSymbol
  说明:      获取单一牌面。
  作者:      who&who
  日期:      2005.03.11
  参数:      PokeData: string
  返回值:    Integer
-------------------------------------------------------------------------------}
function TfrmInsertType.CheckPokeSymbol(PokeData: string): Byte;
begin
  Result := Hi(PokeTemplet[StrToInt(PokeData)]);
end;


procedure TfrmInsertType.FormShow(Sender: TObject);
begin
  imgBtnQuit.Left := RectDest.Right - RectDest.Left - imgBtnQuit.Width;
  imgBtnQuit.Top := Self.Height - imgBtnQuit.Height - 1;
  lblMyName.Left := RectDest.Right - RectDest.Left - lblMyName.Width - 6;
  lblMyName.Top := imgBtnQuit.Top - lblMyName.Height - 5;
  imgLogo.Left := lblMyName.Left - imgLogo.Width - 3;
  imgLogo.Top := lblMyName.Top - 2;

  imgBackGround.Align := alClient;
  imgBackGround.Canvas.FillRect(imgBackGround.ClientRect);
  imgBackGround.Canvas.Pen.Color := clWhite;
  imgBackGround.Canvas.PenPos := Point(10, ImgLineTop);
  imgBackGround.Canvas.LineTo(RectDest.Right - RectDest.Left - 10, ImgLineTop);
  frmMain.TrayIcon.HideTaskbarIcon;
end;


procedure TfrmInsertType.FormDestroy(Sender: TObject);
begin
  imgBackGround.Canvas.Brush.Bitmap.Free;
end;


procedure TfrmInsertType.tmrWatchCardTimer(Sender: TObject);
var
  TempCardList: TStringList;
  NewPokeOut, TmpCount: Cardinal;
begin
  tmrWatchCard.Enabled := False;

  if GameState = GameRunning then
  begin
    //检查左方出牌
    if GetDataFromRam(AdrLeftOut, NewPokeOut) then
    begin
      //如果左方出牌情况变化
      if PokeOutLeft <> NewPokeOut then
      begin
        PokeOutLeft := NewPokeOut;
        if NewPokeOut <> 0 then
        begin
          //获取左方此次出排数量
          if not GetDataFromRam(AdrLeftOutCount, TmpCount) then
            Close;
          //获取左方此次出牌所有牌面
          TempCardList := CheckSideCardOut(AdrLeftOut, TmpCount);
          //添加到左方除牌历史纪录
          SideHistory(LeftCardHistory, TempCardList);
        end;
      end;
    end;

    //检查右方出牌
    if GetDataFromRam(AdrRightOut, NewPokeOut) then
    begin
      //如果右方出牌情况变化
      if PokeOutRight <> NewPokeOut then
      begin
        PokeOutRight := NewPokeOut;
        if NewPokeOut <> 0 then
        begin
          //获取右方此次出排数量
          if not GetDataFromRam(AdrRightOutCount, TmpCount) then
            Close;
          //获取右方此次出牌所有牌面
          TempCardList := CheckSideCardOut(AdrRightOut, TmpCount);
          //添加到右方除牌历史纪录
          SideHistory(RightCardHistory, TempCardList);
        end;
      end;
    end;

    //绘制外面剩余的牌面以及可能的炸弹
    DrawLeaveCardAndBomb;
    //绘制其他两方出牌牌面记录
    DrawSideCardHistory;
  end;

  tmrWatchCard.Enabled := True;
end;


procedure TfrmInsertType.imgBtnQuitClick(Sender: TObject);
begin
  Close;
  Application.Terminate;
end;


{-------------------------------------------------------------------------------
  过程名:    TfrmInsertType.tmrWatchStateTimer
  说明:      通过监视底牌的变化来感知牌局的起始终止
  作者:      who&who
  日期:      2005.03.11
  参数:      Sender: TObject
  返回值:    无
-------------------------------------------------------------------------------}
procedure TfrmInsertType.tmrWatchStateTimer(Sender: TObject);
var
  I: Integer;
  NewPokeLeave: Cardinal;
  SumCount, TmpCount: Cardinal;
  NewSelfSeatNum: Cardinal;
begin
  tmrWatchState.Enabled := False;
  if not GetDataFromRam(AdrSelfSeatNum, NewSelfSeatNum) then
    Self.Close;

  if NewSelfSeatNum <> SelfSeatNum then
  begin
  //重新扫描数据,以应对斗地主窗口没有关闭,但切换了座位的情况。
    if not GetAllDataAdr then
    begin
    //内存扫描不成功,处理;
      Self.Close;
    end;
  end;

  if GetDataFromRam(AdrLeave, NewPokeLeave) then
    //如果底牌发生变化,表明牌局有变动
    if NewPokeLeave <> PokeLeave then
    begin
      //如果原来的底牌状态为空(0),而现在不为空,则表明牌局启动
      if PokeLeave = 0 then
      begin
        //需要查看三方手中牌数是否为54,如果小于54,表明牌局已在进行中,本局不再进行监视。
        GetDataFromRam(AdrLeftCount, TmpCount);
        SumCount := TmpCount;
        LeftSideCardCount := TmpCount;

        GetDataFromRam(AdrSelfCount, TmpCount);
        SumCount := SumCount + TmpCount;

        GetDataFromRam(AdrRightCount, TmpCount);
        SumCount := SumCount + TmpCount;
        RightSideCardCount := TmpCount;

        GameState := GameRunning;
        PokeLeave := NewPokeLeave;
        if SumCount = 54 then
        begin
          AllOtherCardHistory.Clear;
          LeftCardHistory.Clear;
          RightCardHistory.Clear;
          for I := 0 to 53 do
            AllOtherCardHistory.Add(RightStr('0' + IntToStr(I), 2));
          CheckSelfAllCard;

          for I := LeftCardHistory.Count to LeftSideCardCount - 1 do
            DrawOnePoke(-1, PokeInverse, ImgLeftExcursion + I * MyPokeWidth, ImgLeftPokeTop);
          for I := RightCardHistory.Count to RightSideCardCount - 1 do
            DrawOnePoke(-1, PokeInverse, ImgLeftExcursion + I * MyPokeWidth, ImgRightPokeTop);

          tmrWatchCard.Enabled := True;
        end
        else
          //提示牌局早已开始,本局无法记录
          lblMessage.Visible := True;
      end
      //如果原来底牌不为空,而现在为空,表明牌局结束。
      else if NewPokeLeave = 0 then
      begin
        GameState := GameBegin;
        PokeLeave := NewPokeLeave;

        lblMessage.Visible := False;

        //重新绘制背景,清除以前绘制的牌面
        imgBackGround.Canvas.FillRect(imgBackGround.ClientRect);
        imgBackGround.Canvas.Pen.Color := clWhite;
        imgBackGround.Canvas.PenPos := Point(10, ImgLineTop);
        imgBackGround.Canvas.LineTo(RectDest.Right - RectDest.Left - 10, ImgLineTop);

        tmrWatchCard.Enabled := False;
      end;
    end;
  tmrWatchState.Enabled := True;
end;

procedure TfrmInsertType.lblMyNameClick(Sender: TObject);
begin
  ShellExecute(Handle, nil, PChar('mailto:whoawho@qianlong.com'), nil, nil, SW_SHOW);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -