[v0.1.1] some fixes and league stuff

This commit is contained in:
BreadDEV 2024-03-06 22:52:53 +07:00
parent 281d2789ea
commit 4d2d958b0e
11 changed files with 353 additions and 1 deletions

View file

@ -33,6 +33,8 @@ public class LogicClientAvatar : LogicBase
this.PlayerAttributes = new LogicPlayerAttributes(20486);
this.Inventory = new LogicInventory(20486);
this.PlayerStats = new LogicPlayerStats(20486);
this.TutorialFlags = 9999;
}
public override void Destruct()

View file

@ -0,0 +1,68 @@
using Supercell.GUT.Logic.Message.Attributes;
using Supercell.GUT.Titan.Logic.Message;
namespace Supercell.GUT.Logic.Message.Account;
[VersionedMessage(10104)]
public class ChangeAccountSettingsMessage : VersionedMessage
{
public int SettingsMap { get; set; }
public string? FacebookId { get; set; }
public string? GameCenterId { get; set; }
public string? AvatarName { get; set; }
public byte[]? DeviceToken { get; set; }
public ChangeAccountSettingsMessage() : base(0)
{
this.SettingsMap = 0;
this.FacebookId = null;
this.GameCenterId = null;
this.AvatarName = null;
this.DeviceToken = null;
}
public override void Destruct()
{
base.Destruct();
this.SettingsMap = 0;
this.FacebookId = null;
this.GameCenterId = null;
this.AvatarName = null;
this.DeviceToken = null;
}
public override int GetMessageType()
{
return 10104;
}
public override int GetServiceNodeType()
{
return 1;
}
public override void Encode()
{
base.Encode();
this.ByteStream.WriteInt(this.SettingsMap);
this.ByteStream.WriteString(this.FacebookId);
this.ByteStream.WriteString(this.GameCenterId);
this.ByteStream.WriteString(null);
this.ByteStream.WriteString(this.AvatarName);
this.ByteStream.WriteBytes(this.DeviceToken, this.DeviceToken.Length);
}
public override void Decode()
{
base.Decode();
this.SettingsMap = this.ByteStream.ReadInt();
this.FacebookId = this.ByteStream.ReadString();
this.GameCenterId = this.ByteStream.ReadString();
this.ByteStream.ReadString();
this.AvatarName = this.ByteStream.ReadString();
this.DeviceToken = this.ByteStream.ReadBytes(this.ByteStream.ReadBytesLength());
}
}

View file

@ -0,0 +1,46 @@
using Supercell.GUT.Logic.Message.Attributes;
using Supercell.GUT.Titan.Logic.Message;
namespace Supercell.GUT.Logic.Message.Avatar;
[VersionedMessage(20208)]
public class BuyFailedMessage : VersionedMessage
{
public string? Item { get; set; }
public BuyFailedMessage() : base(0)
{
Item = string.Empty;
}
public override void Destruct()
{
base.Destruct();
Item = string.Empty;
}
public override int GetMessageType()
{
return 20208;
}
public override int GetServiceNodeType()
{
return 3;
}
public override void Encode()
{
base.Encode();
ByteStream.WriteString(Item);
}
public override void Decode()
{
base.Decode();
Item = ByteStream.ReadString();
}
}

View file

@ -0,0 +1,46 @@
using Supercell.GUT.Logic.Message.Attributes;
using Supercell.GUT.Titan.Logic.Message;
namespace Supercell.GUT.Logic.Message.Avatar;
[VersionedMessage(10204)]
public class BuyMessage : VersionedMessage
{
public string? Item { get; set; }
public BuyMessage() : base(0)
{
Item = string.Empty;
}
public override void Destruct()
{
base.Destruct();
Item = string.Empty;
}
public override int GetMessageType()
{
return 10204;
}
public override int GetServiceNodeType()
{
return 3;
}
public override void Encode()
{
base.Encode();
ByteStream.WriteString(Item);
}
public override void Decode()
{
base.Decode();
Item = ByteStream.ReadString();
}
}

View file

@ -0,0 +1,46 @@
using Supercell.GUT.Logic.Message.Attributes;
using Supercell.GUT.Titan.Logic.Message;
namespace Supercell.GUT.Logic.Message.Avatar;
[VersionedMessage(20207)]
public class BuyOkMessage : VersionedMessage
{
public string? Item { get; set; }
public BuyOkMessage() : base(0)
{
Item = string.Empty;
}
public override void Destruct()
{
base.Destruct();
Item = string.Empty;
}
public override int GetMessageType()
{
return 20207;
}
public override int GetServiceNodeType()
{
return 3;
}
public override void Encode()
{
base.Encode();
ByteStream.WriteString(Item);
}
public override void Decode()
{
base.Decode();
Item = ByteStream.ReadString();
}
}

