/// <summary> /// 配置を行う /// </summary> /// <param name="EachDay"></param> /// <param name="member"></param> /// <returns></returns> internal bool Allocation(Day EachDay, Member member) { //カレントの曜日の清掃箇所ランダムリストを回す foreach (var CleaningPart in EachDay.place) { //割り当てオブジェクト作成 Day today = new Day(); //曜日を設定 today.days = EachDay.days; if (EachDay.days == ContractConst.DAYS.金) { System.Diagnostics.Debug.WriteLine(""); } //清掃箇所のランダムキューに値が存在する間ループを回す if (CleaningPart.value.Count > 0) { //先頭の清掃箇所を取得 int? randamPlaceValue = CleaningPart.value.Dequeue(); //清掃可否判定を行う if (CheckCleanable(member, randamPlaceValue, today.days)) { //担当箇所オブジェクト作成 Place ResponsiblePlace = new Place(); //同日内清掃箇所リストに追加 ResponsiblePlace.value.Enqueue(randamPlaceValue); //カレントの曜日の清掃箇所を決定 today.place.Add(ResponsiblePlace); //得点を足しこむ if (randamPlaceValue == null) { member.Score += 0; } else { member.Score += ContractConst.COEFFICIENT[(int)randamPlaceValue]; } member.day.Add(today); member.Info += today.days.ToString() + randamPlaceValue.ToString() + " "; } else { CleaningPart.value.Enqueue(randamPlaceValue); } } else { return false; } } return true; }
/// <summary> /// 休日設定されている曜日かどうか判定する /// </summary> /// <param name="mainWindow"></param> /// <param name="EachDay"></param> private bool JudgmentHoliday(MainWindow mainWindow, Day EachDay) { if (mainWindow.chkMon.IsChecked == true && EachDay.days == ContractConst.DAYS.月) { return true; } if (mainWindow.chkTue.IsChecked == true && EachDay.days == ContractConst.DAYS.火) { return true; } if (mainWindow.chkWed.IsChecked == true && EachDay.days == ContractConst.DAYS.水) { return true; } if (mainWindow.chkThu.IsChecked == true && EachDay.days == ContractConst.DAYS.木) { return true; } if (mainWindow.chkFri.IsChecked == true && EachDay.days == ContractConst.DAYS.金) { return true; } return false; }
/// <summary> /// 曜日単位のデータを作成 /// </summary> /// <param name="obj"></param> /// <returns></returns> private Day DayLoccation(int[] p) { Day day = new Day(); Place place = new Place(); while (place.value.Count() < p.Count()) { System.Random rng = new System.Random(); int k = rng.Next(p.Count()); int num = p[k]; if (!place.value.Contains(num)) { place.value.Enqueue(p[k]); } } day.place.Add(place); return day; }
/// <summary> /// 一週間分のデータを作成 /// </summary> /// <returns></returns> internal RandamWeekMap CreateNumMap() { Day day = new Day(); RandamWeekMap RandamWeekMap = new RandamWeekMap(); for (int i = 0; i < ContractConst.WEEK.Count() - 1; i++) { int[] obj = (int[])ContractConst.WEEK[i]; day = DayLoccation(obj); RandamWeekMap.day.Add(day); } int j = 0; foreach (ContractConst.DAYS v in Enum.GetValues(typeof(ContractConst.DAYS))) { RandamWeekMap.day[j].days = v; j++; } return RandamWeekMap; }