📄 ugroup.pas
字号:
unit uGroup;
interface
uses
Classes, SysUtils, BSCommon, UserSDB, AUtil32, DefType, uConnect, AnsImg2;
const
OWNER_XPOS = 17;
FIGHTER_XPOS = 20;
BOTH_YPOS = 18;
WIN_SCORE = 2;
TOTAL_SCORE = 3;
DOUMI_CHAR = '档快固';
type
TBattleRoomStatus = ( brs_none, brs_waitfighter, brs_ready, brs_readyfight, brs_fighting, brs_nextready, brs_end );
TBattleRoom = class
private
RoomNo : Integer;
RoomStatus : TBattleRoomStatus;
ViewerList : TList;
JoinList : TList;
FboAllowDelete : Boolean;
FboRoomGrade : Boolean;
function GetViewerCount : Integer;
function GetJoinCount : Integer;
public
Title : String;
Owner : String; // 捞抚 + 辑滚
Fighter : String; // 捞抚 + 辑滚
OwnerName : String; // 鉴荐 捞抚
FighterName : String; // 鉴荐 捞抚
OwnerServer : String; // 辑滚疙
FighterServer : String; // 辑滚疙
Stage : Integer;
OwnerWin : Integer;
FighterWin : Integer;
Winner : String;
Loser : String;
OwnerXpos : Integer;
FighterXpos : Integer;
OwnerDir : Integer;
FighterDir : Integer;
OwnerPercent : Integer;
FighterPercent : Integer;
OwnerMotion : Integer;
FighterMotion : Integer;
BattleType : Integer;
BattleStartTick : Integer;
StatusElapsedTick : Integer;
OwnerConnector : Pointer;
FighterConnector : Pointer;
OwnerUser : Pointer;
FighterUser : Pointer;
Phone : Pointer;
Maper : Pointer;
UserList : Pointer;
ServerID : integer;
Directory : String;
SmpName : String;
MapName : String;
ObjName : String;
RofName : String;
TilName : String;
SoundBase : String;
boUseDrug : Boolean;
boGetExp : Boolean;
boBigSay : Boolean;
boMakeGuild : Boolean;
boPosDie : Boolean;
boHit : Boolean;
boWeather : Boolean;
boPrison : Boolean;
constructor Create (aOwnerConnector : TConnector; aOwner : String; aRoomNo : Integer);
destructor Destroy; override;
procedure Update (CurTick : Integer);
procedure RemakeBattleChar (aStage : Integer);
procedure RemoveConnector (aConnector : TConnector);
procedure ExitConnector (aConnector : TConnector);
procedure AddViewerConnector (aConnector : TConnector);
procedure RemoveViewerConnector (aConnector : TConnector);
function GetViewerConnector (aIndex : Integer) : TConnector;
procedure AddJoinConnector (aConnector : TConnector);
procedure RemoveJoinConnector (aConnector : TConnector);
procedure SetBattleBar (aSenderInfo : TBasicData; aPercent : Integer);
procedure SetUserMotion (aSenderInfo : TBasicData; aMotion : Integer);
procedure SendWatchMessage (aStr : String; aColor : Byte);
procedure SendWatchMap;
procedure SendRankData (aConnector : TConnector);
procedure SendResultData (aOwnerWin, aFighterWin, aOwnerDisCon, aFighterDisCon : Integer);
procedure KickOutChar (aName : String);
function SearchConnector (aCharName : String) : TConnector;
procedure ExitViewerConnector (aConnector : TConnector);
function GetRoomString : String;
function GetViewerString : String;
property ViewerCount : Integer read GetViewerCount;
property JoinCount : Integer read GetJoinCount;
property BattleRoomStatus : TBattleRoomStatus read RoomStatus;
property RoomGrade : Boolean read FboRoomGrade write FboRoomGrade;
end;
TBattleGroup = class // RoomList;
private
Name : String;
ViewName : String;
RoomLimit : Integer;
MinAge : Integer;
MaxAge : Integer;
boGrade : Boolean;
DataList : TList;
function Get (aIndex : Integer) : Pointer;
function GetCount : Integer;
public
constructor Create (aGroupData : PTCreateGroupData);
destructor Destroy; override;
function CreateBattleRoom (aOwnerConnector : TConnector; aOwner : String; var aRetStr : String) : TBattleRoom;
function FightBattleRoom (aFighterConnector : TConnector; aTitle, aFighter : String; var aRetStr : String) : TBattleRoom;
function ViewBattleRoom (aTitle : String; var aRetStr : String) : TBattleRoom;
// procedure DeleteBattleRoom (aRoom : TBattleRoom);
procedure Update (CurTick : Integer);
procedure GetBattleRoomData (aRoomList : PTSShowListWindow; aType : Byte);
procedure ShowRoomTitleList;
function GetGroupString : String;
property Items [aIndex : Integer] : Pointer read Get;
property Count : Integer read GetCount;
end;
TBattleGroupList = class // BattleGroupList;
private
DataList : TList;
function GetCount : Integer;
function Get (aIndex : Integer) : Pointer;
public
constructor Create;
destructor Destroy; override;
function LoadFromFile (aFileName : String) : Boolean;
procedure Update (CurTick : Integer);
procedure GetBattleGroupData (aGroupList : PTSShowListWindow; aType : Byte);
procedure GetBattleRoomData (aRoomList : PTSShowListWindow; aGroupTitle : String; aType : Byte);
function CreateBattleRoom (aOwnerConnector : TConnector; aGroupTitle, aOwnerName : String; var aRetStr : String) : TBattleRoom;
function FightBattleRoom (aFighterConnector : TConnector; aGroupTitle, aRoomTitle, aFighterName : String; var aRetStr : String) : TBattleRoom;
function ViewBattleRoom (aGroupTitle, aRoomTitle : String; var aRetStr : String) : TBattleRoom;
procedure ShowRoomTitleList (aGroupTitle : String);
property Items [aIndex : Integer] : Pointer read Get;
property Count : Integer read GetCount;
end;
var
BattleGroupList : TBattleGroupList;
ShareRoom : TBattleRoom;
boUseShareRoom : Boolean = false;
implementation
uses
MapUnit, FieldMsg, uUser, SVMain;
// TBattleRoom;
constructor TBattleRoom.Create (aOwnerConnector : TConnector; aOwner : String; aRoomNo : Integer);
var
OwnerPoints : Integer;
begin
Owner := aOwner;
Fighter := '';
OwnerName := '';
FighterName := '';
OwnerServer := '';
FighterServer := '';
Stage := 0;
OwnerWin := 0;
FighterWin := 0;
Winner := '';
Loser := '';
OwnerXpos := 0;
FighterXpos := 0;
OwnerDir := 0;
FighterDir := 0;
OwnerPercent := 100;
FighterPercent := 100;
OwnerMotion := AM_NONE;
FighterMotion := AM_NONE;
BattleType := 2;
FboRoomGrade := false;
OwnerConnector := aOwnerConnector;
FighterConnector := nil;
OwnerUser := nil;
FighterUser := nil;
RoomNo := aRoomNo;
OwnerPoints := 0;
if OwnerConnector <> nil then
OwnerPoints := TConnector (OwnerConnector).Points;
// Title := format ('%d %s [%d]', [RoomNo, Owner, OwnerPoints]);
Title := format ('%s [%d]', [Owner, OwnerPoints]);
if OwnerConnector = nil then begin
Maper := TMaper.Create ('.\Smp\Server2.smp');
Phone := TFieldPhone.Create (Self);
ServerID := 0;
Directory := '.\smp\';
SmpName := 'Server2.smp';
MapName := 'Server2.map';
ObjName := 'BSMapobj.obj';
RofName := 'BSMaprof.rof';
TilName := 'BSmaptil.til';
SoundBase := '1401';
end else begin
Maper := TMaper.Create ('.\Smp\BSMap.smp');
Phone := TFieldPhone.Create (Self);
ServerID := 0;
Directory := '.\smp\';
SmpName := 'BSMap.smp';
MapName := 'BSMap.map';
ObjName := 'BSMapobj.obj';
RofName := 'BSMaprof.rof';
TilName := 'BSMaptil.til';
SoundBase := '1401';
end;
boUseDrug := false;
boGetExp := false;
boBigSay := true;
boMakeGuild := false;
boPosDie := false;
boHit := true;
boWeather := false;
boPrison := false;
FboAllowDelete := false;
RoomStatus := brs_none;
UserList := TUserList.Create (100);
ViewerList := TList.Create;
JoinList := TList.Create;
end;
destructor TBattleRoom.Destroy;
var
i : Integer;
Connector : TConnector;
begin
if (Stage > 0) and (Stage < TOTAL_SCORE) then begin
if FboRoomGrade = true then begin
SendResultData (OwnerWin, FighterWin, 1, 0);
end;
end;
if OwnerConnector <> nil then begin
TUserList (UserList).FinalLayer (OwnerConnector);
TConnector (OwnerConnector).ExitBattleRoom;
end;
if FighterConnector <> nil then begin
TUserList (UserList).FinalLayer (FighterConnector);
TConnector (FighterConnector).ExitBattleRoom;
end;
for i := 0 to ViewerList.Count - 1 do begin
Connector := ViewerList.Items [i];
Connector.ExitBattleRoom;
end;
ViewerList.Clear;
ViewerList.Free;
if OwnerConnector = nil then begin
for i := 0 to JoinList.Count - 1 do begin
Connector := JoinList.Items [i];
Connector.ExitShareRoom;
end;
JoinList.Clear;
JoinList.Free;
end;
TMaper (Maper).Free;
TFieldPhone (Phone).Free;
TUserList (UserList).Free;
inherited Destroy;
end;
function TBattleRoom.GetRoomString : String;
var
FighterPoints : Integer;
begin
FighterPoints := 0;
if FighterConnector <> nil then
FighterPoints := TConnector (FighterConnector).Points;
if Fighter = '' then begin
Result := Title + ':' + ' ( 措扁吝 ) ' + ':' + '包恩 ' + IntToStr (ViewerList.Count) + '疙';
end else begin
Result := Title + ':' + ' ' + Fighter + ' [' + IntToStr (FighterPoints) + ']' + ' ' + ':' + '包恩 ' + IntToStr (ViewerList.Count) + '疙';
end;
end;
function TBattleRoom.GetViewerString : String;
var
i : Integer;
Connector : TConnector;
Str, rdStr : String;
begin
Result := '';
Str := ''; rdStr := '';
for i := 0 to ViewerList.Count - 1 do begin
Connector := ViewerList.Items [i];
rdStr := rdStr + Connector.Name;
if i < ViewerList.Count - 1 then begin
rdStr := rdStr + ' ';
end;
if Length (rdStr) > 40 then begin
Str := ' ' + Str + rdStr + #13;
rdStr := '';
end;
end;
if rdStr <> '' then
Str := ' ' + Str + rdStr + #13;
Result := Str;
end;
function TBattleRoom.GetViewerCount : Integer;
begin
Result := ViewerList.Count;
end;
procedure TBattleRoom.AddViewerConnector (aConnector : TConnector);
begin
ViewerList.Add (aConnector);
end;
procedure TBattleRoom.RemoveViewerConnector (aConnector : TConnector);
var
i : Integer;
tmpConnector : TConnector;
begin
for i := 0 to ViewerList.Count - 1 do begin
tmpConnector := ViewerList.Items [i];
if tmpConnector = aConnector then begin
ViewerList.Delete (i);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -