Added credits, activitypoints and moved some files
parent
f4690c2dd3
commit
5ed8eb6913
|
@ -0,0 +1,30 @@
|
|||
using Tiger.Communication.Messages.Interfaces;
|
||||
using Tiger.Communication.Messages.Outgoing.Notifications;
|
||||
using Tiger.Communication.Messages.Outgoing.Users;
|
||||
using Tiger.Communication.Messages.Types;
|
||||
using Tiger.Networking.Game.Sessions;
|
||||
|
||||
namespace Tiger.Communication.Messages.Incoming.Inventory.Purse;
|
||||
|
||||
public class GetCreditsInfoEvent : IMessageEvent
|
||||
{
|
||||
private readonly IGameSessionManager _gameSessionManager;
|
||||
|
||||
public GetCreditsInfoEvent(IGameSessionManager gameSessionManager)
|
||||
{
|
||||
_gameSessionManager = gameSessionManager;
|
||||
}
|
||||
|
||||
public IncomingHeaders Header => IncomingHeaders.GetCreditsInfoEvent;
|
||||
public async Task HandleAsync(GameSession gameSession, ClientMessage request)
|
||||
{
|
||||
if (gameSession.Habbo == null)
|
||||
{
|
||||
await _gameSessionManager.CloseAsync("Not logged in", gameSession);
|
||||
return;
|
||||
}
|
||||
|
||||
await gameSession.SendComposerAsync(new CreditBalanceComposer(gameSession.Habbo.Credits));
|
||||
await gameSession.SendComposerAsync(new ActivityPointsComposer(gameSession.Habbo.Activitypoints ?? null));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
using Tiger.Communication.Messages.Interfaces;
|
||||
using Tiger.Communication.Messages.Types;
|
||||
using Tiger.Game.Habbos;
|
||||
|
||||
namespace Tiger.Communication.Messages.Outgoing.Notifications;
|
||||
|
||||
public class ActivityPointsComposer : IMessageComposer
|
||||
{
|
||||
private readonly IEnumerable<Activitypoints>? _activitypoints;
|
||||
|
||||
public ActivityPointsComposer(IEnumerable<Activitypoints>? activitypoints)
|
||||
{
|
||||
_activitypoints = activitypoints;
|
||||
}
|
||||
|
||||
public OutgoingHeaders Header => OutgoingHeaders.ActivityPointsMessageComposer;
|
||||
public void Compose(ServerMessage message)
|
||||
{
|
||||
message.AppendInt32(_activitypoints?.Count() ?? 0);
|
||||
|
||||
if (_activitypoints == null) return;
|
||||
|
||||
foreach (var activitypoint in _activitypoints)
|
||||
{
|
||||
message.AppendInt32(activitypoint.Type);
|
||||
message.AppendUInt32(activitypoint.Amount);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
using Tiger.Communication.Messages.Interfaces;
|
||||
using Tiger.Communication.Messages.Types;
|
||||
|
||||
namespace Tiger.Communication.Messages.Outgoing.Users;
|
||||
|
||||
public class CreditBalanceComposer : IMessageComposer
|
||||
{
|
||||
private readonly uint _credits;
|
||||
|
||||
public CreditBalanceComposer(uint credits)
|
||||
{
|
||||
_credits = credits;
|
||||
}
|
||||
|
||||
public OutgoingHeaders Header => OutgoingHeaders.CreditBalanceComposer;
|
||||
public void Compose(ServerMessage message)
|
||||
{
|
||||
message.AppendString($"{_credits}.0");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
namespace Tiger.Game.Habbos;
|
||||
|
||||
public class Activitypoints
|
||||
{
|
||||
public virtual Habbo Habbo { get; set; } = null!;
|
||||
public virtual byte Type { get; set; }
|
||||
public virtual uint Amount { get; set; }
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is not Activitypoints other)
|
||||
return false;
|
||||
|
||||
return Habbo.Id == other.Habbo.Id && Type == other.Type;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hash = 17;
|
||||
hash = hash * 23 + Habbo.Id.GetHashCode();
|
||||
hash = hash * 23 + Type.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
using FluentNHibernate.Mapping;
|
||||
|
||||
namespace Tiger.Game.Habbos;
|
||||
|
||||
public class ActivitypointsMap : ClassMap<Activitypoints>
|
||||
{
|
||||
public ActivitypointsMap()
|
||||
{
|
||||
Table("habbo_activitypoints");
|
||||
LazyLoad();
|
||||
CompositeId()
|
||||
.KeyProperty(h => h.Type, "type")
|
||||
.KeyReference(h => h.Habbo, "habbo_id");
|
||||
Map(h => h.Amount).Column("amount").Not.Nullable();
|
||||
}
|
||||
}
|
|
@ -17,4 +17,5 @@ public class Habbo
|
|||
public virtual uint AchievementScore { get; set; }
|
||||
public virtual uint? GroupId { get; set; }
|
||||
public virtual string? SsoTicket { get; set; }
|
||||
public virtual IEnumerable<Activitypoints>? Activitypoints { get; set; }
|
||||
}
|
|
@ -23,5 +23,6 @@ public class HabboMap : ClassMap<Habbo>
|
|||
Map(h => h.AchievementScore).Column("achievement_score").Not.Nullable();
|
||||
Map(h => h.GroupId).Column("group_id").Nullable();
|
||||
Map(h => h.SsoTicket).Column("sso_ticket").Nullable();
|
||||
HasMany<Activitypoints>(h => h.Activitypoints).LazyLoad().Inverse().Cascade.All();
|
||||
}
|
||||
}
|
|
@ -26,4 +26,7 @@
|
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Communication\Messages\Incoming\Users\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
Loading…
Reference in New Issue