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

📄 castlemanage.pas

📁 飞尔传奇世界的引擎代码可直接编译M2Engine 请使用Delphi编译
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  end;
end;

procedure TfrmCastleManage.RefCastleAttackSabukWall;
var
  I: Integer;
  ListItem: TListItem;
  AttackerInfo, NewAttackerInfo: pTAttackerInfo;
begin
  nCount := 0;
  ListViewAttackSabukWall.Items.Clear;
  ListViewAttackSabukWall.Items.BeginUpdate;
  try
    for I := 0 to CurCastle.m_AttackWarList.Count - 1 do begin
      AttackerInfo := pTAttackerInfo(CurCastle.m_AttackWarList.Items[I]);
      ListItem := ListViewAttackSabukWall.Items.Add;
      if AttackerInfo <> nil then begin
        ListItem.Caption := IntToStr(nCount);
        ListItem.SubItems.AddObject(AttackerInfo.sGuildName, TObject(AttackerInfo));
        ListItem.SubItems.Add(DateToStr(AttackerInfo.AttackDate));
        Inc(nCount);
      end;
    end;
  finally
    ListViewAttackSabukWall.Items.EndUpdate;
  end;
end;

procedure TfrmCastleManage.ListViewCastleClick(Sender: TObject);
var
  ListItem: TListItem;
begin
  ListItem := ListViewCastle.Selected;
  if ListItem = nil then Exit;
  CurCastle := TUserCastle(ListItem.SubItems.Objects[0]);
  RefCastleInfo();
end;

procedure TfrmCastleManage.ButtonRefreshClick(Sender: TObject);
begin
  RefCastleInfo();
end;

function TfrmCastleManage.InListOfGuildName(sGuildName: string): TGUild;
var
  I: Integer;
  Guild: TGUild;
begin
  Result := nil;
  for I := 0 to g_GuildManager.GuildList.Count - 1 do begin
    Guild := TGUild(g_GuildManager.GuildList.Items[I]);
    if CompareText(sGuildName, Guild.sGuildName) = 0 then begin
      Result := Guild;
      Break;
    end;
  end;
end;

function TfrmCastleManage.AddAttackSabukWallOfGuild(sGuildName: string; AttackSabukWall: TDate): Boolean;
var
  AttackerInfo: pTAttackerInfo;
  Guild: TGUild;
  ListItem: TListItem;
begin
  Result := False;
  Guild := nil;
  Guild := InListOfGuildName(sGuildName);
  if Guild = nil then begin
    Application.MessageBox('输入的行会名不存在!!!', '提示信息', MB_ICONQUESTION);
    Exit;
  end;
  if CurCastle = nil then Exit;
  New(AttackerInfo);
  AttackerInfo.AttackDate := AttackSabukWall;
  AttackerInfo.sGuildName := sGuildName;
  AttackerInfo.Guild := Guild;
  CurCastle.m_AttackWarList.Add(AttackerInfo);
  ListViewAttackSabukWall.Items.BeginUpdate;
  try
    ListItem := ListViewAttackSabukWall.Items.Add;
    Inc(nCount);
    ListItem.Caption := IntToStr(nCount);
    ListItem.SubItems.AddObject(AttackerInfo.sGuildName, TObject(AttackerInfo));
    ListItem.SubItems.Add(DateToStr(AttackerInfo.AttackDate));
    CurCastle.Save;
    Result := True;
  finally
    ListViewAttackSabukWall.Items.EndUpdate;
  end;
end;
function TfrmCastleManage.IsAttackSabukWallOfGuild(sGuildName: string; AttackDate: TDate): Boolean;
var
  I: Integer;
  ListItem: TListItem;
  AttackerInfo: pTAttackerInfo;
begin
  Result := False;
  for I := 0 to ListViewAttackSabukWall.Items.Count - 1 do begin
    ListItem := ListViewAttackSabukWall.Items.Item[I];
    AttackerInfo := pTAttackerInfo(ListItem.SubItems.Objects[0]);
    if (CompareText(sGuildName, AttackerInfo.sGuildName) = 0) and (AttackerInfo.AttackDate = AttackDate) then begin
      Result := True;
      Break;
    end;
  end;
end;

function TfrmCastleManage.ChgAttackSabukWallOfGuild(sGuildName: string; AttackSabukWall: TDate): Boolean;
var
  AttackerInfo: pTAttackerInfo;
  Guild: TGUild;
  ListItem: TListItem;
  I: Integer;
  boFound: Boolean;
