예제 #1
0
        public void ClearFromHistory(ScheduledActivity scheduledActivity, bool repeatable, bool multiDorm)
        {
            bool soloTracker = ThisDorm == Dorm;

            if (!soloTracker)
            {
                ++Priority;
                AvailableToday = true;
            }

            if (repeatable && (!soloTracker || multiDorm))
            {
                if (!PreviousRepeatableActivities.Remove(scheduledActivity.Activity))
                {
                    throw new NotImplementedException("Activity not found in PreviousRepeatableActivities.");
                }
            }

            ScheduleHistory.Remove(scheduledActivity.Abbreviation);
        }
예제 #2
0
        internal void ClearFromHistory(ScheduledActivity scheduledActivity, bool ignoreHasOther = false)
        {
            ScheduleHistory.Remove(scheduledActivity.Abbreviation);
            var activity = Schedule.Activities[scheduledActivity.Activity];

            bool repeatable = activity.Flags.HasFlag(ActivityFlags.Repeatable);
            bool multiDorm  = activity.Flags.HasFlag(ActivityFlags.MultiDorm);

            if (activity.IncompatibleActivities.Any())
            {
                var incompat = new SortedSet <int>(activity.IncompatibleActivities);
                incompat.ExceptWith(ActivitiesDoneToday);
                if (incompat.Any())
                {
                    AvailableActivitiesToday.UnionWith(incompat);
                    AvailableMultiDormActivitiesToday.UnionWith(incompat.Intersect(ActivityInfo.MultiDormActivities));
                }
            }
            ActivitiesDoneToday.Remove(activity.ID);

            if (scheduledActivity.HasOther)
            {
                if (!ignoreHasOther)
                {
                    if (!DormPriorities.TryGetValue(scheduledActivity.OtherDorm, out InterDormTracking interDorm))
                    {
                        var index = UsedUpOtherDorms.FindIndex(d => d.Dorm == scheduledActivity.OtherDorm);
                        interDorm = (InterDormTracking)UsedUpOtherDorms[index].Clone();
                        UsedUpOtherDorms.RemoveAt(index);
                        DormPriorities.Add(scheduledActivity.OtherDorm, interDorm);
                    }

                    interDorm.ClearFromHistory(scheduledActivity, repeatable, multiDorm);
                    OtherDormsDoneToday.Remove(scheduledActivity.OtherDorm);
                }
            }
            else
            {
                DormPriorities[Dorm].ClearFromHistory(scheduledActivity, repeatable, multiDorm);
                OtherDormsDoneToday.Remove(Dorm);
            }

            if (repeatable)
            {
                if (RepeatableHistory.Contains(activity.ID))
                {
                    // if it wasn't cleared, it was the first time the activity was done by that dorm
                    if (!AvailableActivities.Add(activity.ID))
                    {
                        RepeatableHistory.Remove(activity.ID);
                    }
                    if (multiDorm)
                    {
                        AvailableMultiDormActivities.Add(activity.ID);
                    }
                    RepeatableTodayHistory.Remove(activity.ID);
                }
                else
                {
                    throw new NotImplementedException("Activity being cleared hasn't been undergone.");
                }

                if (ActivityPriorities.TryGetValue(activity.ID, out int activityPriority))
                {
                    if (++activityPriority == 0)
                    {
                        ActivityPriorities.Remove(activity.ID);
                    }
                }
                else
                {
                    ActivityPriorities.Add(activity.ID, 1);
                }
            }
            else
            {
                if (!AvailableActivities.Add(activity.ID))
                {
                    throw new NotImplementedException("Activity being cleared hasn't been undergone.");
                }
                if (multiDorm)
                {
                    AvailableMultiDormActivities.Add(activity.ID);
                }
            }

            AvailableActivitiesToday.Add(activity.ID);
            if (multiDorm)
            {
                AvailableMultiDormActivitiesToday.Add(activity.ID);
            }

            if (!activity.Flags.HasFlag(ActivityFlags.Manual) && (!activity.Flags.HasFlag(ActivityFlags.Exclusive) || !activity.Flags.HasFlag(ActivityFlags.Excess)))
            {
                TotalScheduledDuration -= activity.Duration;
            }
            else
            {
                TotalManualDuration -= activity.Duration;
            }
        }