private void AddEvilHourModifiers(IList <IDropTableModificatorScheme> totalModifierList) { const float PRE_DAY_COUNT = 5.0f; const float POST_DAY_COUNT = 2.0f; var currentDate = _userTimeProvider.GetCurrentTime(); // Основано на хелловине var evilHour = new DateTime(currentDate.Year, 11, 2); var evilHourStart = evilHour.AddDays(-PRE_DAY_COUNT); var evilHourEnd = evilHour.AddDays(POST_DAY_COUNT); if (evilHourStart <= currentDate && currentDate <= evilHourEnd) { IDropTableModificatorScheme mod; if (currentDate <= evilHour) { // Канун злого часа mod = CreateEvilHourModifier(evilHour, PRE_DAY_COUNT, currentDate); } else { // Хвост события mod = CreateEvilHourModifier(currentDate, POST_DAY_COUNT, evilHourEnd); } totalModifierList.Add(mod); } }
public bool RollEventIsRaised() { // The day of national unity. var targetData = new DateTime(DateTime.Now.Year, 11, 4); var max = _userTimeProvider.GetCurrentTime(); var min = targetData; if (min > max) { var temp = min; min = max; max = temp; } var dateDistance = (max - min).TotalDays; const double EVENT_BONUS_DURATION = 10d; const double EVENT_BONUS_MAX_PROBABILITY = 10; const double EVENT_BONUS_MIN_PROBABILITY = 50; const double EVENT_BONUS_PROBABILITY_DIFF = EVENT_BONUS_MIN_PROBABILITY - EVENT_BONUS_MAX_PROBABILITY; var dateDistanceNormalized = Math.Min(dateDistance, EVENT_BONUS_DURATION); var eventRaiseRollValue = EVENT_BONUS_MAX_PROBABILITY + ((EVENT_BONUS_PROBABILITY_DIFF * dateDistanceNormalized) / EVENT_BONUS_DURATION); return(_dice.Roll(100) > eventRaiseRollValue); }