it's done lolol 🤯
This commit is contained in:
parent
208164fd7c
commit
eac3e558d4
|
@ -1,4 +1,6 @@
|
|||
using AscNet.Common.MsgPack;
|
||||
using AscNet.Common.Util;
|
||||
using AscNet.Table.V2.share.item;
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using MongoDB.Driver;
|
||||
|
@ -72,7 +74,9 @@ namespace AscNet.Common.Database
|
|||
public Item Do(int itemId, int amount)
|
||||
{
|
||||
Item? item = Items.FirstOrDefault(x => x.Id == itemId);
|
||||
if (item is not null)
|
||||
ItemTable? itemTable = TableReaderV2.Parse<ItemTable>().Find(x => x.Id == itemId);
|
||||
|
||||
if (item is not null && itemTable is not null && itemTable.MaxCount <= item.Count + amount)
|
||||
{
|
||||
item.Count += amount;
|
||||
item.RefreshTime = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace AscNet.GameServer.Game
|
|||
{
|
||||
Id = x.Id,
|
||||
UseItemId = Inventory.FreeGem,
|
||||
UseItemCount = 1,
|
||||
UseItemCount = 250,
|
||||
GroupId = GroupArrivalConstruct,
|
||||
BtnDrawCount = { 1, 10 },
|
||||
Banner = "Assets/Product/Ui/Scene3DPrefab/UiMain3dXiahuo.prefab",
|
||||
|
@ -96,7 +96,7 @@ namespace AscNet.GameServer.Game
|
|||
{
|
||||
Id = x.Id,
|
||||
UseItemId = Inventory.FreeGem,
|
||||
UseItemCount = 1,
|
||||
UseItemCount = 250,
|
||||
GroupId = GroupMemberTarget,
|
||||
BtnDrawCount = { 1, 10 },
|
||||
Banner = "Assets/Product/Ui/Scene3DPrefab/UiMain3dXiahuo.prefab",
|
||||
|
@ -138,7 +138,7 @@ namespace AscNet.GameServer.Game
|
|||
{
|
||||
case 1:
|
||||
// Character
|
||||
if (random >= 0.98f)
|
||||
if (random >= 0.972f)
|
||||
{
|
||||
// S Character
|
||||
float rate = Random.Shared.NextSingle();
|
||||
|
@ -345,6 +345,7 @@ namespace AscNet.GameServer.Game
|
|||
{
|
||||
RewardType = (int)RewardType.Character,
|
||||
Quality = characterQuality?.Quality ?? 0,
|
||||
Count = 1,
|
||||
TemplateId = rand
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using AscNet.Common.MsgPack;
|
||||
using AscNet.Common.Util;
|
||||
using AscNet.GameServer.Game;
|
||||
using AscNet.Table.V2.share.character;
|
||||
using MessagePack;
|
||||
|
||||
namespace AscNet.GameServer.Handlers
|
||||
|
@ -157,9 +159,62 @@ namespace AscNet.GameServer.Handlers
|
|||
rsp.RewardGoodsList.AddRange(DrawManager.DrawDraw(request.DrawId));
|
||||
}
|
||||
|
||||
// Post-processing and adding items to user's db
|
||||
NotifyItemDataList notifyItemData = new();
|
||||
NotifyEquipDataList notifyEquipData = new();
|
||||
NotifyCharacterDataList notifyCharacterData = new();
|
||||
FashionSyncNotify fashionSync = new();
|
||||
foreach (var item in rsp.RewardGoodsList)
|
||||
{
|
||||
switch ((RewardType)item.RewardType)
|
||||
{
|
||||
case RewardType.Item:
|
||||
notifyItemData.ItemDataList.Add(session.inventory.Do(item.TemplateId, item.Count));
|
||||
break;
|
||||
case RewardType.Equip:
|
||||
notifyEquipData.EquipDataList.Add(session.character.AddEquip((uint)item.TemplateId));
|
||||
break;
|
||||
case RewardType.Character:
|
||||
if (session.character.Characters.Any(x => x.Id == item.TemplateId))
|
||||
{
|
||||
CharacterTable? characterData = TableReaderV2.Parse<CharacterTable>().Find(x => x.Id == item.TemplateId);
|
||||
if (characterData is not null)
|
||||
{
|
||||
item.ConvertFrom = characterData.Id;
|
||||
item.TemplateId = characterData.ItemId;
|
||||
item.Count = 18;
|
||||
item.RewardType = (int)RewardType.Item;
|
||||
notifyItemData.ItemDataList.Add(session.inventory.Do(item.TemplateId, item.Count));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var ret = session.character.AddCharacter((uint)item.TemplateId);
|
||||
notifyCharacterData.CharacterDataList.Add(ret.Character);
|
||||
fashionSync.FashionList.Add(ret.Fashion);
|
||||
notifyEquipData.EquipDataList.Add(ret.Equip);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DrawInfo? drawInfo = DrawManager.GetDrawInfosByGroup(DrawManager.GetGroupByDrawId(request.DrawId)).Find(x => x.Id == request.DrawId);
|
||||
if (drawInfo is not null)
|
||||
{
|
||||
rsp.ClientDrawInfo = drawInfo;
|
||||
notifyItemData.ItemDataList.Add(session.inventory.Do(drawInfo.UseItemId, drawInfo.UseItemCount * -1));
|
||||
}
|
||||
|
||||
if (notifyItemData.ItemDataList.Count > 0)
|
||||
session.SendPush(notifyItemData);
|
||||
if (notifyEquipData.EquipDataList.Count > 0)
|
||||
session.SendPush(notifyEquipData);
|
||||
if (fashionSync.FashionList.Count > 0)
|
||||
session.SendPush(fashionSync);
|
||||
if (notifyCharacterData.CharacterDataList.Count > 0)
|
||||
session.SendPush(notifyCharacterData);
|
||||
|
||||
session.SendResponse(rsp, packet.Id);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue