This repository has been archived on 2024-03-29. You can view files and clone it, but cannot push or open issues or pull requests.
FreeSR/FreeSR.Gateserver/Manager/Handlers/LineupReqGroup.cs

179 lines
6.3 KiB
C#
Raw Permalink Normal View History

2024-01-27 13:06:07 +00:00
namespace FreeSR.Gateserver.Manager.Handlers
{
using FreeSR.Gateserver.Manager.Handlers.Core;
using FreeSR.Gateserver.Network;
using FreeSR.Proto;
internal static class LineupReqGroup
{
public static uint Avatar1 = 8001;
2024-02-21 06:41:22 +00:00
public static uint Avatar2 = 1308;
public static uint Avatar3 = 1304;
public static uint Avatar4 = 1301;
2024-01-27 13:08:24 +00:00
[Handler(CmdType.CmdGetCurLineupDataCsReq)]
2024-01-27 13:06:07 +00:00
public static void OnGetCurLineupDataCsReq(NetSession session, int cmdId, object _)
{
var response = new GetCurLineupDataScRsp
{
2024-02-21 06:41:22 +00:00
Retcode = 0
2024-01-27 13:06:07 +00:00
};
response.Lineup = new LineupInfo
{
2024-01-27 13:08:24 +00:00
ExtraLineupType = ExtraLineupType.LineupNone,
2024-01-27 13:06:07 +00:00
Name = "Squad 1",
2024-01-27 13:08:24 +00:00
LeaderSlot = 0,
2024-01-28 03:58:19 +00:00
Mp = 5,
MaxMp = 5
2024-01-27 13:06:07 +00:00
};
var characters = new uint[] { Avatar1, Avatar2, Avatar3, Avatar4 };
2024-01-27 13:06:07 +00:00
2024-01-27 13:08:24 +00:00
foreach (uint id in characters)
2024-01-27 13:06:07 +00:00
{
2024-01-27 13:08:24 +00:00
response.Lineup.AvatarLists.Add(new LineupAvatar
2024-01-27 13:06:07 +00:00
{
2024-01-27 13:08:24 +00:00
AvatarType = AvatarType.AvatarFormalType,
Hp = 10000,
Sp = new AmountInfo { CurAmount = 10000,MaxAmount = 10000},
2024-01-27 13:06:07 +00:00
Satiety = 100,
Id = id,
2024-01-27 13:08:24 +00:00
Slot = (uint)response.Lineup.AvatarLists.Count
2024-01-27 13:06:07 +00:00
});
}
2024-01-27 13:08:24 +00:00
session.Send(CmdType.CmdGetCurLineupDataScRsp, response);
2024-01-27 13:06:07 +00:00
}
2024-01-27 13:08:24 +00:00
[Handler(CmdType.CmdGetAllLineupDataCsReq)]
2024-01-27 13:06:07 +00:00
public static void OnGetAllLineupDataCsReq(NetSession session, int cmdId, object data)
{
var response = new GetAllLineupDataScRsp
{
2024-02-21 06:41:22 +00:00
Retcode = 0,
2024-01-27 13:06:07 +00:00
CurIndex = 0,
};
2024-01-27 13:08:24 +00:00
response.LineupLists.Add(new LineupInfo
2024-01-27 13:06:07 +00:00
{
2024-01-27 13:08:24 +00:00
ExtraLineupType = ExtraLineupType.LineupNone,
2024-01-27 13:06:07 +00:00
Name = "Squad 1",
2024-01-27 13:08:24 +00:00
Mp = 5,
2024-01-28 03:58:19 +00:00
MaxMp = 5,
2024-01-27 13:08:24 +00:00
LeaderSlot = 0
2024-01-27 13:06:07 +00:00
});
var characters = new uint[] { Avatar1, Avatar2, Avatar3, Avatar4 };
2024-01-27 13:06:07 +00:00
2024-01-27 13:08:24 +00:00
foreach (uint id in characters)
2024-01-27 13:06:07 +00:00
{
2024-01-27 13:08:24 +00:00
response.LineupLists[0].AvatarLists.Add(new LineupAvatar
2024-01-27 13:06:07 +00:00
{
2024-01-27 13:08:24 +00:00
AvatarType = AvatarType.AvatarFormalType,
Sp = new AmountInfo { CurAmount = 10000, MaxAmount = 10000 },
Hp = 10000,
2024-01-27 13:06:07 +00:00
Satiety = 100,
Id = id,
2024-01-27 13:08:24 +00:00
Slot = (uint)response.LineupLists[0].AvatarLists.Count
2024-01-27 13:06:07 +00:00
});
}
2024-01-27 13:08:24 +00:00
session.Send(CmdType.CmdGetAllLineupDataScRsp, response);
2024-01-27 13:06:07 +00:00
}
2024-01-27 13:08:24 +00:00
[Handler(CmdType.CmdChangeLineupLeaderCsReq)]
2024-01-27 13:06:07 +00:00
public static void OnChangeLineupLeaderCsReq(NetSession session, int cmdId, object data)
{
var request = data as ChangeLineupLeaderCsReq;
2024-01-27 13:08:24 +00:00
session.Send(CmdType.CmdChangeLineupLeaderScRsp, new ChangeLineupLeaderScRsp
2024-01-27 13:06:07 +00:00
{
Slot = request.Slot,
2024-02-21 06:41:22 +00:00
Retcode = 0
2024-01-27 13:06:07 +00:00
});
}
[Handler(CmdType.CmdJoinLineupCsReq)]
public static void OnJoinLineupCsReq(NetSession session, int cmdId, object data)
{
var request = data as JoinLineupCsReq;
if (request.Slot == 0) Avatar1 = request.BaseAvatarId;
if (request.Slot == 1) Avatar2 = request.BaseAvatarId;
if (request.Slot == 2) Avatar3 = request.BaseAvatarId;
if (request.Slot == 3) Avatar4 = request.BaseAvatarId;
RefreshLineup(session);
session.Send(CmdType.CmdJoinLineupScRsp, new JoinLineupScRsp
{
2024-02-21 06:41:22 +00:00
Retcode = 0
});
}
[Handler(CmdType.CmdReplaceLineupCsReq)]
public static void OnReplaceLineupCsReq(NetSession session, int cmdId, object data)
{
var request = data as ReplaceLineupCsReq;
Avatar1 = 0; Avatar2 = 0; Avatar3 = 0; Avatar4 = 0;
foreach (LineupSlotData slotData in request.LineupSlotLists)
{
if (slotData.Slot == 0) Avatar1 = slotData.Id;
if (slotData.Slot == 1) Avatar2 = slotData.Id;
if (slotData.Slot == 2) Avatar3 = slotData.Id;
if (slotData.Slot == 3) Avatar4 = slotData.Id;
}
RefreshLineup(session);
session.Send(CmdType.CmdReplaceLineupScRsp, new ReplaceLineupScRsp
{
2024-02-21 06:41:22 +00:00
Retcode = 0
});
}
[Handler(CmdType.CmdQuitLineupCsReq)]
public static void OnQuitLineupCsReq(NetSession session, int cmdId, object data)
{
var request = data as QuitLineupCsReq;
if (request.BaseAvatarId == Avatar1) Avatar1 = 0;
if (request.BaseAvatarId == Avatar2) Avatar2 = 0;
if (request.BaseAvatarId == Avatar3) Avatar3 = 0;
if (request.BaseAvatarId == Avatar4) Avatar4 = 0;
RefreshLineup(session);
session.Send(CmdType.CmdQuitLineupScRsp, new QuitLineupScRsp
{
2024-02-21 06:41:22 +00:00
Retcode = 0,
BaseAvatarId = request.BaseAvatarId,
IsVirtual = request.IsVirtual
});
}
public static void RefreshLineup(NetSession session) {
var characters = new uint[] { Avatar1, Avatar2, Avatar3, Avatar4 };
var response = new SyncLineupNotify
{
Lineup = new LineupInfo
{
ExtraLineupType = ExtraLineupType.LineupNone,
Name = "Squad 1",
Mp = 5,
MaxMp = 5,
LeaderSlot = 0
}
};
foreach (uint id in characters)
{
if (id == 0) continue;
response.Lineup.AvatarLists.Add(new LineupAvatar
{
AvatarType = AvatarType.AvatarFormalType,
Sp = new AmountInfo { CurAmount = 10000, MaxAmount = 10000 },
Hp = 10000,
Satiety = 100,
Id = id,
Slot = (uint)response.Lineup.AvatarLists.Count
});
}
session.Send(CmdType.CmdSyncLineupNotify, response);
}
2024-01-27 13:06:07 +00:00
}
}