示例#1
0
 public void GiveJob(Job job)
 {
     jobs.Add(job.Identifier, job);
 }
示例#2
0
 public void FireFromJob(Job job)
 {
     jobs.Remove(job.Identifier);
 }
示例#3
0
 public void GiveJobTo(Job job, Character newHolder)
 {
     jobManager.GiveJobTo(job, newHolder, this);
 }
示例#4
0
 public double MeasureJob(Character currentCharacter, Job job)
 {
     if (Perspective == currentCharacter)
         return 1000.0; //Jobs are great.  Really we should measure prestige modifiers since jobs can give you one.
     else
         return 0.0;
 }
示例#5
0
        public void GiveJobTo(Job job, Character newHolder, Game game)
        {
            if(job.Unique)
            {
                Character oldHolder = uniqueJobs[job];

                if(oldHolder != null)
                {
                    if (job.Permanent)
                        throw new InvalidOperationException("You tried to fire the king!! He chops your head off instead.");

                    oldHolder.FireFromJob(job);

                    Event fireEvent = game.GetEventById(job.OnFire);
                    if (fireEvent != null)
                    {
                        EventContext context = new EventContext(oldHolder);
                        fireEvent.Execute(new EventResults(), game, context);
                        //We need to commit any changes.
                        context.Commit();
                    }
                }

                if(newHolder != null)
                {
                    newHolder.GiveJob(job);

                    Event hireEvent = game.GetEventById(job.OnHire);
                    if (hireEvent != null)
                    {
                        EventContext context = new EventContext(newHolder);
                        hireEvent.Execute(new EventResults(), game, context);
                        //We need to commit any changes.
                        context.Commit();
                    }
                }

                uniqueJobs[job] = newHolder;
            }
            else
            {
                if(newHolder != null)
                {
                    newHolder.GiveJob(job);

                    Event hireEvent = game.GetEventById(job.OnHire);
                    if (hireEvent != null)
                    {
                        EventContext context = new EventContext(newHolder);
                        hireEvent.Execute(new EventResults(), game, context);
                        //We need to commit any changes.
                        context.Commit();
                    }
                }
            }
        }