This commit is contained in:
rfi
2024-02-29 10:02:53 +07:00
parent a6f4897c29
commit 5d9003516d
2 changed files with 39 additions and 6 deletions

View File

@@ -116,7 +116,7 @@ namespace BLHX.Server.Game.Handlers
[PacketHandler(Command.Cs10100, IsNotifyHandler = true)] [PacketHandler(Command.Cs10100, IsNotifyHandler = true)]
static void HeartbeatHandler(Connection connection, Packet packet) static void HeartbeatHandler(Connection connection, Packet packet)
{ {
connection.Send(new Sc10101() { State = 1 }); connection.Send(new Sc10101());
connection.Tick(); connection.Tick();
} }
} }

View File

@@ -2,6 +2,8 @@
using BLHX.Server.Common.Database; using BLHX.Server.Common.Database;
using BLHX.Server.Common.Proto; using BLHX.Server.Common.Proto;
using BLHX.Server.Common.Proto.p13; using BLHX.Server.Common.Proto.p13;
using BLHX.Server.Common.Utils;
using System.Numerics;
namespace BLHX.Server.Game.Handlers namespace BLHX.Server.Game.Handlers
{ {
@@ -86,14 +88,18 @@ namespace BLHX.Server.Game.Handlers
var req = packet.Decode<Cs13103>(); var req = packet.Decode<Cs13103>();
var rsp = new Sc13104(); var rsp = new Sc13104();
var currentChapter = connection.player.ChapterInfoes.FirstOrDefault(x => x.Id == connection.player.CurrentChapter);
switch ((ChapterOP)req.Act) switch ((ChapterOP)req.Act)
{ {
case ChapterOP.OpRetreat:
connection.player.CurrentChapter = null;
break;
case ChapterOP.OpMove: case ChapterOP.OpMove:
// TODO: Use pathfinding
rsp.MovePaths.Add(new() { Row = req.ActArg1, Column = req.ActArg2 }); rsp.MovePaths.Add(new() { Row = req.ActArg1, Column = req.ActArg2 });
break; break;
case ChapterOP.OpEnemyRound: case ChapterOP.OpEnemyRound:
break; break;
case ChapterOP.OpRetreat:
case ChapterOP.OpBox: case ChapterOP.OpBox:
case ChapterOP.OpAmbush: case ChapterOP.OpAmbush:
case ChapterOP.OpStrategy: case ChapterOP.OpStrategy:
@@ -108,8 +114,8 @@ namespace BLHX.Server.Game.Handlers
case ChapterOP.OpSwitch: case ChapterOP.OpSwitch:
case ChapterOP.OpSkipBattle: case ChapterOP.OpSkipBattle:
rsp.Result = 1; rsp.Result = 1;
connection.Send(rsp); connection.c.Error($"{nameof(Cs13103)}, {JSON.Stringify(req)}");
throw new NotImplementedException($"{nameof(Cs13103)}, {JSON.Stringify(req)}"); break;
} }
connection.Send(rsp); connection.Send(rsp);
@@ -118,7 +124,29 @@ namespace BLHX.Server.Game.Handlers
[PacketHandler(Command.Cs13106)] [PacketHandler(Command.Cs13106)]
static void ChapterBattleResultRequestHandler(Connection connection, Packet packet) static void ChapterBattleResultRequestHandler(Connection connection, Packet packet)
{ {
connection.Send(new Sc13105()); var rsp = new Sc13105();
var currentChapter = connection.player.ChapterInfoes.FirstOrDefault(x => x.Id == connection.player.CurrentChapter);
if (currentChapter is null || !Data.ChapterTemplate.TryGetValue((int)currentChapter.Id, out var chapterTemplate))
{
connection.Send(rsp);
return;
}
currentChapter.KillCount++;
if (currentChapter.KillCount >= chapterTemplate.BossRefresh)
{
int bossId = chapterTemplate.BossExpeditionId[Random.Shared.Next(chapterTemplate.BossExpeditionId.Length)];
var bossGridItem = chapterTemplate.GridItems.Find(x => x.Flag == ChapterAttachFlag.AttachBoss);
var bossCell = currentChapter.CellLists.Find(x => x.Pos.Row == bossGridItem.Row && x.Pos.Column == bossGridItem.Column);
if (bossCell is not null)
{
bossCell.ItemId = (uint)bossId;
bossCell.ItemType = (uint)ChapterAttachFlag.AttachBoss;
rsp.MapUpdates.Add(bossCell);
}
}
connection.Send(rsp);
} }
[PacketHandler(Command.Cs13505)] [PacketHandler(Command.Cs13505)]
@@ -132,7 +160,12 @@ namespace BLHX.Server.Game.Handlers
{ {
public static void NotifyChapterData(this Connection connection) public static void NotifyChapterData(this Connection connection)
{ {
connection.Send(new Sc13001() { ReactChapter = new() }); connection.Send(new Sc13001()
{
ReactChapter = new(),
ChapterLists = connection.player.ChapterInfoes.Select(x => x.ToProto()).ToList(),
CurrentChapter = connection.player.ChapterInfoes.FirstOrDefault(x => x.Id == connection.player.CurrentChapter)?.ToProto(),
});
} }
} }