private static Tuple<int, int> GetBoundaries(User player, PlayerHistorySample historySample) { var fromStrikeValue = 0; var count = player.Strikes.Count; int toStrikeValue; if (IsStrikeCountNull(historySample)) { fromStrikeValue = GetFromStrikeValue(historySample.FromStrike, count); toStrikeValue = GetToStrikeValue(historySample.ToStrike, count); } else { var strikesCount = historySample.StrikesCount; if (strikesCount == null) throw new NullReferenceException(); if (strikesCount.Value > 0) { fromStrikeValue = GetFromStrikeValue(historySample.FromStrike, count); toStrikeValue = fromStrikeValue + strikesCount.Value; } else if (strikesCount.Value < 0) { toStrikeValue = GetToStrikeValue(historySample.ToStrike, count); fromStrikeValue = toStrikeValue + strikesCount.Value; } else { if (historySample.ToStrike == null && historySample.FromStrike == null) { throw new ArgumentException( "Количество ударов не может быть равным 0, если явно не задан параметр \"ToStrike\" или \"FromStrike\", "); } else if (historySample.ToStrike != null) { fromStrikeValue = toStrikeValue = GetToStrikeValue(historySample.ToStrike, count); } else { fromStrikeValue = toStrikeValue = GetFromStrikeValue(historySample.FromStrike, count); } } } return new Tuple<int, int>(fromStrikeValue, toStrikeValue); }
private static bool IsStrikeCountNull(PlayerHistorySample historySample) { return historySample.StrikesCount == null; }