internal void RescheduleActivity(ActivityInfo activity, ScheduledActivity scheduledActivity, bool ignoreOther) { bool multiDorm = activity.Flags.HasFlag(ActivityFlags.MultiDorm); AvailableActivitiesToday.Remove(activity.ID); if (multiDorm) { AvailableMultiDormActivitiesToday.Remove(activity.ID); } if (activity.Flags.HasFlag(ActivityFlags.Repeatable)) { RepeatableTodayHistory.Add(activity.ID); } ActivitiesDoneToday.Add(activity.ID); if (activity.IncompatibleActivities.Any()) { AvailableActivitiesToday.ExceptWith(activity.IncompatibleActivities); AvailableMultiDormActivitiesToday.ExceptWith(activity.IncompatibleActivities); } if (!ignoreOther && scheduledActivity.HasOther) { if (DormPriorities.TryGetValue(scheduledActivity.OtherDorm, out InterDormTracking interDorm)) { interDorm.RescheduleActivity(!OtherDormsDoneToday.Add(scheduledActivity.OtherDorm)); } } else { OtherDormsDoneToday.Add(Dorm); } }
public void ScheduleActivity(ActivityInfo activity, ScheduledActivity scheduledActivity) { if (!activity.Flags.HasFlag(ActivityFlags.Manual) && (!activity.Flags.HasFlag(ActivityFlags.Exclusive) || !activity.Flags.HasFlag(ActivityFlags.Excess))) { TotalScheduledDuration += activity.Duration; } else { TotalManualDuration += activity.Duration; } bool repeatable = activity.Flags.HasFlag(ActivityFlags.Repeatable); bool multiDorm = activity.Flags.HasFlag(ActivityFlags.MultiDorm); AvailableActivitiesToday.Remove(activity.ID); if (multiDorm) { AvailableMultiDormActivitiesToday.Remove(activity.ID); } bool clear = !repeatable; if (repeatable) { if (!RepeatableHistory.Add(activity.ID)) { clear = true; } else { if (ActivityPriorities.TryGetValue(activity.ID, out int activityPriority)) { if (--activityPriority == 0) { ActivityPriorities.Remove(activity.ID); } } else { ActivityPriorities.Add(activity.ID, -1); } } /*if (!RepeatableTodayHistory.Add(activity.ID)) * throw new IndexOutOfRangeException("Activity repeated twice the same day.");*/ } if (clear) { AvailableActivities.Remove(activity.ID); if (multiDorm) { AvailableMultiDormActivities.Remove(activity.ID); } } ActivitiesDoneToday.Add(activity.ID); if (activity.IncompatibleActivities.Any()) { AvailableActivitiesToday.ExceptWith(activity.IncompatibleActivities); AvailableMultiDormActivitiesToday.ExceptWith(activity.IncompatibleActivities); } ScheduleHistory.Add(scheduledActivity.Abbreviation); if (scheduledActivity.HasOther) { if (scheduledActivity.Dorm == Dorm) { if ( DormPriorities.TryGetValue( scheduledActivity.OtherDorm, out InterDormTracking otherDorm ) && otherDorm.ScheduleActivity( scheduledActivity, !OtherDormsDoneToday.Add(scheduledActivity.OtherDorm), repeatable, multiDorm ) ) { UsedUpOtherDorms.Add((InterDormTracking)otherDorm.Clone()); DormPriorities.Remove(scheduledActivity.OtherDorm); } } } else { DormPriorities[Dorm].ScheduleActivity(scheduledActivity, false, repeatable, multiDorm); OtherDormsDoneToday.Add(Dorm); } }