stage reward for item type

This commit is contained in:
rfi 2023-11-24 20:01:26 +07:00
parent cf82daad00
commit 1f4b0b660f
7 changed files with 151 additions and 36 deletions

View File

@ -2375,7 +2375,7 @@ namespace AscNet.Common.MsgPack
{
public Int32 ChallengeCount { get; set; }
public UInt32 StageId { get; set; }
public List<UInt32> CardIds { get; set; } = new();
public List<UInt32>? CardIds { get; set; } = new();
public Int32 FirstFightPos { get; set; }
public Int32 CaptainPos { get; set; }
public Boolean IsHasAssist { get; set; }
@ -2452,11 +2452,11 @@ namespace AscNet.Common.MsgPack
public class FightSettleResponseSettle
{
public Boolean IsWin { get; set; }
public UInt32 StageId { get; set; }
public long StageId { get; set; }
public Int32 StarsMark { get; set; }
public List<dynamic> RewardGoodsList { get; set; } = new();
public List<RewardGoods> RewardGoodsList { get; set; } = new();
public Int32 LeftTime { get; set; }
public Dictionary<dynamic, dynamic> NpcHpInfo { get; set; }
public dynamic? NpcHpInfo { get; set; }
public Int32 UrgentEnventId { get; set; }
public dynamic? ClientAssistInfo { get; set; }
public List<dynamic> FlopRewardList { get; set; } = new();
@ -2574,26 +2574,26 @@ namespace AscNet.Common.MsgPack
public Int32 Count { get; set; }
}
[global::MessagePack.MessagePackObject(true)]
public class ItemUseResponse
{
public Int32 Code { get; set; }
[global::MessagePack.MessagePackObject(true)]
public class ItemUseResponseRewardGoods
public class RewardGoods
{
public Int32 RewardType { get; set; }
public Int32 TemplateId { get; set; }
public UInt32 Count { get; set; }
public Int32 Count { get; set; }
public Int32 Level { get; set; }
public Int32 Quality { get; set; }
public Int32 Grade { get; set; }
public Int32 Breakthrough { get; set; }
public Int32 ConvertFrom { get; set; }
public UInt32 Id { get; set; }
public Int32 Id { get; set; }
}
public List<ItemUseResponseRewardGoods> RewardGoodsList { get; set; } = new();
[global::MessagePack.MessagePackObject(true)]
public class ItemUseResponse
{
public Int32 Code { get; set; }
public List<RewardGoods> RewardGoodsList { get; set; } = new();
}

View File

@ -106,10 +106,12 @@ namespace AscNet.Common.Util
prop.PropertyType.GetMethod("Add").Invoke(prop.GetValue(obj), new object[] { value });
}
}
else if (prop.PropertyType == typeof(int))
else if (prop.PropertyType == typeof(int) || prop.PropertyType == typeof(int?))
{
// For int properties like GroupId
if (!string.IsNullOrEmpty(values[i]))
prop.SetValue(obj, int.Parse(values[i]));
else
prop.SetValue(obj, null);
}
else
{

View File

@ -91,8 +91,10 @@ namespace AscNet.GameServer.Handlers
else
{
player = Player.FromToken(request.Token);
session.log.Debug("Player is reconnecting into new session...");
if (player is not null && (session.character is null || session.stage is null || session.inventory is null))
{
session.log.Debug("Reassigning player props...");
session.character = Character.FromUid(player.PlayerData.Id);
session.stage = Stage.FromUid(player.PlayerData.Id);
session.inventory = Inventory.FromUid(player.PlayerData.Id);
@ -219,7 +221,7 @@ Sorry for the inconvenience.
});
NotifyWorldChat notifyWorldChat = new();
notifyWorldChat.ChatMessages.Add(ChatModule.MakeLuciaMessage($"Hello {session.player.PlayerData.Name}! Welcome to AscNet, please read mails if you haven't already.\n如果您还没有阅读邮件请阅读邮件"));
notifyWorldChat.ChatMessages.Add(ChatModule.MakeLuciaMessage($"Hello {session.player.PlayerData.Name}! Welcome to AscNet, please read mails if you haven't already.\n如果您还没有阅读邮件请阅读邮件\n\nTry '/help' to get started"));
session.SendPush(notifyMails);
session.SendPush(notifyWorldChat);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,26 @@
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 GetVoteGroupListResponse
{
public List<dynamic> VoteGroupListCode;
}
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
#endregion
internal class VoteModule
{
[RequestPacketHandler("GetVoteGroupListRequest")]
public static void GetVoteGroupListRequestHandler(Session session, Packet.Request packet)
{
GetVoteGroupListResponse response = new();
session.SendResponse(response, packet.Id);
}
}
}

View File

@ -57,12 +57,13 @@ namespace AscNet.GameServer
while (readbytes < len)
{
int packetLen = BinaryPrimitives.ReadInt32LittleEndian(msg.AsSpan()[readbytes..]);
if (len > 0)
readbytes += 4;
if (packetLen < 1)
{
break;
}
else if (packetLen > len)
else if (packetLen > len && len > 0)
{
prevBuf += len;
break;
@ -132,7 +133,7 @@ namespace AscNet.GameServer
}
catch (Exception ex)
{
log.Error("Failed to invoke handler: " + ex.Message + $", Raw {packet.Type} packet: " + BitConverter.ToString(debugContent).Replace("-", ""));
log.Error("Failed to invoke handler: " + ex.ToString() + $", Raw {packet.Type} packet: " + BitConverter.ToString(debugContent).Replace("-", ""));
}
}
}

View File

@ -3,6 +3,7 @@ using AscNet.GameServer.Handlers;
using AscNet.GameServer.Commands;
using AscNet.Logging;
using AscNet.Common.Util;
using AscNet.Table.V2.share.reward;
using Newtonsoft.Json;
namespace AscNet
@ -18,6 +19,7 @@ namespace AscNet
#if DEBUG
if (Common.Common.config.VerboseLevel < Common.VerboseLevel.Debug)
Common.Common.config.VerboseLevel = Common.VerboseLevel.Debug;
// LoggerFactory.Logger.Debug(JsonConvert.SerializeObject(TableReaderV2.Parse<RewardTable>().Where(x => x.Id == null).SelectMany(x => x.SubIds)));
#endif
PacketFactory.LoadPacketHandlers();