From f2ee2b7018b0f9b1f383a0a68a4b8f11a41f0182 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sat, 12 Feb 2022 17:21:57 +0100 Subject: [PATCH] feat(game): add character sp points --- .../Data/Characters/Character.cs | 21 ++++++--- .../Extensions/ServiceCollectionExtensions.cs | 2 + .../PacketHandlers/Specialists/SpResponder.cs | 45 +++++++++++++++++++ 3 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 Core/NosSmooth.Game/PacketHandlers/Specialists/SpResponder.cs diff --git a/Core/NosSmooth.Game/Data/Characters/Character.cs b/Core/NosSmooth.Game/Data/Characters/Character.cs index ae383f3..5dee80c 100644 --- a/Core/NosSmooth.Game/Data/Characters/Character.cs +++ b/Core/NosSmooth.Game/Data/Characters/Character.cs @@ -18,11 +18,6 @@ namespace NosSmooth.Game.Data.Characters; /// public class Character : Player { - /// - /// Gets or sets whether the character can't move. - /// - public bool Stunned { get; set; } - /// /// Gets or sets the inventory of the character. /// @@ -78,4 +73,20 @@ public class Character : Player } } } + + /// + /// Gets or sets the sp points of the player. + /// + /// + /// Resets every day, max 10 000. + /// + public int SpPoints { get; set; } + + /// + /// Gets or sets the additional sp points of the player. + /// + /// + /// Used if are 0. Max 1 000 000 + /// + public int AdditionalSpPoints { get; set; } } \ No newline at end of file diff --git a/Core/NosSmooth.Game/Extensions/ServiceCollectionExtensions.cs b/Core/NosSmooth.Game/Extensions/ServiceCollectionExtensions.cs index e381006..423d6c8 100644 --- a/Core/NosSmooth.Game/Extensions/ServiceCollectionExtensions.cs +++ b/Core/NosSmooth.Game/Extensions/ServiceCollectionExtensions.cs @@ -12,6 +12,7 @@ using NosSmooth.Game.Events.Core; using NosSmooth.Game.PacketHandlers.Characters; using NosSmooth.Game.PacketHandlers.Entities; using NosSmooth.Game.PacketHandlers.Map; +using NosSmooth.Game.PacketHandlers.Specialists; namespace NosSmooth.Game.Extensions; @@ -49,6 +50,7 @@ public static class ServiceCollectionExtensions .AddPacketResponder() .AddPacketResponder() .AddPacketResponder() + .AddPacketResponder() .AddPacketResponder(); serviceCollection diff --git a/Core/NosSmooth.Game/PacketHandlers/Specialists/SpResponder.cs b/Core/NosSmooth.Game/PacketHandlers/Specialists/SpResponder.cs new file mode 100644 index 0000000..869f69e --- /dev/null +++ b/Core/NosSmooth.Game/PacketHandlers/Specialists/SpResponder.cs @@ -0,0 +1,45 @@ +// +// SpResponder.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Core.Packets; +using NosSmooth.Packets.Server.Specialists; +using Remora.Results; + +namespace NosSmooth.Game.PacketHandlers.Specialists; + +/// +/// Responds to sp packet. +/// +public class SpResponder : IPacketResponder +{ + private readonly Game _game; + + /// + /// Initializes a new instance of the class. + /// + /// The game. + public SpResponder(Game game) + { + _game = game; + } + + /// + public Task Respond(PacketEventArgs packetArgs, CancellationToken ct = default) + { + var packet = packetArgs.Packet; + var character = _game.Character; + + if (character is null) + { + return Task.FromResult(Result.FromSuccess()); + } + + character.SpPoints = packet.SpPoints; + character.AdditionalSpPoints = packet.AdditionalSpPoints; + + return Task.FromResult(Result.FromSuccess()); + } +} \ No newline at end of file -- 2.49.0