mirror of
https://github.com/EggLinks/DanhengServer-OpenSource.git
synced 2026-01-02 12:16:03 +08:00
feat: supply pending action without effects
This commit is contained in:
@@ -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; }
|
||||
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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<List<BaseGridFightSyncData>> EnterNextSection(bool sendPacket = true)
|
||||
public async ValueTask<List<BaseGridFightSyncData>> 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<BaseGridFightSyncData> syncs = [new GridFightLevelSyncData(GridFightSrc.KGridFightSrcBattleEnd, this)];
|
||||
List<BaseGridFightSyncData> syncs = [new GridFightLevelSyncData(src, this)];
|
||||
|
||||
//await Inst.RollPortalBuff();
|
||||
if (CurrentSection.Excel.IsAugment == 1)
|
||||
{
|
||||
// create augment action
|
||||
syncs.Add(await Inst.CreatePendingAction<GridFightAugmentPendingAction>(sendPacket: false));
|
||||
}
|
||||
|
||||
if (CurrentSection.Excel.NodeType == GridFightNodeTypeEnum.Supply)
|
||||
{
|
||||
// create supply action
|
||||
syncs.Add(await Inst.CreatePendingAction<GridFightSupplyPendingAction>(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<int> 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)]
|
||||
};
|
||||
|
||||
@@ -95,7 +95,7 @@ public class GridFightInstance(PlayerInstance player, uint season, uint division
|
||||
_ = GetComponent<GridFightRoleComponent>().AddAvatar(1414, 3, false);
|
||||
_ = GetComponent<GridFightShopComponent>().RefreshShop(true, false);
|
||||
|
||||
// _ = CreatePendingAction<GridFightAugmentPendingAction>(); // TODO wait for release official server
|
||||
_ = CreatePendingAction<GridFightPortalBuffPendingAction>(); // TODO wait for release official server
|
||||
}
|
||||
|
||||
public T GetComponent<T>() where T : BaseGridFightComponent
|
||||
@@ -152,24 +152,31 @@ public class GridFightInstance(PlayerInstance player, uint season, uint division
|
||||
return pos;
|
||||
}
|
||||
|
||||
public async ValueTask CreatePendingAction<T>(GridFightSrc src = GridFightSrc.KGridFightSrcEnterNode, bool sendPacket = true) where T: BaseGridFightPendingAction
|
||||
public async ValueTask<BaseGridFightSyncData> CreatePendingAction<T>(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<GridFightLevelComponent>();
|
||||
var curSection = levelComp.CurrentSection;
|
||||
|
||||
if (curSection.Encounters.Count != 0) return;
|
||||
|
||||
if (PendingActions.Count != 0) return;
|
||||
|
||||
// next
|
||||
await levelComp.EnterNextSection(src:src);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -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<GridFightGameSupplyRoleInfo> 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
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user