Skip to content

BattleStatePredictor

战斗状态推算器,位于 FunGame.Core.Api。静态类。

基于回合记录(RoundRecord)与检查点(CharacterStateSnapshot)推算到目标回合时各角色的状态,用于回放与观战的"跳到第 N 回合"功能。

方法

方法签名说明
PredictAllstatic Dictionary<Guid, CharacterStateSnapshot> PredictAll(IEnumerable<RoundRecord> rounds, int targetRound)推算到目标回合时所有角色的状态快照(key: 角色 Guid)
Predictstatic CharacterStateSnapshot? Predict(IEnumerable<RoundRecord> rounds, int targetRound, Guid characterGuid)推算单个角色的状态快照

使用示例

csharp
using FunGame.Core.Api;

// 服务器端从 "1"/"2" 事件还原的回合记录
List<RoundRecord> rounds = LoadRounds(queueId);

// 推算第 15 回合所有角色的状态
Dictionary<Guid, CharacterStateSnapshot> states =
    BattleStatePredictor.PredictAll(rounds, targetRound: 15);

// 推算单个角色
CharacterStateSnapshot? state =
    BattleStatePredictor.Predict(rounds, targetRound: 15, characterGuid);

说明

  • 推算基于最近的有效检查点(RoundRecord.Checkpoint)逐操作(ActionRecord)应用
  • 无检查点时从开局状态推算
  • 状态快照结构见 CharacterStateSnapshot

关联

基于 LGPL-3.0 许可证发布