40 lines
1.7 KiB
C#
40 lines
1.7 KiB
C#
using Tiger.Communication.Messages.Interfaces;
|
|
using Tiger.Communication.Messages.Types;
|
|
using Tiger.Game.Achievements;
|
|
using Tiger.Game.Habbos;
|
|
|
|
namespace Tiger.Communication.Messages.Outgoing.Inventory.Achievements;
|
|
|
|
public class AchievementComposer : IMessageComposer
|
|
{
|
|
private readonly Achievement _achievement;
|
|
private readonly HabboAchievement _habboAchievement;
|
|
|
|
public AchievementComposer(Achievement achievement, HabboAchievement habboAchievement)
|
|
{
|
|
_achievement = achievement;
|
|
_habboAchievement = habboAchievement;
|
|
}
|
|
|
|
public OutgoingHeaders Header => OutgoingHeaders.AchievementComposer;
|
|
public void Compose(ServerMessage message)
|
|
{
|
|
var targetLevel = _habboAchievement.Level == _achievement.Levels.Count
|
|
? _habboAchievement.Level
|
|
: _habboAchievement.Level + 1;
|
|
|
|
message.AppendInt32(_achievement.Id);
|
|
message.AppendInt32(targetLevel);
|
|
message.AppendString($"{_achievement.Badge}{targetLevel}");
|
|
message.AppendInt32(_habboAchievement.Progress);
|
|
message.AppendInt32(_achievement.Levels[targetLevel].ProgressNeeded);
|
|
message.AppendInt32(_achievement.Levels[targetLevel].RewardAmount);
|
|
message.AppendInt32(_achievement.Levels[targetLevel].RewardType);
|
|
message.AppendInt32(_habboAchievement.Progress);
|
|
message.AppendBoolean(_habboAchievement.Level >= _achievement.Levels.Count);
|
|
message.AppendString(_achievement.Category);
|
|
message.AppendString(string.Empty);
|
|
message.AppendInt32(_achievement.Levels.Count);
|
|
message.AppendInt32(_habboAchievement.Level >= _achievement.Levels.Count ? 1 : 0);
|
|
}
|
|
} |