📄 ugroup.pas
字号:
iNo := 1;
while true do begin
boFlag := false;
for i := 0 to DataList.Count - 1 do begin
BattleRoom := DataList.Items [i];
if BattleRoom.RoomNo = iNo then begin
boFlag := true;
break;
end;
end;
if boFlag = false then break;
Inc (iNo);
end;
BattleRoom := TBattleRoom.Create (aOwnerConnector, aOwner, iNo);
DataList.Add (BattleRoom);
BattleRoom.RoomGrade := boGrade;
pd := @ComData.Data;
pd^.rMsg := SM_SHOWSPECIALWINDOW;
pd^.rWindow := WINDOW_GROUPWINDOW;
pd^.rType := 3;
Str := GetGroupString;
SetWordString (pd^.rWordString, Str);
ComData.Cnt := sizeof(TSShowListWindow) - sizeof(TWordString) + sizeofwordstring(pd^.rWordString);
ConnectorList.SendLatestList (ws_group, @ComData, ComData.Cnt + SizeOf (Word));
frmMain.lstGroupUpdate (Str);
// ViewTitle := ViewName + ':' + IntToStr (DataList.Count);
Result := BattleRoom;
end;
function TBattleGroup.FightBattleRoom (aFighterConnector : TConnector; aTitle, aFighter : String; var aRetStr : String) : TBattleRoom;
var
i, Age : Integer;
BattleRoom : TBattleRoom;
begin
Result := nil;
Age := aFighterConnector.GetCharAge;
if (Age < MinAge) or (Age > MaxAge) then begin
aRetStr := '捞 弊缝俊辑 措傈且 荐 绝嚼聪促';
exit;
end;
for i := 0 to DataList.Count - 1 do begin
BattleRoom := DataList.Items [i];
if BattleRoom.Title = aTitle then begin
if BattleRoom.Fighter = '' then begin
BattleRoom.FighterConnector := aFighterConnector;
BattleRoom.Fighter := aFighter;
Result := BattleRoom;
end else begin
aRetStr := '捞固 措傈吝牢 规涝聪促';
end;
exit;
end;
end;
aRetStr := '急琶茄 规阑 茫阑 荐 绝嚼聪促';
end;
function TBattleGroup.ViewBattleRoom (aTitle : String; var aRetStr : String) : TBattleRoom;
var
i : Integer;
BattleRoom : TBattleRoom;
begin
Result := nil;
for i := 0 to DataList.Count - 1 do begin
BattleRoom := DataList.Items [i];
if BattleRoom.Title = aTitle then begin
Result := BattleRoom;
exit;
end;
end;
aRetStr := '急琶茄 规阑 茫阑 荐 绝嚼聪促';
end;
{
procedure TBattleGroup.DeleteBattleRoom (aRoom : TBattleRoom);
var
i : Integer;
BattleRoom : TBattleRoom;
begin
for i := 0 to DataList.Count - 1 do begin
BattleRoom := DataList.Items [i];
if BattleRoom = aRoom then begin
BattleRoom.Free;
DataList.Delete (i);
exit;
end;
end;
end;
}
procedure TBattleGroup.Update (CurTick : Integer);
var
i : Integer;
BattleRoom : TBattleRoom;
str : String;
ComData : TWordComData;
pd : PTSShowListWindow;
prd : PTSShowListWindow;
begin
if ShareRoom <> nil then ShareRoom.Update (CurTick);
for i := DataList.Count - 1 downto 0 do begin
BattleRoom := DataList.Items [i];
if BattleRoom.FboAllowDelete = true then begin
prd := @ComData.Data;
prd^.rMsg := SM_SHOWSPECIALWINDOW;
prd^.rWindow := WINDOW_ROOMWINDOW;
prd^.rType := 2;
Str := BattleRoom.GetRoomString;
SetWordString (prd^.rWordString, str);
ComData.Cnt := sizeof(TSShowListWindow) - sizeof(TWordString) + sizeofwordstring(prd^.rWordString);
ConnectorList.SendLatestRoomList (ViewName, @ComData, ComData.Cnt + SizeOf (Word));
// ConnectorList.SendLatestList (ws_room, @ComData, ComData.Cnt + SizeOf (Word));
BattleRoom.Free;
DataList.Delete (i);
pd := @ComData.Data;
pd^.rMsg := SM_SHOWSPECIALWINDOW;
pd^.rWindow := WINDOW_GROUPWINDOW;
pd^.rType := 3;
Str := GetGroupString;
SetWordString (pd^.rWordString, str);
ComData.Cnt := sizeof(TSShowListWindow) - sizeof(TWordString) + sizeofwordstring(pd^.rWordString);
ConnectorList.SendLatestList (ws_group, @ComData, ComData.Cnt + SizeOf (Word));
frmMain.lstGroupUpdate (Str);
end;
end;
for i := 0 to DataList.Count - 1 do begin
BattleRoom := DataList.Items [i];
if BattleRoom.FboAllowDelete = true then
frmMain.WriteLogInfo ('FboAllowDelete = true');
BattleRoom.Update (CurTick);
if (BattleRoom.FboAllowDelete = true) and (BattleRoom.OwnerUser = nil) and (BattleRoom.OwnerConnector = nil) then
frmMain.WriteLogInfo ('FboAllowDelete = true, OwnerUser = nil, OwnerConnector = nil');
end;
end;
procedure TBattleGroup.GetBattleRoomData (aRoomList : PTSShowListWindow; aType : Byte);
var
i : Integer;
dest : String;
BattleRoom : TBattleRoom;
begin
aRoomList^.rMsg := SM_SHOWSPECIALWINDOW;
aRoomList^.rWindow := WINDOW_ROOMWINDOW;
aRoomList^.rType := aType;
dest := '';
for i := 0 to DataList.Count - 1 do begin
BattleRoom := DataList.Items [i];
if BattleRoom.FboAllowDelete = true then continue;
dest := dest + BattleRoom.GetRoomString + ',';
end;
SetWordString (aRoomList^.rWordString, dest);
end;
procedure TBattleGroup.ShowRoomTitleList;
var
i : Integer;
BattleRoom : TBattleRoom;
begin
for i := 0 to DataList.Count - 1 do begin
BattleRoom := DataList.Items [i];
frmMain.lstRoom.Items.Add (BattleRoom.GetRoomString);
end;
end;
function TBattleGroup.Get (aIndex : Integer) : Pointer;
begin
Result := nil;
if (aIndex < 0) or (aIndex >= DataList.Count) then exit;
Result := DataList.Items [aIndex];
end;
function TBattleGroup.GetCount : Integer;
begin
Result := DataList.Count;
end;
// TBattleGroupList;
constructor TBattleGroupList.Create;
begin
DataList := TList.Create;
LoadFromFile ('.\Setting\CreateGroup.SDB');
end;
destructor TBattleGroupList.Destroy;
var
i : Integer;
BattleGroup : TBattleGroup;
begin
for i := 0 to DataList.Count - 1 do begin
BattleGroup := DataList.Items [i];
BattleGroup.Free;
end;
DataList.Clear;
DataList.Free;
inherited Destroy;
end;
function TBattleGroupList.LoadFromFile (aFileName : String) : Boolean;
var
i : Integer;
iName : String;
DB : TUserStringDB;
gd : TCreateGroupData;
BattleGroup : TBattleGroup;
begin
Result := false;
if not FileExists (aFileName) then exit;
DB := TUserStringDB.Create;
DB.LoadFromFile (aFileName);
for i := 0 to DB.Count - 1 do begin
iName := DB.GetIndexName (i);
if iName = '' then continue;
gd.Name := iName;
gd.ViewName := DB.GetFieldValueString (iName, 'ViewName');
gd.RoomLimit := DB.GetFieldValueInteger (iName, 'RoomLimit');
gd.MinAge := DB.GetFieldValueInteger (iName, 'MinAge');
gd.MaxAge := DB.GetFieldValueInteger (iName, 'MaxAge');
gd.boGrade := DB.GetFieldValueBoolean (iName, 'boGrade');
BattleGroup := TBattleGroup.Create (@gd);
DataList.Add (BattleGroup);
frmMain.lstGroup.Items.Add (BattleGroup.GetGroupString);
end;
DB.Free;
Result := true;
end;
procedure TBattleGroupList.GetBattleGroupData (aGroupList : PTSShowListWindow; aType : Byte);
var
i : Integer;
BattleGroup : TBattleGroup;
dest : String;
begin
// FillChar (aGroupList^, SizeOf (TSShowGroupListWindow), 0);
aGroupList^.rMsg := SM_SHOWSPECIALWINDOW;
aGroupList^.rWindow := WINDOW_GROUPWINDOW;
aGroupList^.rType := aType;
dest := '';
for i := 0 to DataList.Count - 1 do begin
BattleGroup := DataList.Items [i];
dest := dest + BattleGroup.GetGroupString + ',';
end;
SetWordString (aGroupList^.rWordString, dest);
end;
procedure TBattleGroupList.GetBattleRoomData (aRoomList : PTSShowListWindow; aGroupTitle : String; aType : Byte);
var
i : Integer;
BattleGroup : TBattleGroup;
begin
for i := 0 to DataList.Count - 1 do begin
BattleGroup := DataList.Items [i];
if BattleGroup.ViewName = aGroupTitle then begin
BattleGroup.GetBattleRoomData (aRoomList, aType);
exit;
end;
end;
end;
function TBattleGroupList.CreateBattleRoom (aOwnerConnector : TConnector; aGroupTitle, aOwnerName : String; var aRetStr : String) : TBattleRoom;
var
i : Integer;
BattleGroup : TBattleGroup;
begin
Result := nil;
aRetStr := '';
for i := 0 to DataList.Count - 1 do begin
BattleGroup := DataList.Items [i];
if BattleGroup.ViewName = aGroupTitle then begin
Result := BattleGroup.CreateBattleRoom (aOwnerConnector, aOwnerName, aRetStr);
exit;
end;
end;
aRetStr := '瘤沥茄 弊缝阑 茫阑 荐 绝嚼聪促';
end;
function TBattleGroupList.FightBattleRoom (aFighterConnector : TConnector; aGroupTitle, aRoomTitle, aFighterName : String; var aRetStr : String) : TBattleRoom;
var
i : Integer;
BattleGroup : TBattleGroup;
begin
Result := nil;
for i := 0 to DataList.Count - 1 do begin
BattleGroup := DataList.Items [i];
if BattleGroup.ViewName = aGroupTitle then begin
Result := BattleGroup.FightBattleRoom (aFighterConnector, aRoomTitle, aFighterName, aRetStr);
exit;
end;
end;
aRetStr := '瘤沥茄 弊缝阑 茫阑 荐 绝嚼聪促';
end;
function TBattleGroupList.ViewBattleRoom (aGroupTitle, aRoomTitle : String; var aRetStr : String) : TBattleRoom;
var
i : Integer;
BattleGroup : TBattleGroup;
begin
Result := nil;
for i := 0 to DataList.Count - 1 do begin
BattleGroup := DataList.Items [i];
if BattleGroup.ViewName = aGroupTitle then begin
Result := BattleGroup.ViewBattleRoom (aRoomTitle, aRetStr);
exit;
end;
end;
aRetStr := '瘤沥茄 弊缝阑 茫阑 荐 绝嚼聪促';
end;
function TBattleGroupList.Get (aIndex : Integer) : Pointer;
begin
Result := nil;
if (aIndex < 0) or (aIndex >= DataList.Count) then exit;
Result := DataList.Items [aIndex];
end;
function TBattleGroupList.GetCount : Integer;
begin
Result := DataList.Count;
end;
procedure TBattleGroupList.Update (CurTick : Integer);
var
i : Integer;
BattleGroup : TBattleGroup;
begin
for i := 0 to DataList.Count - 1 do begin
BattleGroup := DataList.Items [i];
BattleGroup.Update (CurTick);
end;
end;
procedure TBattleGroupList.ShowRoomTitleList (aGroupTitle : String);
var
i : Integer;
BattleGroup : TBattleGroup;
begin
for i := 0 to DataList.Count - 1 do begin
BattleGroup := DataList.Items [i];
if BattleGroup.ViewName = aGroupTitle then begin
BattleGroup.ShowRoomTitleList;
exit;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -