exp implementation

This commit is contained in:
rafi1212122
2023-05-29 09:00:46 +07:00
parent 761f9c130d
commit 5a0e2e6da3
5 changed files with 144 additions and 3 deletions

View File

@@ -0,0 +1,75 @@
using Newtonsoft.Json;
namespace Common.Utils.ExcelReader
{
public class PlayerLevelData : BaseExcelReader<PlayerLevelData, PlayerLevelDataExcel>
{
public override string FileName { get { return "PlayerLevelData.json"; } }
public PlayerLevelDataExcel? FromLevel(int level)
{
return All.Where(levelData => levelData.Level == level).FirstOrDefault();
}
public readonly struct LevelData
{
public LevelData(int level, int exp)
{
Level = level;
Exp = exp;
}
public int Level { get; init; }
public int Exp { get; init; }
}
public LevelData CalculateLevel(int exp)
{
int level = 1;
int expRemain = exp;
foreach (var levelData in All)
{
if(expRemain < 1)
{
break;
}
else if(expRemain > levelData.Exp)
{
level++;
expRemain -= levelData.Exp;
}
}
return new LevelData(level, expRemain);
}
}
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public partial class PlayerLevelDataExcel
{
[JsonProperty("exp")]
public int Exp { get; set; }
[JsonProperty("stamina")]
public int Stamina { get; set; }
[JsonProperty("numFriends")]
public int NumFriends { get; set; }
[JsonProperty("avatarLevelLimit")]
public int AvatarLevelLimit { get; set; }
[JsonProperty("staminaBonus")]
public int StaminaBonus { get; set; }
[JsonProperty("sweepStaminaLimit")]
public int SweepStaminaLimit { get; set; }
[JsonProperty("DataImpl")]
public object DataImpl { get; set; }
[JsonProperty("level")]
public int Level { get; set; }
}
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
}

View File

@@ -1,5 +1,6 @@
using Common.Database; using Common.Database;
using Common.Resources.Proto; using Common.Resources.Proto;
using Common.Utils.ExcelReader;
namespace PemukulPaku.GameServer.Handlers namespace PemukulPaku.GameServer.Handlers
{ {
@@ -10,17 +11,50 @@ namespace PemukulPaku.GameServer.Handlers
{ {
UserScheme User = session.Player.User; UserScheme User = session.Player.User;
PlayerLevelData.LevelData levelData = PlayerLevelData.GetInstance().CalculateLevel(User.Exp);
GetMainDataRsp Rsp = new() GetMainDataRsp Rsp = new()
{ {
retcode = GetMainDataRsp.Retcode.Succ, retcode = GetMainDataRsp.Retcode.Succ,
AssistantAvatarId = (uint)User.AssistantAvatarId, AssistantAvatarId = (uint)User.AssistantAvatarId,
Birthday = (uint)User.BirthDate, Birthday = (uint)User.BirthDate,
Nickname = User.Nick, Nickname = User.Nick,
Level = 4, Level = (uint)levelData.Level,
Exp = (uint)User.Exp, Exp = (uint)levelData.Exp,
FreeHcoin = (uint)User.Hcoin, FreeHcoin = (uint)User.Hcoin,
Hcoin = (uint)User.Hcoin, Hcoin = (uint)User.Hcoin,
CustomHeadId = 161001 CustomHeadId = 161001,
Scoin = session.Player.Equipment.MaterialList.Where(mat => mat.Id == 100).FirstOrDefault()?.Num ?? 0,
IsAll = true,
RegisterTime = (uint)User.Id.Timestamp,
PayHcoin = 0,
WarshipAvatar = User.WarshipAvatar,
SelfDesc = User.SelfDesc,
UseFrameId = 200001,
OnPhonePendantId = 350005,
Stamina = (uint)User.Stamina,
StaminaRecoverConfigTime = 360,
StaminaRecoverLeftTime = 0,
EquipmentSizeLimit = 1000,
OpenPanelActivityLists = new uint[] { 2 },
ChatworldActivityInfo = new()
{
IsHasNpcRedEnvelope = true,
TreasureScheduleId = 1
},
IsAllowCostSeniorEquipOnCurDevice = true,
TypeLists = new uint[] { 2, 3, 4, 5, 6, 7, 8, 9, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39 },
LevelLockId = 1,
Mcoin = 0,
MonthRechargePrice = 0,
WarshipTheme = new ()
{
WarshipId = (uint)User.WarshipId
},
TotalLoginDays = 1,
NextEvaluateTime = 0,
OnMedalId = 0,
TodayRechargePrice = 0,
}; };
session.Send(Packet.FromProto(Rsp, CmdId.GetMainDataRsp)); session.Send(Packet.FromProto(Rsp, CmdId.GetMainDataRsp));

View File

@@ -0,0 +1,28 @@
using Common.Resources.Proto;
using Common.Utils.ExcelReader;
namespace PemukulPaku.GameServer.Handlers
{
[PacketCmdId(CmdId.GetStageDataReq)]
internal class GetStageDataReqHandler : IPacketHandler
{
public void Handle(Session session, Packet packet)
{
GetStageDataRsp Rsp = new()
{
retcode = GetStageDataRsp.Retcode.Succ,
IsAll = true,
};
Rsp.StageLists.AddRange(StageData.GetInstance().All.Select(stage => new Stage()
{
Id = (uint)stage.LevelId,
IsDone = true,
Progress = (uint)stage.MaxProgress,
EnterTimes = 1
}));
session.Send(Packet.FromProto(Rsp, CmdId.GetStageDataRsp));
}
}
}

View File

@@ -42,10 +42,13 @@ namespace PemukulPaku.GameServer.Handlers
} }
session.Player.User.Hcoin += DecodedBody.ChallengeIndexLists.Length * 5; session.Player.User.Hcoin += DecodedBody.ChallengeIndexLists.Length * 5;
session.Player.User.Exp += 100;
session.ProcessPacket(Packet.FromProto(new GetMainDataReq() { }, CmdId.GetMainDataReq));
session.ProcessPacket(Packet.FromProto(new GetEquipmentDataReq() { }, CmdId.GetEquipmentDataReq)); session.ProcessPacket(Packet.FromProto(new GetEquipmentDataReq() { }, CmdId.GetEquipmentDataReq));
session.ProcessPacket(Packet.FromProto(new GetWorldMapDataReq() { }, CmdId.GetWorldMapDataReq)); session.ProcessPacket(Packet.FromProto(new GetWorldMapDataReq() { }, CmdId.GetWorldMapDataReq));
session.ProcessPacket(Packet.FromProto(new ChapterGroupGetDataReq() { }, CmdId.ChapterGroupGetDataReq)); session.ProcessPacket(Packet.FromProto(new ChapterGroupGetDataReq() { }, CmdId.ChapterGroupGetDataReq));
session.ProcessPacket(Packet.FromProto(new GetStageDataReq() { }, CmdId.GetStageDataReq));
Rsp.PlayerExpReward = 100; Rsp.PlayerExpReward = 100;
Rsp.AvatarExpReward = DecodedBody.AvatarExpReward; Rsp.AvatarExpReward = DecodedBody.AvatarExpReward;

View File

@@ -3,6 +3,7 @@ using System.Net.NetworkInformation;
using PemukulPaku.GameServer; using PemukulPaku.GameServer;
using Common.Database; using Common.Database;
using PemukulPaku.GameServer.Game; using PemukulPaku.GameServer.Game;
using Common.Utils.ExcelReader;
namespace PemukulPaku namespace PemukulPaku
{ {