- 删除中间契约(BattleStartRequest/BattlePlayerInput/BattleReturnPlan/桥接与策略接口/FlowState),收敛为 BattleViewState/BattleStep/一层 BattleEvent - 新增内部 BattleRuntime/BattleUnit/BattleStatus 共享上下文;TurnBattleComponent 成为唯一外部入口,吸收启动/暂停/回写职责 - 内核支持 1v1 攻击闭环:效果公式、HP/MP 钳制、阵亡、Victory/TotalDefeat、敌人随机决策;敌人行动间歇 0.6s 由组件协程编排并经 StepListener 推送 - UI:玩家卡片/敌人槽/回合槽按战局重建,图标配置驱动(含新增 EnemyConfig.Icon),每轮刷新一次 TurnSlots 且轮内只移动高亮 - 新增 Tests 程序集 + InternalsVisibleTo,25 个 BattleRuntime 纯逻辑用例全部通过
46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using SepCore.CustomComponent;
|
|
using SepCore.Definition;
|
|
|
|
namespace SepCore.Battle
|
|
{
|
|
/// <summary>
|
|
/// 战斗配置的运行时适配器,隔离战斗规则与 GameEntry.Luban。
|
|
/// 配置缺失返回 null,由启动校验决定失败;正常行动不重复扫描全表完整性。
|
|
/// EditMode 测试使用内存配置,不使用本类。
|
|
/// </summary>
|
|
internal sealed class LubanBattleConfigProvider : IBattleConfigProvider
|
|
{
|
|
public EnemyPartyConfig GetEnemyParty(int id)
|
|
{
|
|
return SafeGet(() => GameEntry.Luban.Get<EnemyPartyConfig>(id));
|
|
}
|
|
|
|
public EnemyConfig GetEnemy(int id)
|
|
{
|
|
return SafeGet(() => GameEntry.Luban.Get<EnemyConfig>(id));
|
|
}
|
|
|
|
public BattleActionConfig GetAction(int id)
|
|
{
|
|
return SafeGet(() => GameEntry.Luban.Get<BattleActionConfig>(id));
|
|
}
|
|
|
|
public GlobalConfig GetGlobal()
|
|
{
|
|
return SafeGet(() => GameEntry.Luban.Global != null ? GameEntry.Luban.Global.Data : null);
|
|
}
|
|
|
|
private static T SafeGet<T>(System.Func<T> getter) where T : class
|
|
{
|
|
try
|
|
{
|
|
return GameEntry.Luban != null && GameEntry.Luban.IsReady ? getter() : null;
|
|
}
|
|
catch (System.Exception)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|