📄 guild.pas
字号:
unit Guild;
interface
uses
Windows, SysUtils, Classes,IniFiles,ObjBase;
type
TGuildRank = record
nRankNo :Integer;
sRankName :String;
MemberList :TStringList;
end;
pTGuildRank = ^TGuildRank;
TWarGuild = record
Guild :TObject;
dwWarTick:LongWord;
dwWarTime:LongWord;
end;
pTWarGuild = ^TWarGuild;
TGuild = class
sGuildName :String; //0x04
NoticeList :TStringList; //0x08
GuildWarList :TStringList; //0x0C
GuildAllList :TStringList; //0x10
m_RankList :TList; //0x14 职位列表
nContestPoint:integer; //0x18
boTeamFight :Boolean; //0x1C;
// MatchPoint :Integer;
TeamFightDeadList :TStringList; //0x20
m_boEnableAuthAlly :Boolean; //0x24
dwSaveTick :LongWord; //0x28
boChanged :Boolean; //0x2C;
m_DynamicVarList :TList;
private
m_Config :TIniFile;
m_nBuildPoint :Integer; //建筑度
m_nAurae :Integer; //人气度
m_nStability :Integer; //安定度
m_nFlourishing :Integer; //繁荣度
m_nChiefItemCount :Integer; //行会领取装备数量
function SetGuildInfo(sChief:String):Boolean;
procedure ClearRank();
procedure SaveGuildFile(sFileName: String);
procedure SaveGuildConfig(sFileName: String);
function GetMemberCount():Integer;
function GetMemgerIsFull():Boolean;
procedure SetAuraePoint(nPoint:Integer);
procedure SetBuildPoint(nPoint:Integer);
procedure SetStabilityPoint(nPoint:Integer);
procedure SetFlourishPoint(nPoint:Integer);
procedure SetChiefItemCount(nPoint:Integer);
public
constructor Create(sName:String);
destructor Destroy; override;
procedure SaveGuildInfoFile();
function LoadGuild():Boolean;
function LoadGuildFile(sGuildFileName:String):Boolean;
function LoadGuildConfig(sGuildFileName:String):Boolean;
procedure UpdateGuildFile;
procedure CheckSaveGuildFile;
function IsMember(sName:String):Boolean;
function IsAllyGuild(Guild:TGuild):Boolean;
function IsWarGuild(Guild:TGuild):Boolean;
function DelAllyGuild(Guild:TGuild):Boolean;
procedure TeamFightWhoDead(sName:String);
procedure TeamFightWhoWinPoint(sName:String;nPoint:Integer);
procedure SendGuildMsg(sMsg:String);
procedure RefMemberName();
function GetRankName(PlayObject:TPlayObject;var nRankNo:integer):String;
function DelMember(sHumName:String):Boolean;
function UpdateRank(sRankData:String):Integer;
function CancelGuld(sHumName:String):Boolean;
function IsNotWarGuild(Guild:TGuild):Boolean;
function AllyGuild(Guild:TGuild):Boolean;
function AddMember(PlayObject:TPlayObject):Boolean;
procedure DelHumanObj(PlayObject:TPlayObject);
function GetChiefName():String;
procedure BackupGuildFile();
procedure sub_499B4C(Guild:TGuild);
function AddWarGuild(Guild: TGuild): pTWarGuild;
procedure StartTeamFight();
procedure EndTeamFight();
procedure AddTeamFightMember(sHumanName:String);
property Count:Integer read GetMemberCount;
property IsFull:Boolean read GetMemgerIsFull;
property nBuildPoint:Integer read m_nBuildPoint write SetBuildPoint;
property nAurae:Integer read m_nAurae write SetAuraePoint;
property nStability:Integer read m_nStability write SetStabilityPoint;
property nFlourishing:Integer read m_nFlourishing write SetFlourishPoint;
property nChiefItemCount:Integer read m_nChiefItemCount write SetChiefItemCount;
end;
TGuildManager = class
GuildList :TList; //0x4
private
public
constructor Create();
destructor Destroy; override;
procedure LoadGuildInfo();
procedure SaveGuildList();
function MemberOfGuild(sName:String):TGuild;
function AddGuild(sGuildName,sChief:String):Boolean;
function FindGuild(sGuildName:String):TGuild;
function DelGuild(sGuildName:String):Boolean;
procedure ClearGuildInf();
procedure Run();
end;
implementation
uses M2Share, HUtil32, Grobal2;
{ TGuildManager }
function TGuildManager.AddGuild(sGuildName, sChief: String): Boolean;//0049A4A4
var
Guild:TGuild;
begin
Result:=False;
if CheckGuildName(sGuildName) and (FindGuild(sGuildName) = nil) then begin
Guild:=TGuild.Create(sGuildName);
Guild.SetGuildInfo(sChief);
GuildList.Add(Guild);
SaveGuildList();
Result:=True;
end;
end;
function TGuildManager.DelGuild(sGuildName: String): Boolean;//0049A550
var
I:Integer;
Guild:TGuild;
begin
Result:=False;
for i:=0 to GuildList.Count -1 do begin
Guild:=TGuild(GuildList.Items[I]);
if CompareText(Guild.sGuildName,sGuildName) = 0 then begin
if Guild.m_RankList.Count > 1 then break;
Guild.BackupGuildFile();
GuildList.Delete(I);
SaveGuildList();
Result:=True;
Break;
end;
end;
end;
procedure TGuildManager.ClearGuildInf;//0049A02C
var
I: Integer;
begin
for I := 0 to GuildList.Count - 1 do begin
TGuild(GuildList.Items[I]).Free;
end;
GuildList.Clear;
end;
constructor TGuildManager.Create;
begin
GuildList:=TList.Create;
end;
destructor TGuildManager.Destroy;
begin
GuildList.Free;
inherited;
end;
function TGuildManager.FindGuild(sGuildName: String): TGuild;//0049A36C
var
i:Integer;
begin
Result:=nil;
for i:=0 to GuildList.Count -1 do begin
if TGuild(GuildList.Items[i]).sGuildName = sGuildName then begin
Result:=TGuild(GuildList.Items[i]);
Break;
end;
end;
end;
procedure TGuildManager.LoadGuildInfo;//0049A078
var
LoadList:TStringList;
Guild:TGuild;
sGuildName:String;
i:integer;
begin
if FileExists(g_Config.sGuildFile) then begin
LoadList:=TStringList.Create;
LoadList.LoadFromFile(g_Config.sGuildFile);
for i:=0 to LoadList.Count -1 do begin
sGuildName:=Trim(LoadList.Strings[i]);
if sGuildName <> '' then begin
Guild:=TGuild.Create(sGuildName);
GuildList.Add(Guild);
end;
end;
LoadList.Free;
for i:=GuildList.Count -1 downto 0 do begin
Guild:=GuildList.Items[i];
if not Guild.LoadGuild() then begin
MainOutMessage(Guild.sGuildName + ' 读取出错!!!');
Guild.Free;
GuildList.Delete(i);
SaveGuildList();
end;
end;
MainOutMessage('已读取 ' + IntToStr(GuildList.Count) + '个行会信息...');
end else begin
MainOutMessage('行会信息文件未找到!!!');
end;
end;
function TGuildManager.MemberOfGuild(sName: String): TGuild;
//0049A408
var
i:Integer;
begin
Result:=nil;
for i:=0 to GuildList.Count -1 do begin
if TGuild(GuildList.Items[i]).IsMember(sName) then begin
Result:=TGuild(GuildList.Items[i]);
Break;
end;
end;
end;
procedure TGuildManager.SaveGuildList;//0049A260
var
I: Integer;
SaveList:TStringList;
begin
if nServerIndex <> 0 then exit;
SaveList:=TStringList.Create;
for I := 0 to GuildList.Count - 1 do begin
SaveList.Add(TGuild(GuildList.Items[I]).sGuildName);
end; // for
try
SaveList.SaveToFile(g_Config.sGuildFile);
except
MainOutMessage('行会信息保存失败!!!');
end;
SaveList.Free;
end;
procedure TGuildManager.Run;//0049A61C
var
I :Integer;
II :Integer;
Guild :TGuild;
boChanged:Boolean;
WarGuild :pTWarGuild;
begin
for I := 0 to GuildList.Count - 1 do begin
Guild:=TGuild(GuildList.Items[I]);
boChanged:=False;
for II := Guild.GuildWarList.Count - 1 downto 0 do begin
WarGuild:=pTWarGuild(Guild.GuildWarList.Objects[II]);
if (GetTickCount - WarGuild.dwWarTick) > WarGuild.dwWarTime then begin
Guild.sub_499B4C(TGuild(WarGuild.Guild));
Guild.GuildWarList.Delete(II);
Dispose(WarGuild);
boChanged:=True;
end;
end;
if boChanged then begin
Guild.UpdateGuildFile();
end;
Guild.CheckSaveGuildFile;
end;
end;
{ TGuild }
procedure TGuild.ClearRank;//00497C78
var
I: Integer;
GuildRank:pTGuildRank;
begin
for I := 0 to m_RankList.Count - 1 do begin
GuildRank:=m_RankList.Items[I];
GuildRank.MemberList.Free;
Dispose(GuildRank);
end; // for
m_RankList.Clear;
end;
constructor TGuild.Create(sName: String); //00497B04
var
sFileName:String;
begin
sGuildName :=sName;
NoticeList :=TStringList.Create;
GuildWarList :=TStringList.Create;
GuildAllList :=TStringList.Create;
m_RankList :=TList.Create;
TeamFightDeadList :=TStringList.Create;
dwSaveTick :=0;
boChanged :=False;
nContestPoint :=0;
boTeamFight :=False;
m_boEnableAuthAlly :=False;
sFileName:=g_Config.sGuildDir + sName + '.ini';
m_Config :=TIniFile.Create(sFileName);
if not FileExists(sFileName) then begin
m_Config.WriteString('Guild','GuildName',sName);
end;
m_nBuildPoint :=0;
m_nAurae :=0;
m_nStability :=0;
m_nFlourishing :=0;
m_nChiefItemCount :=0;
m_DynamicVarList := TList.Create;
end;
function TGuild.DelAllyGuild(Guild: TGuild):Boolean; //00499CEC
var
I: Integer;
AllyGuild:TGuild;
begin
Result:=False;
for I := 0 to GuildAllList.Count - 1 do begin
AllyGuild:=TGuild(GuildAllList.Objects[I]);
if AllyGuild = Guild then begin
GuildAllList.Delete(I);
Result:=True;
break;
end;
end; // for
SaveGuildInfoFile();
end;
destructor TGuild.Destroy; //00497C08
var
I:Integer;
begin
NoticeList.Free;
GuildWarList.Free;
GuildAllList.Free;
ClearRank();
m_RankList.Free;
TeamFightDeadList.Free;
m_Config.Free;
for I := 0 to m_DynamicVarList.Count - 1 do begin
Dispose(pTDynamicVar(m_DynamicVarList.Items[I]));
end;
m_DynamicVarList.Free;
inherited;
end;
function TGuild.IsAllyGuild(Guild: TGuild): Boolean; //00499BD8
var
I: Integer;
AllyGuild:TGuild;
begin
Result:=False;
for I := 0 to GuildAllList.Count - 1 do begin
AllyGuild:=TGuild(GuildAllList.Objects[I]);
if AllyGuild = Guild then begin
Result:=True;
break;
end;
end;
end;
function TGuild.IsMember(sName: String): Boolean; //00498714
var
i,II:integer;
GuildRank:pTGuildRank;
begin
Result:=False;
for i:=0 to m_RankList.Count - 1 do begin
GuildRank:=m_RankList.Items[i];
for II:=0 to GuildRank.MemberList.Count -1 do begin
if GuildRank.MemberList.Strings[II] = sName then begin
Result:=True;
exit;
end;
end;
end;
end;
function TGuild.IsWarGuild(Guild: TGuild): Boolean;//00499924
var
I: Integer;
begin
Result:=False;
for I := 0 to GuildWarList.Count - 1 do begin
if pTWarGuild(GuildWarList.Objects[I]).Guild = Guild then begin
Result:=True;
break;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -