37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
using Tiger.Communication.Messages.Interfaces;
|
|
using Tiger.Communication.Messages.Types;
|
|
using Tiger.Game.Habbos;
|
|
|
|
namespace Tiger.Communication.Messages.Outgoing.Inventory.Badges;
|
|
|
|
public class BadgesComposer : IMessageComposer
|
|
{
|
|
private readonly IReadOnlyList<Badge> _badges;
|
|
|
|
public BadgesComposer(IEnumerable<Badge>? badges)
|
|
{
|
|
_badges = badges != null ? badges.ToList() : new List<Badge>();
|
|
}
|
|
|
|
public OutgoingHeaders Header => OutgoingHeaders.UserBadges;
|
|
public void Compose(ServerMessage message)
|
|
{
|
|
message.AppendInt32(_badges.Count);
|
|
|
|
foreach (var badge in _badges)
|
|
{
|
|
message.AppendInt32(badge.Id);
|
|
message.AppendString(badge.Code);
|
|
}
|
|
|
|
var wearingBadges = _badges.Where(b => b.Slot > 0).ToList();
|
|
|
|
message.AppendInt32(wearingBadges.Count);
|
|
|
|
foreach (var wearingBadge in wearingBadges)
|
|
{
|
|
message.AppendInt32(wearingBadge.Slot);
|
|
message.AppendString(wearingBadge.Code);
|
|
}
|
|
}
|
|
} |