mirror of
https://git.lewd.wtf/PGR/ascnet
synced 2025-12-12 19:24:36 +01:00
item enhane
This commit is contained in:
@@ -134,7 +134,6 @@ namespace AscNet.GameServer.Handlers
|
||||
BaseEquipLoginData = new(),
|
||||
FubenData = new()
|
||||
{
|
||||
StageData = session.stage.Stages,
|
||||
FubenBaseData = new()
|
||||
},
|
||||
FubenMainLineData = new(),
|
||||
@@ -148,6 +147,12 @@ namespace AscNet.GameServer.Handlers
|
||||
|
||||
#if DEBUG
|
||||
notifyLogin.PlayerData.GuideData = GuideGroupTableReader.Instance.All.Select(x => (long)x.Id).ToList();
|
||||
#endif
|
||||
|
||||
NotifyStageData notifyStageData = new()
|
||||
{
|
||||
StageList = session.stage.Stages.Values.ToList()
|
||||
};
|
||||
|
||||
StageDatum stageForChat = new()
|
||||
{
|
||||
@@ -166,9 +171,9 @@ namespace AscNet.GameServer.Handlers
|
||||
BestCardIds = new List<long> { 1021001 },
|
||||
LastCardIds = new List<long> { 1021001 }
|
||||
};
|
||||
if (!notifyLogin.FubenData.StageData.ContainsKey(stageForChat.StageId))
|
||||
notifyLogin.FubenData.StageData = notifyLogin.FubenData.StageData.Append(new(stageForChat.StageId, stageForChat)).ToDictionary(x => x.Key, x => x.Value);
|
||||
#endif
|
||||
|
||||
if (!notifyStageData.StageList.Any(x => x.StageId == stageForChat.StageId))
|
||||
notifyStageData.StageList = notifyStageData.StageList.Append(stageForChat).ToList();
|
||||
|
||||
NotifyCharacterDataList notifyCharacterData = new();
|
||||
notifyCharacterData.CharacterDataList.AddRange(session.character.Characters);
|
||||
@@ -203,6 +208,7 @@ namespace AscNet.GameServer.Handlers
|
||||
};
|
||||
|
||||
session.SendPush(notifyLogin);
|
||||
session.SendPush(notifyStageData);
|
||||
session.SendPush(notifyCharacterData);
|
||||
session.SendPush(notifyEquipData);
|
||||
session.SendPush(notifyAssistData);
|
||||
|
||||
74
AscNet.GameServer/Handlers/EquipModule.cs
Normal file
74
AscNet.GameServer/Handlers/EquipModule.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using AscNet.Common;
|
||||
using AscNet.Common.Database;
|
||||
using AscNet.Common.MsgPack;
|
||||
using AscNet.Common.Util;
|
||||
using AscNet.Table.V2.share.item;
|
||||
using MessagePack;
|
||||
|
||||
namespace AscNet.GameServer.Handlers
|
||||
{
|
||||
#region MsgPackScheme
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
[MessagePackObject(true)]
|
||||
public class EquipLevelUpRequest
|
||||
{
|
||||
public int EquipId;
|
||||
public Dictionary<int, int> UseItems;
|
||||
public List<int> UseEquipIdList;
|
||||
}
|
||||
|
||||
[MessagePackObject(true)]
|
||||
public class EquipLevelUpResponse
|
||||
{
|
||||
public int Code;
|
||||
public int Level;
|
||||
public int Exp;
|
||||
}
|
||||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
#endregion
|
||||
|
||||
internal class EquipModule
|
||||
{
|
||||
[RequestPacketHandler("EquipLevelUpRequest")]
|
||||
public static void EquipLevelUpRequestHandler(Session session, Packet.Request packet)
|
||||
{
|
||||
EquipLevelUpRequest request = packet.Deserialize<EquipLevelUpRequest>();
|
||||
|
||||
NotifyItemDataList notifyItemData = new();
|
||||
int totalExp = 0;
|
||||
int totalCost = 0;
|
||||
foreach (var item in request.UseItems)
|
||||
{
|
||||
ItemTable? itemTable = TableReaderV2.Parse<ItemTable>().FirstOrDefault(x => x.Id == item.Key);
|
||||
if (itemTable is not null)
|
||||
{
|
||||
var upgradeInfo = itemTable.GetEquipUpgradeInfo() * item.Value;
|
||||
totalExp += upgradeInfo.Exp;
|
||||
totalCost += upgradeInfo.Cost;
|
||||
notifyItemData.ItemDataList.Add(session.inventory.Do(item.Key, item.Value * -1));
|
||||
}
|
||||
}
|
||||
|
||||
notifyItemData.ItemDataList.Add(session.inventory.Do(Inventory.Coin, totalCost * -1));
|
||||
session.SendPush(notifyItemData);
|
||||
|
||||
EquipLevelUpResponse rsp = new()
|
||||
{
|
||||
Code = 0
|
||||
};
|
||||
|
||||
var upEquip = session.character.AddEquipExp(request.EquipId, totalExp);
|
||||
if (upEquip != null)
|
||||
{
|
||||
rsp.Level = upEquip.Level;
|
||||
rsp.Exp = upEquip.Exp;
|
||||
|
||||
NotifyEquipDataList notifyEquipDataList = new();
|
||||
notifyEquipDataList.EquipDataList.Add(upEquip);
|
||||
session.SendPush(notifyEquipDataList);
|
||||
}
|
||||
|
||||
session.SendResponse(rsp, packet.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,6 +208,10 @@ namespace AscNet.GameServer.Handlers
|
||||
|
||||
List<RewardGoods> rewards = new();
|
||||
List<RewardTable> rewardTables = TableReaderV2.Parse<RewardTable>().Where(x => session.stage.Stages.ContainsKey(req.Result.StageId) ? x.Id == stageTable.FinishDropId : (x.Id == stageTable.FinishDropId || x.Id == stageTable.FirstRewardId)).ToList();
|
||||
if (rewardTables.Count == 0)
|
||||
{
|
||||
rewardTables.AddRange(TableReaderV2.Parse<RewardTable>().Where(x => session.stage.Stages.ContainsKey(req.Result.StageId) ? x.Id == stageTable.FinishRewardShow : (x.Id == stageTable.FinishRewardShow || x.Id == stageTable.FirstRewardShow)));
|
||||
}
|
||||
|
||||
NotifyItemDataList notifyItemData = new();
|
||||
notifyItemData.ItemDataList.Add(session.inventory.Do(Inventory.TeamExp, stageTable.TeamExp ?? 0));
|
||||
|
||||
@@ -23,5 +23,17 @@ namespace AscNet.GameServer.Handlers
|
||||
|
||||
session.SendResponse(rsp, packet.Id);
|
||||
}
|
||||
|
||||
[RequestPacketHandler("GetShopInfoRequest")]
|
||||
public static void GetShopInfoRequestHandler(Session session, Packet.Request packet)
|
||||
{
|
||||
GetShopInfoResponse rsp = new()
|
||||
{
|
||||
Code = 0,
|
||||
ClientShop = { }
|
||||
};
|
||||
|
||||
session.SendResponse(rsp, packet.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user