TeamExp on stage settle

This commit is contained in:
rfi 2023-11-25 18:56:53 +07:00
parent 556477d312
commit f00e16c7a1
3 changed files with 66 additions and 4 deletions

View File

@ -140,7 +140,6 @@ namespace AscNet.GameServer.Handlers
FubenMainLineData = new(), FubenMainLineData = new(),
FubenChapterExtraLoginData = new(), FubenChapterExtraLoginData = new(),
FubenUrgentEventData = new(), FubenUrgentEventData = new(),
ItemList = session.inventory.Items,
UseBackgroundId = 14000001 // main ui theme, table still failed to dump UseBackgroundId = 14000001 // main ui theme, table still failed to dump
}; };
if (notifyLogin.PlayerData.DisplayCharIdList.Count < 1) if (notifyLogin.PlayerData.DisplayCharIdList.Count < 1)
@ -191,11 +190,24 @@ namespace AscNet.GameServer.Handlers
UnlockEmojis = EmojiTableReader.Instance.All.Select(x => new NotifyChatLoginData.NotifyChatLoginDataUnlockEmoji() { Id = (uint)x.Id }).ToList() UnlockEmojis = EmojiTableReader.Instance.All.Select(x => new NotifyChatLoginData.NotifyChatLoginDataUnlockEmoji() { Id = (uint)x.Id }).ToList()
}; };
NotifyItemDataList notifyItemDataList = new()
{
/*ItemDataList = TableReaderV2.Parse<Table.V2.share.item.ItemTable>().Select(x => new Item()
{
Id = x.Id,
Count = x.MaxCount ?? 999_999_999,
RefreshTime = DateTimeOffset.Now.ToUnixTimeSeconds(),
CreateTime = DateTimeOffset.Now.ToUnixTimeSeconds()
}).ToList(),*/
ItemDataList = session.inventory.Items
};
session.SendPush(notifyLogin); session.SendPush(notifyLogin);
session.SendPush(notifyCharacterData); session.SendPush(notifyCharacterData);
session.SendPush(notifyEquipData); session.SendPush(notifyEquipData);
session.SendPush(notifyAssistData); session.SendPush(notifyAssistData);
session.SendPush(notifyChatLoginData); session.SendPush(notifyChatLoginData);
session.SendPush(notifyItemDataList);
#region DisclamerMail #region DisclamerMail
NotifyMails notifyMails = new(); NotifyMails notifyMails = new();

View File

@ -1,4 +1,5 @@
using AscNet.Common.MsgPack; using AscNet.Common.Database;
using AscNet.Common.MsgPack;
using AscNet.Common.Util; using AscNet.Common.Util;
using AscNet.Table.share.fuben; using AscNet.Table.share.fuben;
using AscNet.Table.V2.share.reward; using AscNet.Table.V2.share.reward;
@ -204,9 +205,13 @@ namespace AscNet.GameServer.Handlers
session.SendResponse(new FightSettleResponse() { Code = 20032004 }, packet.Id); session.SendResponse(new FightSettleResponse() { Code = 20032004 }, packet.Id);
return; return;
} }
List<RewardGoods> rewards = new(); 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(); 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();
NotifyItemDataList notifyItemData = new();
notifyItemData.ItemDataList.Add(session.inventory.Do(Inventory.TeamExp, stageTable.TeamExp ?? 0));
foreach (var rewardGoodsId in rewardTables.SelectMany(x => x.SubIds)) foreach (var rewardGoodsId in rewardTables.SelectMany(x => x.SubIds))
{ {
RewardGoodsTable? rewardGood = TableReaderV2.Parse<RewardGoodsTable>().FirstOrDefault(x => x.Id == rewardGoodsId); RewardGoodsTable? rewardGood = TableReaderV2.Parse<RewardGoodsTable>().FirstOrDefault(x => x.Id == rewardGoodsId);
@ -227,9 +232,7 @@ namespace AscNet.GameServer.Handlers
// TODO: Implement other types. Other types are behaving weirdly // TODO: Implement other types. Other types are behaving weirdly
if (rewardType == RewardType.Item) if (rewardType == RewardType.Item)
{ {
NotifyItemDataList notifyItemData = new();
notifyItemData.ItemDataList.Add(session.inventory.Do(rewardGood.TemplateId, rewardGood.Count)); notifyItemData.ItemDataList.Add(session.inventory.Do(rewardGood.TemplateId, rewardGood.Count));
session.SendPush(notifyItemData);
rewards.Add(new() rewards.Add(new()
{ {
@ -242,6 +245,9 @@ namespace AscNet.GameServer.Handlers
} }
} }
session.SendPush(notifyItemData);
session.ExpSanityCheck();
StageDatum stageData = new() StageDatum stageData = new()
{ {
StageId = req.Result.StageId, StageId = req.Result.StageId,

View File

@ -0,0 +1,44 @@
using AscNet.Common.Database;
using AscNet.Common.MsgPack;
using AscNet.Common.Util;
using AscNet.Table.V2.share.player;
namespace AscNet.GameServer
{
public static class SessionExtensions
{
/// <summary>
/// Please invoke after messing with TeamExp(commandant exp) count!
/// </summary>
/// <param name="session"></param>
public static void ExpSanityCheck(this Session session)
{
Item? expItem = session.inventory.Items.FirstOrDefault(x => x.Id == Inventory.TeamExp);
if (expItem is null)
return;
PlayerTable? playerLevel = TableReaderV2.Parse<PlayerTable>().FirstOrDefault(x => x.Level == session.player.PlayerData.Level);
if (playerLevel is null)
return;
if (expItem.Count < playerLevel.MaxExp)
return;
expItem.Count -= playerLevel.MaxExp;
session.player.PlayerData.Level++;
NotifyPlayerLevel notifyPlayerLevel = new()
{
Level = (int)session.player.PlayerData.Level
};
NotifyItemDataList notifyItemDataList = new();
notifyItemDataList.ItemDataList.Add(expItem);
notifyItemDataList.ItemDataList.Add(session.inventory.Do(Inventory.ActionPoint, playerLevel.FreeActionPoint));
session.SendPush(notifyPlayerLevel);
session.SendPush(notifyItemDataList);
session.ExpSanityCheck();
}
}
}