//////////////////////// /// Auxiliar Methods /// //////////////////////// ////////////////////// /// Public Methods /// ////////////////////// public LeisurePlan GetMostSatisfyingPlan(Citizen.NATURE nature, int currentHour, int limitHour) { LeisurePlan mostSatisfying = GetNullPlan(); int iteration = 0; foreach (Leisure l in LeisureVenues) { if (iteration++ < 1) { continue; } if (limitHour < currentHour) { limitHour += 24; } int closing = l.Schedule.Closing, openinng = l.Schedule.Opening; if (closing < openinng) { closing += 24; } int entering; if (currentHour > openinng) { if (currentHour < closing) { entering = currentHour; } else { entering = openinng; } } else { entering = openinng; } float satisfactionValue = l.Satisfaction.Value; if (nature == Leisure.typeToNatureMatching[(int)l.LeisureType]) { satisfactionValue += Global.Values.matchingNatureBonues; } if (satisfactionValue > mostSatisfying.Satisfaction && // If... it's more satisfying than the current option entering + l.Schedule.RequieredTime <= closing && // ... it's possible to do the activity before the closing entering + l.Schedule.RequieredTime <= limitHour) // ... it's possible to do the activity before it's too late { mostSatisfying.Enter = entering; mostSatisfying.Place = l.LeisurePlace; mostSatisfying.Satisfaction = satisfactionValue; mostSatisfying.TimeExpended = l.Schedule.RequieredTime; mostSatisfying.Cost = l.Cost; } } return(mostSatisfying); }
public LeisurePlan GetCheapestPlan(Citizen.NATURE nature, int currentHour, int limitHour) { LeisurePlan cheapest = GetNullPlan(); int iteration = 0; foreach (Leisure l in LeisureVenues) { if (iteration++ < 1) { continue; } if (limitHour < currentHour) { limitHour += 24; } int closing = l.Schedule.Closing, openinng = l.Schedule.Opening; if (closing < openinng) { closing += 24; } int entering; if (currentHour > openinng) { if (currentHour < closing) { entering = currentHour; } else { entering = openinng; } } else { entering = openinng; } if (cheapest.Cost < cheapest.Cost && entering + l.Schedule.RequieredTime <= closing && entering + l.Schedule.RequieredTime <= limitHour) { float satisfactionValue = l.Satisfaction.Value; if (nature == Leisure.typeToNatureMatching[(int)l.LeisureType]) { satisfactionValue += Global.Values.matchingNatureBonues; } cheapest.Enter = entering; cheapest.Place = l.LeisurePlace; cheapest.Satisfaction = satisfactionValue; cheapest.TimeExpended = l.Schedule.RequieredTime; cheapest.Cost = l.Cost; } } return(cheapest); }