- 删除中间契约(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 纯逻辑用例全部通过
104 lines
2.7 KiB
C#
104 lines
2.7 KiB
C#
using System.Collections.Generic;
|
|
using SepCore.Definition;
|
|
|
|
namespace SepCore.Battle
|
|
{
|
|
/// <summary>
|
|
/// 单场战斗的运行时单位,仅 BattleRuntime 及其协作者读写。
|
|
/// UI 与探索层通过 BattleUnitView 读取,不直接持有本类型。
|
|
/// </summary>
|
|
internal sealed class BattleUnit
|
|
{
|
|
/// <summary>
|
|
/// 本场战斗单位的唯一运行时标识;重复配置的敌人拥有不同 ID。
|
|
/// </summary>
|
|
public readonly int UnitId;
|
|
|
|
/// <summary>
|
|
/// 阵营。
|
|
/// </summary>
|
|
public readonly BattleFaction Faction;
|
|
|
|
/// <summary>
|
|
/// 配置标识:玩家为 CharacterId,敌人为 EnemyConfigId。
|
|
/// </summary>
|
|
public readonly int ConfigId;
|
|
|
|
/// <summary>
|
|
/// 同阵营同速度的最终并列规则顺序。
|
|
/// </summary>
|
|
public readonly int PartyOrder;
|
|
|
|
/// <summary>
|
|
/// HP 上限。
|
|
/// </summary>
|
|
public readonly int MaxHp;
|
|
|
|
/// <summary>
|
|
/// MP 上限。
|
|
/// </summary>
|
|
public readonly int MaxMp;
|
|
|
|
/// <summary>
|
|
/// 攻击。
|
|
/// </summary>
|
|
public readonly int Atk;
|
|
|
|
/// <summary>
|
|
/// 魔力。
|
|
/// </summary>
|
|
public readonly int Mat;
|
|
|
|
/// <summary>
|
|
/// 当前 HP。
|
|
/// </summary>
|
|
public int CurrentHp;
|
|
|
|
/// <summary>
|
|
/// 当前 MP。
|
|
/// </summary>
|
|
public int CurrentMp;
|
|
|
|
/// <summary>
|
|
/// 当前速度;可被战斗内效果修改。
|
|
/// </summary>
|
|
public int Speed;
|
|
|
|
/// <summary>
|
|
/// 是否阵亡。
|
|
/// </summary>
|
|
public bool IsDefeated;
|
|
|
|
/// <summary>
|
|
/// 是否已逃跑。
|
|
/// </summary>
|
|
public bool IsEscaped;
|
|
|
|
/// <summary>
|
|
/// 当前剩余状态。
|
|
/// </summary>
|
|
public readonly List<BattleStatus> Statuses = new List<BattleStatus>();
|
|
|
|
/// <summary>
|
|
/// 该单位可用的行动配置 ID。
|
|
/// </summary>
|
|
public readonly List<int> ActionIds = new List<int>();
|
|
|
|
public BattleUnit(int unitId, BattleFaction faction, int configId, int partyOrder,
|
|
int currentHp, int maxHp, int currentMp, int maxMp, int atk, int mat, int speed)
|
|
{
|
|
UnitId = unitId;
|
|
Faction = faction;
|
|
ConfigId = configId;
|
|
PartyOrder = partyOrder;
|
|
CurrentHp = currentHp;
|
|
MaxHp = maxHp;
|
|
CurrentMp = currentMp;
|
|
MaxMp = maxMp;
|
|
Atk = atk;
|
|
Mat = mat;
|
|
Speed = speed;
|
|
}
|
|
}
|
|
}
|