Beispiel #1
0
            private static Agent AddEmployee(Corporation target, Agent agent)
            {
                target.Employees.Add(agent);
                agent.Corporation = target;

                return agent;
            }
Beispiel #2
0
            private static void ApplyStatDeltas(IIdResolver idResolver, Agent agent)
            {
                foreach (var implant in agent.Implants)
                {
                    agent.Statistics[implant.Stat].Alter(implant);
                }

                agent.Statistics.Recalculate();
            }
Beispiel #3
0
        public void CantUndockWithoutShipSkillLevel()
        {
            var structure = new Manufactory();
            var ship = new Ship { Position = new Position(structure, Vector.Zero), ShipInfo = GetShipInfo() };
            var pilot = new Agent { Skills = { { SkillCode.SpaceshipCommand, new Echo.Agents.Skills.SkillLevel { Level = 1 } } } };

            _task.SetParameters(new UndockShipParameters(ship, pilot));
            var result = (UndockShipResult)_task.Execute();
            Assert.That(result.StatusCode, Is.EqualTo(ShipTask.StatusCode.MissingSkillRequirement));
        }
Beispiel #4
0
 public static AgentState Save(Agent agent)
 {
     return new AgentState
     {
         ObjectId = agent.Id,
         Name = agent.Name,
         Statistics = agent.Statistics.Select(Save),
         Skills = agent.Skills.Select(Save),
         Location = agent.Location.AsObjectReference()
     };
 }
Beispiel #5
0
        public void CanUndockWithShipSkill()
        {
            var solarSystem = new SolarSystem();
            var structure = new Manufactory { Position = new Position(solarSystem, Vector.Parse("0,1,0")) };
            var ship = new Ship { Position = new Position(structure, Vector.Zero), ShipInfo = GetShipInfo() };
            var pilot = new Agent { Skills = { { SkillCode.SpaceshipCommand, new Echo.Agents.Skills.SkillLevel { Level = 5 } } } };

            _task.SetParameters(new UndockShipParameters(ship, pilot));

            var result = _task.Execute();
            Assert.That(result.Success, Is.True, result.StatusCode);
            Assert.That(ship.Position.LocalCoordinates, Is.EqualTo(structure.Position.LocalCoordinates));
            Assert.That(ship.Position.Location, Is.EqualTo(solarSystem));
        }
Beispiel #6
0
            public static ObjectBuilder<Agent> Build(AgentState state)
            {
                var agent = new Agent
                {
                    Id = state.ObjectId,
                    Name = state.Name,
                    Statistics = new AgentStatistics(state.Statistics.Select(Build)),
                    Implants = new ImplantCollection(state.Implants)
                };

                return new ObjectBuilder<Agent>(agent)
                    .Resolve((resolver, target) => target.Location = resolver.Get<ILocation>(state.Location))
                    .Resolve((resolver, target) => target.Skills = new SkillCollection(state.Skills.Select(skill => Build(resolver, skill))))
                    .Resolve(ApplyStatDeltas);
            }
Beispiel #7
0
        public void CantUndockWhenNotDocked()
        {
            var ship = new Ship();
            var pilot = new Agent();

            _task.SetParameters(new UndockShipParameters(ship, pilot));

            var result = (UndockShipResult )_task.Execute();
            Assert.That(result.Success, Is.False);
            Assert.That(result.StatusCode, Is.EqualTo(ShipTask.StatusCode.NotDocked));

            ITaskResult taskResult = result;
            Assert.That(taskResult.StatusCode, Is.EqualTo("NotDocked"));
            Assert.That(taskResult.ErrorParams, Has.Property("Ship").EqualTo(ship));
            Assert.That(taskResult.ErrorParams, Has.Property("Pilot").Null);
        }
Beispiel #8
0
 public void Fire(Agent agent)
 {
     if (Employees.Remove(agent))
     {
         agent.Corporation = null;
     }
 }
Beispiel #9
0
        public void Hire(Agent agent)
        {
            Ensure.That(agent.Corporation).IsNull();

            Employees.Add(agent);
            agent.Corporation = this;
        }
Beispiel #10
0
 public void Agent()
 {
     var item = new Agent();
     item.ObjectType.ShouldBe(ObjectType.Agent);
 }
Beispiel #11
0
 public UndockShipParameters(Ship ship, Agent pilot)
 {
     _ship = ship;
     _pilot = pilot;
 }