diff --git a/Common/Data/Excel/GridFightStageRouteExcel.cs b/Common/Data/Excel/GridFightStageRouteExcel.cs index 97cc4167..8bd8b018 100644 --- a/Common/Data/Excel/GridFightStageRouteExcel.cs +++ b/Common/Data/Excel/GridFightStageRouteExcel.cs @@ -11,6 +11,7 @@ public class GridFightStageRouteExcel : ExcelResource public uint ChapterID { get; set; } public uint ID { get; set; } public uint StageID { get; set; } + public uint IsAugment { get; set; } public uint NodeTemplateID { get; set; } public uint BasicGoldRewardNum { get; set; } diff --git a/GameServer/Game/Battle/Custom/BattleGridFightOptions.cs b/GameServer/Game/Battle/Custom/BattleGridFightOptions.cs index fbf3b492..72e6b2e8 100644 --- a/GameServer/Game/Battle/Custom/BattleGridFightOptions.cs +++ b/GameServer/Game/Battle/Custom/BattleGridFightOptions.cs @@ -74,13 +74,6 @@ public class BattleGridFightOptions(GridFightGameSectionInfo curSection, GridFig WaveFlag = -1 }); - var even = battle.Stages.First().StageConfigData.FirstOrDefault(x => x.Key == "_CreateBattleEvent"); - if (even?.Value != null) - { - var id = int.Parse(even.Value); - battle.BattleEvents.TryAdd(id, new BattleEventInstance(id, 5000)); - } - proto.BattleGridFightInfo = new BattleGridFightInfo { GridGameAvatarList = diff --git a/GameServer/Game/GridFight/Component/GridFightLevelComponent.cs b/GameServer/Game/GridFight/Component/GridFightLevelComponent.cs index 18b3451d..03ae1c08 100644 --- a/GameServer/Game/GridFight/Component/GridFightLevelComponent.cs +++ b/GameServer/Game/GridFight/Component/GridFightLevelComponent.cs @@ -1,6 +1,7 @@ using EggLink.DanhengServer.Data; using EggLink.DanhengServer.Data.Excel; using EggLink.DanhengServer.Enums.GridFight; +using EggLink.DanhengServer.GameServer.Game.GridFight.PendingAction; using EggLink.DanhengServer.GameServer.Game.GridFight.Sync; using EggLink.DanhengServer.GameServer.Server.Packet.Send.GridFight; using EggLink.DanhengServer.Proto; @@ -99,7 +100,7 @@ public class GridFightLevelComponent : BaseGridFightComponent #region Actions - public async ValueTask> EnterNextSection(bool sendPacket = true) + public async ValueTask> EnterNextSection(bool sendPacket = true, GridFightSrc src = GridFightSrc.KGridFightSrcBattleEnd) { // if last section of chapter if (_curSectionId >= Sections[_curChapterId].Count) @@ -118,8 +119,20 @@ public class GridFightLevelComponent : BaseGridFightComponent _curSectionId++; } - List syncs = [new GridFightLevelSyncData(GridFightSrc.KGridFightSrcBattleEnd, this)]; + List syncs = [new GridFightLevelSyncData(src, this)]; + //await Inst.RollPortalBuff(); + if (CurrentSection.Excel.IsAugment == 1) + { + // create augment action + syncs.Add(await Inst.CreatePendingAction(sendPacket: false)); + } + + if (CurrentSection.Excel.NodeType == GridFightNodeTypeEnum.Supply) + { + // create supply action + syncs.Add(await Inst.CreatePendingAction(sendPacket: false)); + } if (sendPacket) { @@ -171,7 +184,8 @@ public class GridFightLevelComponent : BaseGridFightComponent RouteId = CurrentSection.Excel.ID, GridFightLayerInfo = new GridFightLayerInfo { - RouteInfo = CurrentSection.ToRouteInfo() + RouteInfo = CurrentSection.ToRouteInfo(), + RouteIsPending = CurrentSection.Excel.IsAugment == 1 }, BossInfo = new GridFightBossInfo { @@ -248,6 +262,9 @@ public class GridFightGameSectionInfo MonsterCamp = camp; + if (Excel.NodeType is not GridFightNodeTypeEnum.Monster and not GridFightNodeTypeEnum.CampMonster + and not GridFightNodeTypeEnum.Boss and not GridFightNodeTypeEnum.EliteBranch || Excel.IsAugment == 1) return; + Encounters.Add(new GridFightGameEncounterInfo(1, 1, this)); } @@ -279,20 +296,17 @@ public class GridFightGameEncounterInfo EncounterDifficulty = difficulty; ParentSection = section; - if (ParentSection.Excel.NodeType is not GridFightNodeTypeEnum.Monster and not GridFightNodeTypeEnum.CampMonster - and not GridFightNodeTypeEnum.Boss and not GridFightNodeTypeEnum.EliteBranch) return; - var waveNum = ParentSection.Excel.NodeType switch { - GridFightNodeTypeEnum.Boss => 2, - GridFightNodeTypeEnum.EliteBranch => 2, + //GridFightNodeTypeEnum.Boss => 2, + //GridFightNodeTypeEnum.EliteBranch => 2, _ => 1 }; List monsterNum = ParentSection.Excel.NodeType switch { - GridFightNodeTypeEnum.Boss => [Random.Shared.Next(3, 5), 1], - GridFightNodeTypeEnum.EliteBranch => [Random.Shared.Next(3, 5), 3], + GridFightNodeTypeEnum.Boss => [1], + GridFightNodeTypeEnum.EliteBranch => [3], GridFightNodeTypeEnum.CampMonster => [3], _ => [Random.Shared.Next(3, 5)] }; diff --git a/GameServer/Game/GridFight/GridFightInstance.cs b/GameServer/Game/GridFight/GridFightInstance.cs index 748038ed..8bcc1375 100644 --- a/GameServer/Game/GridFight/GridFightInstance.cs +++ b/GameServer/Game/GridFight/GridFightInstance.cs @@ -95,7 +95,7 @@ public class GridFightInstance(PlayerInstance player, uint season, uint division _ = GetComponent().AddAvatar(1414, 3, false); _ = GetComponent().RefreshShop(true, false); - // _ = CreatePendingAction(); // TODO wait for release official server + _ = CreatePendingAction(); // TODO wait for release official server } public T GetComponent() where T : BaseGridFightComponent @@ -152,24 +152,31 @@ public class GridFightInstance(PlayerInstance player, uint season, uint division return pos; } - public async ValueTask CreatePendingAction(GridFightSrc src = GridFightSrc.KGridFightSrcEnterNode, bool sendPacket = true) where T: BaseGridFightPendingAction + public async ValueTask CreatePendingAction(GridFightSrc src = GridFightSrc.KGridFightSrcEnterNode, bool sendPacket = true) where T: BaseGridFightPendingAction { var action = (T)Activator.CreateInstance(typeof(T), this)!; AddPendingAction(action); + var res = new GridFightPendingActionSyncData(src, action); if (sendPacket) - await Player.SendPacket(new PacketGridFightSyncUpdateResultScNotify( - new GridFightPendingActionSyncData(src, action))); + await Player.SendPacket(new PacketGridFightSyncUpdateResultScNotify(res)); + + return res; } public async ValueTask HandleResultRequest(GridFightHandlePendingActionCsReq req) { var curAction = GetCurAction(); + // end + PendingActions.Remove(curAction.QueuePosition); + var src = GridFightSrc.KGridFightSrcNone; + switch (req.GridFightActionTypeCase) { case GridFightHandlePendingActionCsReq.GridFightActionTypeOneofCase.PortalBuffAction: + src = GridFightSrc.KGridFightSrcSelectPortalBuff; break; case GridFightHandlePendingActionCsReq.GridFightActionTypeOneofCase.PortalBuffRerollAction: if (curAction is GridFightPortalBuffPendingAction portalBuffAction) @@ -179,6 +186,8 @@ public class GridFightInstance(PlayerInstance player, uint season, uint division break; case GridFightHandlePendingActionCsReq.GridFightActionTypeOneofCase.AugmentAction: + src = GridFightSrc.KGridFightSrcSelectAugment; + await CheckCurNodeFinish(src); break; case GridFightHandlePendingActionCsReq.GridFightActionTypeOneofCase.RerollAugmentAction: @@ -191,14 +200,27 @@ public class GridFightInstance(PlayerInstance player, uint season, uint division case GridFightHandlePendingActionCsReq.GridFightActionTypeOneofCase.EliteAction: break; case GridFightHandlePendingActionCsReq.GridFightActionTypeOneofCase.SupplyAction: + src = GridFightSrc.KGridFightSrcSelectSupply; + await CheckCurNodeFinish(src); break; } - // end - PendingActions.Remove(curAction.QueuePosition); await Player.SendPacket(new PacketGridFightSyncUpdateResultScNotify( - new GridFightPendingActionSyncData(GridFightSrc.KGridFightSrcNone, GetCurAction()))); + new GridFightPendingActionSyncData(src, GetCurAction()))); + } + + public async ValueTask CheckCurNodeFinish(GridFightSrc src) + { + var levelComp = GetComponent(); + var curSection = levelComp.CurrentSection; + + if (curSection.Encounters.Count != 0) return; + + if (PendingActions.Count != 0) return; + + // next + await levelComp.EnterNextSection(src:src); } #endregion diff --git a/GameServer/Game/GridFight/PendingAction/GridFightSupplyPendingAction.cs b/GameServer/Game/GridFight/PendingAction/GridFightSupplyPendingAction.cs new file mode 100644 index 00000000..342ecab2 --- /dev/null +++ b/GameServer/Game/GridFight/PendingAction/GridFightSupplyPendingAction.cs @@ -0,0 +1,69 @@ +using EggLink.DanhengServer.Data; +using EggLink.DanhengServer.GameServer.Game.GridFight.Sync; +using EggLink.DanhengServer.GameServer.Server.Packet.Send.GridFight; +using EggLink.DanhengServer.Proto; +using EggLink.DanhengServer.Util; + +namespace EggLink.DanhengServer.GameServer.Game.GridFight.PendingAction; + +public class GridFightSupplyPendingAction : BaseGridFightPendingAction +{ + public uint MaxRerollNum { get; set; } = 1; + public uint CurRerollNum { get; set; } + public List RoleList { get; set; } = []; + + public GridFightSupplyPendingAction(GridFightInstance inst) : base(inst) + { + for (var i = 0; i < 3; i++) + { + RoleList.Add(new GridFightGameSupplyRoleInfo(GameData.GridFightRoleBasicInfoData.Keys.ToList().RandomElement())); + } + } + + public async ValueTask Reroll() + { + if (MaxRerollNum <= CurRerollNum) + return; + + CurRerollNum++; + + RoleList.Clear(); + for (var i = 0; i < 3; i++) + { + RoleList.Add(new GridFightGameSupplyRoleInfo(GameData.GridFightRoleBasicInfoData.Keys.ToList().RandomElement())); + } + + // sync + await Inst.Player.SendPacket(new PacketGridFightSyncUpdateResultScNotify( + new GridFightPendingActionSyncData(GridFightSrc.KGridFightSrcNone, this))); + } + + public override GridFightPendingAction ToProto() + { + return new GridFightPendingAction + { + QueuePosition = QueuePosition, + SupplyAction = new GridFightSupplyActionInfo + { + MaxRerollCount = MaxRerollNum, + CurRollCount = CurRerollNum, + MEKEFPNMNLE = 3, + JLHIKCHIEDJ = 2, + SupplyRoleInfoList = { RoleList.Select(x => x.ToProto()) } + } + }; + } +} + +public class GridFightGameSupplyRoleInfo(uint roleId) +{ + public uint RoleId { get; set; } = roleId; + + public GridFightSupplyRoleInfo ToProto() + { + return new GridFightSupplyRoleInfo + { + RoleBasicId = RoleId + }; + } +} \ No newline at end of file diff --git a/GameServer/Game/GridFight/Sync/GridFightFinishPendingActionSyncData.cs b/GameServer/Game/GridFight/Sync/GridFightFinishPendingActionSyncData.cs new file mode 100644 index 00000000..b62a385c --- /dev/null +++ b/GameServer/Game/GridFight/Sync/GridFightFinishPendingActionSyncData.cs @@ -0,0 +1,13 @@ +using EggLink.DanhengServer.Proto; + +namespace EggLink.DanhengServer.GameServer.Game.GridFight.Sync; + +public class GridFightFinishPendingActionSyncData(GridFightSrc src, uint queuePosition) : BaseGridFightSyncData(src) +{ + public override GridFightSyncData ToProto() + { + return new GridFightSyncData + { + }; + } +} \ No newline at end of file diff --git a/GameServer/Game/GridFight/Sync/GridFightLevelSyncData.cs b/GameServer/Game/GridFight/Sync/GridFightLevelSyncData.cs index 9a1fa15c..ed6a1995 100644 --- a/GameServer/Game/GridFight/Sync/GridFightLevelSyncData.cs +++ b/GameServer/Game/GridFight/Sync/GridFightLevelSyncData.cs @@ -15,7 +15,8 @@ public class GridFightLevelSyncData(GridFightSrc src, GridFightLevelComponent le ChapterId = level.CurrentSection.ChapterId, GridFightLayerInfo = new GridFightLayerInfo { - RouteInfo = level.CurrentSection.ToRouteInfo() + RouteInfo = level.CurrentSection.ToRouteInfo(), + RouteIsPending = level.CurrentSection.Excel.IsAugment == 1 } } };