diff --git a/Supercell.GUT.Logic/Avatar/LogicClientAvatar.cs b/Supercell.GUT.Logic/Avatar/LogicClientAvatar.cs index dad32ff..240cdc1 100644 --- a/Supercell.GUT.Logic/Avatar/LogicClientAvatar.cs +++ b/Supercell.GUT.Logic/Avatar/LogicClientAvatar.cs @@ -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() diff --git a/Supercell.GUT.Logic/Message/Account/ChangeAccountSettingsMessage.cs b/Supercell.GUT.Logic/Message/Account/ChangeAccountSettingsMessage.cs new file mode 100644 index 0000000..35daf33 --- /dev/null +++ b/Supercell.GUT.Logic/Message/Account/ChangeAccountSettingsMessage.cs @@ -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()); + } +} diff --git a/Supercell.GUT.Logic/Message/Avatar/BuyFailedMessage.cs b/Supercell.GUT.Logic/Message/Avatar/BuyFailedMessage.cs new file mode 100644 index 0000000..e2697c4 --- /dev/null +++ b/Supercell.GUT.Logic/Message/Avatar/BuyFailedMessage.cs @@ -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(); + } +} diff --git a/Supercell.GUT.Logic/Message/Avatar/BuyMessage.cs b/Supercell.GUT.Logic/Message/Avatar/BuyMessage.cs new file mode 100644 index 0000000..01d8b68 --- /dev/null +++ b/Supercell.GUT.Logic/Message/Avatar/BuyMessage.cs @@ -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(); + } +} diff --git a/Supercell.GUT.Logic/Message/Avatar/BuyOkMessage.cs b/Supercell.GUT.Logic/Message/Avatar/BuyOkMessage.cs new file mode 100644 index 0000000..9bd6a0c --- /dev/null +++ b/Supercell.GUT.Logic/Message/Avatar/BuyOkMessage.cs @@ -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(); + } +} diff --git a/Supercell.GUT.Logic/Message/League/AskForLeagueStatsMessage.cs b/Supercell.GUT.Logic/Message/League/AskForLeagueStatsMessage.cs new file mode 100644 index 0000000..57e857e --- /dev/null +++ b/Supercell.GUT.Logic/Message/League/AskForLeagueStatsMessage.cs @@ -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; + } +} diff --git a/Supercell.GUT.Logic/Message/League/LeagueStatsMessage.cs b/Supercell.GUT.Logic/Message/League/LeagueStatsMessage.cs new file mode 100644 index 0000000..3ce29b9 --- /dev/null +++ b/Supercell.GUT.Logic/Message/League/LeagueStatsMessage.cs @@ -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; + } +} diff --git a/Supercell.GUT.Logic/Supercell.GUT.Logic.csproj b/Supercell.GUT.Logic/Supercell.GUT.Logic.csproj index b21cae9..4576adc 100644 --- a/Supercell.GUT.Logic/Supercell.GUT.Logic.csproj +++ b/Supercell.GUT.Logic/Supercell.GUT.Logic.csproj @@ -10,4 +10,8 @@ + + + + diff --git a/Supercell.GUT.Server/Protocol/Handlers/AccountMessageHandler.cs b/Supercell.GUT.Server/Protocol/Handlers/AccountMessageHandler.cs index 1ac0d19..416ce5d 100644 --- a/Supercell.GUT.Server/Protocol/Handlers/AccountMessageHandler.cs +++ b/Supercell.GUT.Server/Protocol/Handlers/AccountMessageHandler.cs @@ -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) { diff --git a/Supercell.GUT.Server/Protocol/Handlers/AvatarMessageHandler.cs b/Supercell.GUT.Server/Protocol/Handlers/AvatarMessageHandler.cs index a837036..1b6ee64 100644 --- a/Supercell.GUT.Server/Protocol/Handlers/AvatarMessageHandler.cs +++ b/Supercell.GUT.Server/Protocol/Handlers/AvatarMessageHandler.cs @@ -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(); } diff --git a/Supercell.GUT.Server/Protocol/Handlers/LeagueMesageHandler.cs b/Supercell.GUT.Server/Protocol/Handlers/LeagueMesageHandler.cs new file mode 100644 index 0000000..6f09afb --- /dev/null +++ b/Supercell.GUT.Server/Protocol/Handlers/LeagueMesageHandler.cs @@ -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 logger) + { + _logger = logger; + _connection = connection; + } + + [MessageHandler(10601)] + public async Task OnAskForLeagueStats(AskForLeagueStatsMessage askForLeagueStatsMessage) + { + await _connection.SendMessage(new LeagueStatsMessage() + { + Division = 1, + League = 0, + }); + } +}