mirror of
https://github.com/rafi1212122/BLHX.Server.git
synced 2025-12-12 14:34:39 +01:00
dummy chapter handling + OpMove PoC
This commit is contained in:
@@ -3,6 +3,34 @@ using System.Text.Json.Serialization;
|
||||
|
||||
namespace BLHX.Server.Common.Data;
|
||||
|
||||
public enum ChapterAttachFlag
|
||||
{
|
||||
AttachNone = 0,
|
||||
AttachBorn = 1,
|
||||
AttachBox = 2,
|
||||
AttachSupply = 3,
|
||||
AttachElite = 4,
|
||||
AttachAmbush = 5,
|
||||
AttachEnemy = 6,
|
||||
AttachTorpedo_Enemy = 7,
|
||||
AttachBoss = 8,
|
||||
AttachStory = 9,
|
||||
AttachAreaBoss = 11,
|
||||
AttachChampion = 12,
|
||||
AttachTorpedo_Fleet = 14,
|
||||
AttachChampionPatrol = 15,
|
||||
AttachBorn_Sub = 16,
|
||||
AttachTransport = 17,
|
||||
AttachTransport_Target = 18,
|
||||
AttachChampionSub = 19,
|
||||
AttachOni = 20,
|
||||
AttachOni_Target = 21,
|
||||
AttachBomb_Enemy = 24,
|
||||
AttachBarrier = 25,
|
||||
AttachHugeSupply = 26,
|
||||
AttachLandbase = 100
|
||||
}
|
||||
|
||||
public class ChapterTemplate : Model
|
||||
{
|
||||
[JsonIgnore]
|
||||
@@ -10,7 +38,7 @@ public class ChapterTemplate : Model
|
||||
{
|
||||
get
|
||||
{
|
||||
return Grids.Select(x => new GridItem() { Row = x[0].GetUInt32(), Column = x[1].GetUInt32(), Blocking = x[2].GetBoolean(), Flag = x[3].GetInt32() }).ToList();
|
||||
return Grids.Select(x => new GridItem() { Row = x[0].GetUInt32(), Column = x[1].GetUInt32(), Blocking = x[2].GetBoolean(), Flag = (ChapterAttachFlag)x[3].GetInt32() }).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,5 +247,5 @@ public readonly struct GridItem
|
||||
public uint Row { get; init; }
|
||||
public uint Column { get; init; }
|
||||
public bool Blocking { get; init; }
|
||||
public int Flag { get; init; }
|
||||
public ChapterAttachFlag Flag { get; init; }
|
||||
}
|
||||
@@ -477,5 +477,35 @@ namespace BLHX.Server.Common.Database
|
||||
Time = (uint)new DateTimeOffset(Time).ToUnixTimeSeconds()
|
||||
};
|
||||
}
|
||||
|
||||
public static ChapterInfo FromProto(Currentchapterinfo chapterInfo, uint uid)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Id = chapterInfo.Id,
|
||||
AiLists = chapterInfo.AiLists,
|
||||
BattleStatistics = chapterInfo.BattleStatistics,
|
||||
BuffLists = chapterInfo.BuffLists,
|
||||
CellFlagLists = chapterInfo.CellFlagLists,
|
||||
CellLists = chapterInfo.CellLists,
|
||||
ChapterHp = chapterInfo.ChapterHp,
|
||||
ChapterStrategyLists = chapterInfo.ChapterStrategyLists,
|
||||
ContinuousKillCount = chapterInfo.ContinuousKillCount,
|
||||
EscortLists = chapterInfo.EscortLists,
|
||||
ExtraFlagLists = chapterInfo.ExtraFlagLists,
|
||||
FleetDuties = chapterInfo.FleetDuties,
|
||||
GroupLists = chapterInfo.GroupLists,
|
||||
InitShipCount = chapterInfo.InitShipCount,
|
||||
IsSubmarineAutoAttack = Convert.ToBoolean(chapterInfo.IsSubmarineAutoAttack),
|
||||
KillCount = chapterInfo.KillCount,
|
||||
LoopFlag = chapterInfo.LoopFlag,
|
||||
ModelActCount = chapterInfo.ModelActCount,
|
||||
MoveStepCount = chapterInfo.MoveStepCount,
|
||||
OperationBuffs = chapterInfo.OperationBuffs,
|
||||
Round = chapterInfo.Round,
|
||||
Time = DateTimeOffset.FromUnixTimeSeconds(chapterInfo.Time).DateTime,
|
||||
PlayerUid = uid
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BLHX.Server.Common.Data;
|
||||
using BLHX.Server.Common.Database;
|
||||
using BLHX.Server.Common.Proto;
|
||||
using BLHX.Server.Common.Proto.p13;
|
||||
|
||||
@@ -6,7 +7,7 @@ namespace BLHX.Server.Game.Handlers
|
||||
{
|
||||
internal static class P13
|
||||
{
|
||||
[PacketHandler(Command.Cs13101)]
|
||||
[PacketHandler(Command.Cs13101, SaveDataAfterRun = true)]
|
||||
static void TrackingHandler(Connection connection, Packet packet)
|
||||
{
|
||||
var req = packet.Decode<Cs13101>();
|
||||
@@ -18,17 +19,100 @@ namespace BLHX.Server.Game.Handlers
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Populate values, pls make managers
|
||||
connection.Send(new Sc13102()
|
||||
connection.player.DoResource(2, chapterTemplate.Oil * -1);
|
||||
|
||||
var cells = chapterTemplate.GridItems.Select(x =>
|
||||
{
|
||||
CurrentChapter = new()
|
||||
var cellInfo = new Chaptercellinfo()
|
||||
{
|
||||
Pos = new Chaptercellpos() { Column = x.Column, Row = x.Row }
|
||||
};
|
||||
|
||||
if (x.Flag == ChapterAttachFlag.AttachEnemy)
|
||||
{
|
||||
cellInfo.ItemType = (uint)x.Flag;
|
||||
cellInfo.ItemId = (uint)chapterTemplate.ExpeditionIdWeightList[Random.Shared.Next(chapterTemplate.ExpeditionIdWeightList.Length)][0];
|
||||
}
|
||||
|
||||
if (x.Flag == ChapterAttachFlag.AttachBoss && chapterTemplate.BossRefresh == 0)
|
||||
{
|
||||
cellInfo.ItemType = (uint)x.Flag;
|
||||
cellInfo.ItemId = (uint)chapterTemplate.BossExpeditionId[Random.Shared.Next(chapterTemplate.BossExpeditionId.Length)];
|
||||
}
|
||||
|
||||
return cellInfo;
|
||||
}).ToList();
|
||||
var born = chapterTemplate.GridItems.Find(x => x.Flag == ChapterAttachFlag.AttachBorn);
|
||||
var chapter = new Currentchapterinfo()
|
||||
{
|
||||
Id = req.Id,
|
||||
Time = (uint)(DateTimeOffset.Now.ToUnixTimeSeconds() + chapterTemplate.Time)
|
||||
Time = (uint)new DateTimeOffset(DateTime.Now.AddSeconds(chapterTemplate.Time)).ToUnixTimeSeconds(),
|
||||
CellLists = cells,
|
||||
GroupLists = req.GroupIdLists.Select(x =>
|
||||
{
|
||||
var fleet = connection.player.Fleets.Find(y => y.Id == x);
|
||||
|
||||
return new Groupinchapter()
|
||||
{
|
||||
Id = x,
|
||||
ShipLists = fleet?.ShipLists.Select(x => new Shipinchapter() { Id = x, HpRant = 10000 }).ToList(),
|
||||
Pos = new Chaptercellpos() { Column = born.Column, Row = born.Row },
|
||||
Bullet = 5,
|
||||
StartPos = new(),
|
||||
FleetId = x
|
||||
};
|
||||
}).ToList(),
|
||||
IsSubmarineAutoAttack = 1,
|
||||
InitShipCount = (uint)connection.player.Fleets.Where(x => req.GroupIdLists.Contains(x.Id)).Sum(x => x.ShipLists.Count)
|
||||
};
|
||||
|
||||
if (connection.player.ChapterInfoes.Any(x => x.Id == chapter.Id))
|
||||
{
|
||||
connection.player.ChapterInfoes.Remove(connection.player.ChapterInfoes.First(x => x.Id == chapter.Id));
|
||||
}
|
||||
connection.player.ChapterInfoes.Add(ChapterInfo.FromProto(chapter, connection.player.Uid));
|
||||
connection.player.CurrentChapter = chapter.Id;
|
||||
|
||||
connection.Send(new Sc13102()
|
||||
{
|
||||
CurrentChapter = chapter
|
||||
});
|
||||
}
|
||||
|
||||
[PacketHandler(Command.Cs13103)]
|
||||
static void ChapterOPHandler(Connection connection, Packet packet)
|
||||
{
|
||||
var req = packet.Decode<Cs13103>();
|
||||
var rsp = new Sc13104();
|
||||
|
||||
switch ((ChapterOP)req.Act)
|
||||
{
|
||||
case ChapterOP.OpMove:
|
||||
rsp.MovePaths.Add(new() { Row = req.ActArg1, Column = req.ActArg2 });
|
||||
break;
|
||||
case ChapterOP.OpRetreat:
|
||||
case ChapterOP.OpBox:
|
||||
case ChapterOP.OpAmbush:
|
||||
case ChapterOP.OpStrategy:
|
||||
case ChapterOP.OpRepair:
|
||||
case ChapterOP.OpSupply:
|
||||
case ChapterOP.OpEnemyRound:
|
||||
case ChapterOP.OpSubState:
|
||||
case ChapterOP.OpStory:
|
||||
case ChapterOP.OpBarrier:
|
||||
case ChapterOP.OpSubTeleport:
|
||||
case ChapterOP.OpPreClear:
|
||||
case ChapterOP.OpRequest:
|
||||
case ChapterOP.OpSwitch:
|
||||
case ChapterOP.OpSkipBattle:
|
||||
rsp.Result = 1;
|
||||
connection.Send(rsp);
|
||||
throw new NotImplementedException($"{nameof(Cs13103)}, {JSON.Stringify(req)}");
|
||||
}
|
||||
|
||||
connection.Send(rsp);
|
||||
}
|
||||
|
||||
[PacketHandler(Command.Cs13505)]
|
||||
static void RemasterInfoRequestHandler(Connection connection, Packet packet)
|
||||
{
|
||||
@@ -43,4 +127,24 @@ namespace BLHX.Server.Game.Handlers
|
||||
connection.Send(new Sc13001() { ReactChapter = new() });
|
||||
}
|
||||
}
|
||||
|
||||
enum ChapterOP
|
||||
{
|
||||
OpRetreat = 0,
|
||||
OpMove = 1,
|
||||
OpBox = 2,
|
||||
OpAmbush = 4,
|
||||
OpStrategy = 5,
|
||||
OpRepair = 6,
|
||||
OpSupply = 7,
|
||||
OpEnemyRound = 8,
|
||||
OpSubState = 9,
|
||||
OpStory = 10,
|
||||
OpBarrier = 16,
|
||||
OpSubTeleport = 19,
|
||||
OpPreClear = 30,
|
||||
OpRequest = 49,
|
||||
OpSwitch = 98,
|
||||
OpSkipBattle = 99
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user