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

                return agent;
            }
Esempio n. 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();
            }
Esempio n. 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));
        }
Esempio n. 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()
     };
 }
Esempio n. 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));
        }
Esempio n. 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);
            }
Esempio n. 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);
        }
Esempio n. 8
0
 public void Fire(Agent agent)
 {
     if (Employees.Remove(agent))
     {
         agent.Corporation = null;
     }
 }
Esempio n. 9
0
        public void Hire(Agent agent)
        {
            Ensure.That(agent.Corporation).IsNull();

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