38 lines
1.4 KiB
C#
38 lines
1.4 KiB
C#
using Wizard;
|
|
using Wizard.BattleMgr;
|
|
|
|
namespace SVSim.BattleEngine.Rng
|
|
{
|
|
// The headless authoritative NETWORK battle mgr — the emitting twin of HeadlessBattleMgr. Emission
|
|
// lives on NetworkBattleManagerBase (NetworkBattleSender's ctor demands one), so the M13 emit read
|
|
// needs this subclass; HeadlessBattleMgr : SingleBattleMgr cannot reach the sender. RNG overrides are
|
|
// identical to HeadlessBattleMgr (the same BattleManagerBase virtuals + RandomSourceBridge), so the
|
|
// M14 rand-list emit reuses this mgr unchanged. M13's deterministic card never exercises a roll.
|
|
public sealed class HeadlessNetworkBattleMgr : NetworkBattleManagerBase
|
|
{
|
|
private readonly IRandomSource _rng;
|
|
|
|
public HeadlessNetworkBattleMgr(IBattleMgrContentsCreator contentsCreator, IRandomSource rng = null)
|
|
: base(contentsCreator)
|
|
{
|
|
_rng = rng ?? new SeededRandomSource(contentsCreator.RandomSeed);
|
|
}
|
|
|
|
public override int StableRandom(int val)
|
|
{
|
|
double unit = _rng.NextUnit();
|
|
randomResult = unit;
|
|
return RandomSourceBridge.Range(val, unit);
|
|
}
|
|
|
|
public override double StableRandomDouble()
|
|
{
|
|
double unit = _rng.NextUnit();
|
|
randomResult = unit;
|
|
return unit;
|
|
}
|
|
|
|
public override int StableRandomOnlySelf(int val) => _rng.NextSelf(val);
|
|
}
|
|
}
|