forked from PGR/ascnet
1
0
Fork 0
ascnet/AscNet.GameServer/Handlers/CharacterModule.cs

31 lines
1.3 KiB
C#
Raw Normal View History

using AscNet.Common.Database;
using AscNet.Common.MsgPack;
namespace AscNet.GameServer.Handlers
{
internal class CharacterModule
{
[RequestPacketHandler("CharacterUpgradeSkillGroupRequest")]
public static void CharacterUpgradeSkillGroupRequestHandler(Session session, Packet.Request packet)
{
CharacterUpgradeSkillGroupRequest request = packet.Deserialize<CharacterUpgradeSkillGroupRequest>();
var upgradeResult = session.character.UpgradeCharacterSkillGroup(request.SkillGroupId, request.Count);
NotifyCharacterDataList notifyCharacterData = new();
notifyCharacterData.CharacterDataList.AddRange(session.character.Characters.Where(x => upgradeResult.AffectedCharacters.Contains(x.Id)));
NotifyItemDataList notifyItemData = new();
2023-11-20 15:19:46 +00:00
notifyItemData.ItemDataList.AddRange(new Item[] {
session.inventory.Do(Inventory.Coin, upgradeResult.CoinCost * -1),
session.inventory.Do(Inventory.SkillPoint, upgradeResult.SkillPointCost * -1)
});
session.SendPush(notifyCharacterData);
session.SendPush(notifyItemData);
session.SendResponse(new CharacterUpgradeSkillGroupResponse(), packet.Id);
}
}
}