2024-07-27 22:13:58 +05:00

40 lines
1.0 KiB
C#

using SoulstormReplayReader.Core.Domain.Action;
using SoulstormReplayReader.Core.Enums;
namespace SoulstormReplayReader.Core.Domain.BugCheckers;
public sealed class GenBugChecker(int playerId, RaceEnum playerRace) : BugCheckerBase(playerId, playerRace)
{
public override BugType BugType => BugType.GenBug;
private const int TicksRange = 4;
private const int GensToTrigger = 3;
private int _startTick;
private int _gensBuilt;
public override void Check(IGameAction action)
{
if (IsCompleted)
return;
if (PlayerId != action.PlayerId)
return;
if (action.Cmd != 117 || action.Arg != 141)
return;
if (_startTick == 0 || action.Tick - _startTick > TicksRange)
{
_startTick = action.Tick;
_gensBuilt = 0;
return;
}
if (++_gensBuilt == GensToTrigger)
{
Accusation = $"GenBug: {GensToTrigger}+ gens added in under {TicksRange / 8.0} sec";
IsCompleted = true;
}
}
}