Implement AddFriendQuery/Reply

This commit is contained in:
Ray Koopa 2019-01-22 21:22:38 +01:00
parent e9c88caadc
commit 5c84357edb
4 changed files with 80 additions and 1 deletions

View File

@ -8,12 +8,21 @@ namespace Syroot.Worms.Mgame.GameServer
{
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
public void HandleWwpaChannelAddFriend(AddFriendQuery packet)
{
SendPacket(new AddFriendReply
{
Result = FriendRequestResult.Success,
UserName = packet.UserName
});
}
public void HandleWwpaChannelCmdFindUser(CmdFindUserQuery packet)
{
SendPacket(new CmdFindUserReply
{
Success = true,
NickName = "Fuckerman",
NickName = packet.UserName,
Gender = UserGender.Male,
GamesWon = 12,
GamesLost = 17,

View File

@ -0,0 +1,28 @@
using System;
using Syroot.BinaryData.Memory;
namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua.Channel
{
/// <summary>
/// Represents the client request for an <see cref="AddFriendReply"/>.
/// </summary>
[WwpaPacket(0x15C)]
internal class AddFriendQuery : IPacket
{
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
/// <summary>
/// Gets or sets the name of the user to add as a friend.
/// </summary>
public string UserName { get; set; }
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
public void Load(ref SpanReader reader)
{
UserName = reader.ReadString2();
}
public void Save(ref SpanWriter writer) => throw new NotImplementedException();
}
}

View File

@ -0,0 +1,39 @@
using System;
using Syroot.BinaryData.Memory;
namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua.Channel
{
/// <summary>
/// Represents the server response to an <see cref="AddFriendQuery"/>.
/// </summary>
[WwpaPacket(0x15D)]
internal class AddFriendReply : IPacket
{
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
public FriendRequestResult Result { get; set; }
/// <summary>
/// Gets or sets the name of the user who was added as a friend.
/// </summary>
public string UserName { get; set; }
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
public void Load(ref SpanReader reader) => throw new NotImplementedException();
public void Save(ref SpanWriter writer)
{
writer.WriteEnumSafe(Result);
if (Result == FriendRequestResult.Success)
writer.WriteString2(UserName);
}
}
internal enum FriendRequestResult : int
{
Success = 0,
NotFound = 1,
Fail = 99
}
}

View File

@ -11,6 +11,9 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua.Channel
{
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
/// <summary>
/// Gets or sets the name of the user to search.
/// </summary>
public string UserName { get; set; }
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------