this took soo long, but here you are wells

This commit is contained in:
rfi
2024-02-22 16:11:23 +07:00
parent 5d39e1c6be
commit db93c8f49d
18 changed files with 1210 additions and 17 deletions

View File

@@ -76,7 +76,7 @@ namespace BLHX.Server.Game
if (!attr.IsNotifyHandler)
packetIdx++;
if (!attr.SaveDataAfterRun)
DBManager.PlayerContext.SaveChanges();
DBManager.PlayerContext.Save();
}
else
{
@@ -138,6 +138,20 @@ namespace BLHX.Server.Game
ns.Write(sendBuf);
}
public void Tick()
{
foreach (var resourceField in player.ResourceFields)
{
resourceField.CalculateYield();
}
DBManager.PlayerContext.Save();
this.NotifyResourceList();
#if DEBUG
c.Log($"Tick");
#endif
}
public void InitClientData()
{
this.NotifyPlayerData();

View File

@@ -89,6 +89,7 @@ namespace BLHX.Server.Game.Handlers
return;
}
DBManager.PlayerContext.PlayerRoutine(player);
connection.player = player;
rsp.UserId = player.Uid;
connection.Send(rsp);
@@ -116,6 +117,7 @@ namespace BLHX.Server.Game.Handlers
static void HeartbeatHandler(Connection connection, Packet packet)
{
connection.Send(new Sc10101() { State = 1 });
connection.Tick();
}
}
}

View File

@@ -16,6 +16,7 @@ namespace BLHX.Server.Game.Handlers
Monday0oclockTimestamp = Connection.Monday0oclockTimestamp,
ShipCount = connection.player is null ? 0 : (uint)connection.player.Ships.Count
});
connection.Tick();
}
[PacketHandler(Command.Cs11009, SaveDataAfterRun = true)]
@@ -27,6 +28,15 @@ namespace BLHX.Server.Game.Handlers
connection.Send(new Sc11010());
}
[PacketHandler(Command.Cs11013, SaveDataAfterRun = true)]
static void HarvestResourceHandler(Connection connection, Packet packet)
{
var req = packet.Decode<Cs11013>();
connection.player.HarvestResourceField((ResourceFieldType)req.Type);
connection.Send(new Sc11014());
}
[PacketHandler(Command.Cs11601)]
static void GetEmojiInfoHandler(Connection connection, Packet packet)
{
@@ -60,6 +70,17 @@ namespace BLHX.Server.Game.Handlers
static class P11ConnectionNotifyExtensions
{
public static void NotifyResourceList(this Connection connection)
{
if (connection.player is not null)
{
connection.Send(new Sc11004()
{
ResourceLists = connection.player.Resources.Select(x => new Resource() { Num = x.Num, Type = x.Id }).ToList()
});
}
}
public static void NotifyPlayerData(this Connection connection)
{
if (connection.player is not null)

View File

@@ -24,8 +24,8 @@ namespace BLHX.Server.Game.Handlers
{
connection.Send(new Sc22001()
{
OilWellLevel = 1,
GoldWellLevel = 1,
OilWellLevel = connection.player.ResourceFields.FirstOrDefault(x => x.Type == Common.Database.ResourceFieldType.Oil)?.Level ?? 1,
GoldWellLevel = connection.player.ResourceFields.FirstOrDefault(x => x.Type == Common.Database.ResourceFieldType.Gold)?.Level ?? 1,
ClassLv = 1,
Class = new(),
SkillClassNum = 2