public JobOffer Reverse() { var reversedConnections = new List <BasePlace>(); for (int i = Connections.Count - 1; i >= 0; i--) { reversedConnections.Add(Connections[i]); } var reversePath = new JobOffer(-1, Company, this.To, this.From, null, 0, null, reversedConnections); return(reversePath); }
public static void CreateDefault() { OwnedPlaces = new List <PlaceState>(); OwnedPlaces.Add(new PlaceState(WorldData.GetPlaceByName("Winnipeg"))); OwnedPlaces.Add(new PlaceState(WorldData.GetPlaceByName("Quebec"))); var winnipeg = GetStateForPlace(WorldData.GetPlaceByName("Winnipeg")); var employees = winnipeg.Employees; for (int i = 0; i < 2; i++) { var truck = new Truck_TGX_D38(); winnipeg.Trucks.Add(truck); var employee = EmployeeState.GenerateNew(winnipeg); employee.AssignTruck(truck); employees.Add(employee); } var jobs = winnipeg.AvailableJobs; jobs.Add(new JobOffer(1, "Good Foods Inc", winnipeg.Place, WorldData.GetPlaceByName("Ottawa"), TransportableItem.Bananas, 1100, new List <Weekday>() { Weekday.Friday, Weekday.Saturday, Weekday.Sunday })); var existingJob = new JobOffer(2, "Nutty Inc", winnipeg.Place, WorldData.GetPlaceByName("Quebec"), TransportableItem.Peanuts, 1350, new List <Weekday>() { Weekday.Monday, Weekday.Tuesday }); winnipeg.Docks[0].Schedule.Jobs.Add(new ScheduledJob(existingJob, new Dictionary <Weekday, ShipTimeAssignment>() { { Weekday.Monday, new ShipTimeAssignment(new TimeSpan(7, 15, 0), WorldState.GetEmployeeById("#000002"), false) }, { Weekday.Tuesday, new ShipTimeAssignment(new TimeSpan(12, 30, 0), WorldState.GetEmployeeById("#000004"), false) } })); }
public ScheduledJob(JobOffer job, Dictionary <Weekday, ShipTimeAssignment> shipTime) : this(job) { ShipTimes = shipTime; if (job.IsReturnDrive) { return; } foreach (var item in ShipTimes) { if (!job.ShipDays.Contains(item.Key)) { throw new Exception("Shipday and time assigned to job that shouldn't ship on that day."); } } }
public bool CanScheduleJob(Weekday day, TimeSpan time, JobOffer toReplace = null) { foreach (var item in Jobs) { if (toReplace != null && item.Job.Id == toReplace.Id) { continue; } foreach (var plannedTime in item.ShipTimes) { if (plannedTime.Key == day && plannedTime.Value.Time == time) { return(false); } } } return(true); }
public ScheduledJob(JobOffer job) { Job = job; }