begin
  Result := False;
  Guild := nil;
  boFound := False;
  Guild := InListOfGuildName(sGuildName);
  if Guild = nil then begin
    Application.MessageBox('输入的行会名不存在!!!', '提示信息', MB_ICONQUESTION);
    Exit;
  end;
  if CurCastle = nil then Exit;
  for I := 0 to ListViewAttackSabukWall.Items.Count - 1 do begin
    ListItem := ListViewAttackSabukWall.Items.Item[I];
    AttackerInfo := pTAttackerInfo(ListItem.SubItems.Objects[0]);
    if CompareText(sGuildName, AttackerInfo.sGuildName) = 0 then begin
      AttackerInfo.AttackDate := AttackSabukWall;
      AttackerInfo.sGuildName := sGuildName;
      ListItem.SubItems.Strings[0] := sGuildName;
      ListItem.SubItems.Strings[1] := DateToStr(AttackSabukWall);
      CurCastle.Save;
      boFound := True;
      Result := True;
      Break;
    end;
  end;
  if not boFound then Result := AddAttackSabukWallOfGuild(sGuildName, AttackSabukWall);
end;

procedure TfrmCastleManage.ButtonAttackAdClick(Sender: TObject);
begin
  FrmAttackSabukWall := TFrmAttackSabukWall.Create(Owner);
  FrmAttackSabukWall.Caption := '增加攻城申请';
  nStute := 0;
  FrmAttackSabukWall.Top := frmCastleManage.Top - 50;
  FrmAttackSabukWall.Left := frmCastleManage.Left + 150;
  FrmAttackSabukWall.Open();
  FrmAttackSabukWall.Free;
end;

procedure TfrmCastleManage.ButtonAttackEditClick(Sender: TObject);
begin
  if CurCastle = nil then Exit;
  if SelAttackGuildInfo = nil then Exit;
  FrmAttackSabukWall := TFrmAttackSabukWall.Create(Owner);
  FrmAttackSabukWall.Caption := '编辑攻城申请';
  nStute := 1;
  FrmAttackSabukWall.Top := frmCastleManage.Top - 50;
  FrmAttackSabukWall.Left := frmCastleManage.Left + 150;
  m_sGuildName := SelAttackGuildInfo.sGuildName;
  m_AttackDate := SelAttackGuildInfo.AttackDate;
  FrmAttackSabukWall.Open();
  FrmAttackSabukWall.Free;
end;

procedure TfrmCastleManage.ListViewAttackSabukWallClick(Sender: TObject);
var
  ListItem: TListItem;
begin
  try
    ListItem := ListViewAttackSabukWall.Selected;
    SelAttackGuildInfo := pTAttackerInfo(ListItem.SubItems.Objects[0]);
  except
    SelAttackGuildInfo := nil;
  end;
end;

procedure TfrmCastleManage.ButtonAttackRClick(Sender: TObject);
begin
  if CurCastle = nil then Exit;
  RefCastleAttackSabukWall;
end;

procedure TfrmCastleManage.ButtonAttackDelClick(Sender: TObject);
var
  I: Integer;
  AttackerInfo: pTAttackerInfo;
begin
  if CurCastle = nil then Exit;
  if SelAttackGuildInfo = nil then Exit;
  if Application.MessageBox(PChar('是否确认删除此行会攻城申请?' + #10#10 +
    '行会名称:' + SelAttackGuildInfo.sGuildName + #10 +
    '攻城时间:' + DateToStr(SelAttackGuildInfo.AttackDate)), '确认信息', MB_YESNO + MB_ICONQUESTION) = IDYES then begin
    for I := 0 to CurCastle.m_AttackWarList.Count - 1 do begin
      AttackerInfo := pTAttackerInfo(CurCastle.m_AttackWarList.Items[I]);
      if AttackerInfo = SelAttackGuildInfo then begin
        CurCastle.m_AttackWarList.Delete(I);
        CurCastle.Save;
        Break;
      end;
    end;
    try
      ListViewAttackSabukWall.DeleteSelected;
    except
    end;
  end;
end;

procedure TfrmCastleManage.ButtonSaveClick(Sender: TObject);
begin
  if CurCastle = nil then Exit;
  CurCastle.m_sHomeMap := EditHomeMap.Text;
  CurCastle.m_sPalaceMap := EditPalace.Text;
  CurCastle.m_sHomeMap := EditHomeMap.Text;
  CurCastle.m_nHomeX := SpinEditNomeX.Value;
  CurCastle.m_nHomeY := SpinEditNomeY.Value;
  CurCastle.m_sSecretMap := EditTunnelMap.Text;
  CurCastle.Save;
  ButtonSave.Enabled := False;
end;

end.

⌨️ 快捷键说明

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