forked from PGR/ascnet
TeamExp on stage settle
This commit is contained in:
parent
556477d312
commit
f00e16c7a1
|
@ -140,7 +140,6 @@ namespace AscNet.GameServer.Handlers
|
|||
FubenMainLineData = new(),
|
||||
FubenChapterExtraLoginData = new(),
|
||||
FubenUrgentEventData = new(),
|
||||
ItemList = session.inventory.Items,
|
||||
UseBackgroundId = 14000001 // main ui theme, table still failed to dump
|
||||
};
|
||||
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()
|
||||
};
|
||||
|
||||
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(notifyCharacterData);
|
||||
session.SendPush(notifyEquipData);
|
||||
session.SendPush(notifyAssistData);
|
||||
session.SendPush(notifyChatLoginData);
|
||||
session.SendPush(notifyItemDataList);
|
||||
|
||||
#region DisclamerMail
|
||||
NotifyMails notifyMails = new();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using AscNet.Common.MsgPack;
|
||||
using AscNet.Common.Database;
|
||||
using AscNet.Common.MsgPack;
|
||||
using AscNet.Common.Util;
|
||||
using AscNet.Table.share.fuben;
|
||||
using AscNet.Table.V2.share.reward;
|
||||
|
@ -204,9 +205,13 @@ namespace AscNet.GameServer.Handlers
|
|||
session.SendResponse(new FightSettleResponse() { Code = 20032004 }, packet.Id);
|
||||
return;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
NotifyItemDataList notifyItemData = new();
|
||||
notifyItemData.ItemDataList.Add(session.inventory.Do(Inventory.TeamExp, stageTable.TeamExp ?? 0));
|
||||
|
||||
foreach (var rewardGoodsId in rewardTables.SelectMany(x => x.SubIds))
|
||||
{
|
||||
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
|
||||
if (rewardType == RewardType.Item)
|
||||
{
|
||||
NotifyItemDataList notifyItemData = new();
|
||||
notifyItemData.ItemDataList.Add(session.inventory.Do(rewardGood.TemplateId, rewardGood.Count));
|
||||
session.SendPush(notifyItemData);
|
||||
|
||||
rewards.Add(new()
|
||||
{
|
||||
|
@ -242,6 +245,9 @@ namespace AscNet.GameServer.Handlers
|
|||
}
|
||||
}
|
||||
|
||||
session.SendPush(notifyItemData);
|
||||
session.ExpSanityCheck();
|
||||
|
||||
StageDatum stageData = new()
|
||||
{
|
||||
StageId = req.Result.StageId,
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue