private static Agent AddEmployee(Corporation target, Agent agent) { target.Employees.Add(agent); agent.Corporation = target; return agent; }
private static void ApplyStatDeltas(IIdResolver idResolver, Agent agent) { foreach (var implant in agent.Implants) { agent.Statistics[implant.Stat].Alter(implant); } agent.Statistics.Recalculate(); }
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)); }
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() }; }
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)); }
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); }
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); }
public void Fire(Agent agent) { if (Employees.Remove(agent)) { agent.Corporation = null; } }
public void Hire(Agent agent) { Ensure.That(agent.Corporation).IsNull(); Employees.Add(agent); agent.Corporation = this; }
public void Agent() { var item = new Agent(); item.ObjectType.ShouldBe(ObjectType.Agent); }
public UndockShipParameters(Ship ship, Agent pilot) { _ship = ship; _pilot = pilot; }