View file

@ -0,0 +1,33 @@
using Supercell.GUT.Logic.Message.Attributes;
using Supercell.GUT.Titan.Logic.Message;
namespace Supercell.GUT.Logic.Message.Account;
[VersionedMessage(10601)]
public class AskForLeagueStatsMessage : VersionedMessage
{
public AskForLeagueStatsMessage() : base(0)
{
;
}
public override void Encode()
{
base.Encode();
}
public override void Decode()
{
base.Decode();
}
public override int GetServiceNodeType()
{
return 13;
}
public override int GetMessageType()
{
return 10601;
}
}

View file

@ -0,0 +1,67 @@
using Supercell.GUT.Logic.Game;
using Supercell.GUT.Logic.Message.Attributes;
using Supercell.GUT.Titan.Logic.Message;
namespace Supercell.GUT.Logic.Message.Account;
[VersionedMessage(20601)]
public class LeagueStatsMessage : VersionedMessage
{
public int Division { get; set; }
public int League { get; set; }
public LeagueStatsMessage() : base(0)
{
this.Division = 0;
this.League = 0;
}
public override void Destruct()
{
base.Destruct();
this.Division = 0;
this.League = 0;
}
public override void Encode()
{
base.Encode();
this.ByteStream.WriteInt(this.Division);
this.ByteStream.WriteInt(this.League);
this.ByteStream.WriteInt(50);
for (int i = 0; i < 50; i++)
{
this.ByteStream.WriteInt(20486);
this.ByteStream.WriteInt(i);
this.ByteStream.WriteInt(i);
this.ByteStream.WriteInt(20486);
this.ByteStream.WriteInt(0);
this.ByteStream.WriteInt(i);
this.ByteStream.WriteString("t.me/BL4D3_BR34D");
this.ByteStream.WriteString("" + i);
this.ByteStream.WriteInt(21);
}
new LogicGameCalendar(20486).Encode(this.ByteStream);
}
public override void Decode()
{
base.Decode();
}
public override int GetServiceNodeType()
{
return 13;
}
public override int GetMessageType()
{
return 20601;
}
}

View file

@ -10,4 +10,8 @@
<ProjectReference Include="..\Supercell.GUT.Titan\Supercell.GUT.Titan.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Message\Zone\" />
</ItemGroup>
</Project>

View file

@ -40,6 +40,17 @@ internal class AccountMessageHandler : MessageHandlerBase
_connection.SetNonce(nonce);
}
[MessageHandler(10104)]
public async Task OnChangeAccountSettings(ChangeAccountSettingsMessage changeAccountSettingsMessage)
{
if (_connection.LogicClientAvatar == null)
return;
_connection.LogicClientAvatar.Name = changeAccountSettingsMessage.AvatarName;
await Task.CompletedTask;
}
[MessageHandler(10103)]
public async Task OnCreateAccount(CreateAccountMessage createAccountMessage)
{

View file

@ -44,7 +44,7 @@ internal class AvatarMessageHandler : MessageHandlerBase
[MessageHandler(10210)]
public async Task OnTutorialProgressUpdate(TutorialProgressUpdateMessage tutorialProgressUpdateMessage)
{
_connection.LogicClientAvatar!.SetTutorialFlags(tutorialProgressUpdateMessage.TutorialFlags);
// _connection.LogicClientAvatar!.SetTutorialFlags(tutorialProgressUpdateMessage.TutorialFlags);
await _documentManager.SaveAsync();
}

View file

@ -0,0 +1,29 @@
using Microsoft.Extensions.Logging;
using Supercell.GUT.Logic.Message.Account;
using Supercell.GUT.Server.Network.Connection;
using Supercell.GUT.Server.Protocol.Attributes;
namespace Supercell.GUT.Server.Protocol.Handlers;
[ServiceNode(13)]
internal class LeagueMesageHandler : MessageHandlerBase
{
private readonly ILogger _logger;
private readonly ClientConnection _connection;
public LeagueMesageHandler(ClientConnection connection, ILogger<LeagueMesageHandler> logger)
{
_logger = logger;
_connection = connection;
}
[MessageHandler(10601)]
public async Task OnAskForLeagueStats(AskForLeagueStatsMessage askForLeagueStatsMessage)
{
await _connection.SendMessage(new LeagueStatsMessage()
{
Division = 1,
League = 0,
});
}
}