Exemple #1
0
        private void applyJobFactors(PlaceState place, JobOffer offer)
        {
            if (offer.TrustFactor < 1.0f)
            {
                foreach (var dock in place.Docks)
                {
                    var schedule = dock.Schedule;
                    for (int i = 0; i < schedule.Jobs.Count; i++)
                    {
                        var item = schedule.Jobs[i];
                        if (item.Job.Id == offer.Id)
                        {
                            MessageLog.AddError(string.Format("{0} has cancelled your contract to ship {1} from {2} to {3}",
                                                              item.Job.Company,
                                                              item.Job.Item.Name,
                                                              item.Job.From.Name,
                                                              item.Job.To.Name));

                            schedule.Jobs.RemoveAt(i);
                            i--;
                        }
                    }
                }
            }
        }
Exemple #2
0
        private void StartJob(PlaceState place, ShipTimeAssignment assignee, ScheduledJob job)
        {
            if (!place.Employees.Contains(assignee.AssignedEmployee))
            {
                job.Job.JobWasCompletedUnsuccesfully();

                MessageLog.AddError(string.Format("{0} {1} missed their trip to {2} from {3} at {4}",
                                                  assignee.AssignedEmployee.Name,
                                                  assignee.AssignedEmployee.Id,
                                                  job.Job.To.Name, job.Job.From.Name, assignee.Time.ToString("h':'m''")));
                return;
            }

            var employee = assignee.AssignedEmployee;

            if (employee.AssignedTruck == null)
            {
                MessageLog.AddError(string.Format("{0} {1} does not have a truck to drive to {2} from {3} at {4}",
                                                  assignee.AssignedEmployee.Name,
                                                  assignee.AssignedEmployee.Id,
                                                  job.Job.To.Name, job.Job.From.Name, assignee.Time.ToString("h':'m''")));
                return;
            }

            if (employee.CurrentJob == null)
            {
                employee.CurrentLocation = null;
                place.Employees.Remove(assignee.AssignedEmployee);
                var activeJob = new ActiveJob(job, assignee, Time - TimeSpan.FromMinutes(Time.Minute % 15), employee);
                Money -= activeJob.GasPrice();

                employee.CurrentJob = activeJob;
                ActiveJobs.Add(activeJob);

                MessageLog.AddInfo(string.Format("{0} left {1}, driving to {2}", assignee.AssignedEmployee.Name, job.Job.From.Name, job.Job.To.Name));
            }
        }