private bool CanRun(StationEventRuleConfiguration stationEvent, int playerCount, TimeSpan currentTime) { if (GameTicker.IsGameRuleStarted(stationEvent.Id)) { return(false); } if (stationEvent.MaxOccurrences.HasValue && GetOccurrences(stationEvent) >= stationEvent.MaxOccurrences.Value) { return(false); } if (playerCount < stationEvent.MinimumPlayers) { return(false); } if (currentTime != TimeSpan.Zero && currentTime.TotalMinutes < stationEvent.EarliestStart) { return(false); } var lastRun = TimeSinceLastEvent(stationEvent); if (lastRun != TimeSpan.Zero && currentTime.TotalMinutes < stationEvent.ReoccurrenceDelay + lastRun.TotalMinutes) { return(false); } return(true); }
private int GetOccurrences(StationEventRuleConfiguration stationEvent) { return(GameTicker.AllPreviousGameRules.Count(p => p.Item2.ID == stationEvent.Id)); }