Пример #1
0
        public Ship(Corporation owner)
            : this()
        {
            if (owner == null)
                throw new ArgumentNullException("owner");

            Owner = owner;
        }
Пример #2
0
        protected Structure(ILocation orbiting, Corporation owner)
            : base(orbiting)
        {
            Owner = owner;

            this.ships = new ObjectCollection<Ship>(this);
            this.personnel = new ObjectCollection<Agent>(this);
            this.stores = new ItemCollection<IItem>();
        }
Пример #3
0
            public MockShipYard(ILocation orbiting, Corporation owner)
                : base(orbiting, owner)
            {
                var refinedOre = new RefinedOre();
                refinedOre.Quantity = 1000;
                refinedOre.Owner = owner;

                AddItem(refinedOre);
            }
Пример #4
0
        public void BuildShip()
        {
            var universe = new Universe();
            var corp = new Corporation { Location = universe };
            var shipYard = new MockShipYard(universe, corp);

            var shipBlueprint = new ShipBlueprint {HardPoints = new[] {HardPoint.FactoryHardPoint(HardPointPosition.Front),}, BuildCost = 10, Speed = 20d, Location = shipYard, Owner = corp };
            shipBlueprint.Materials = new List<Material> {new Material(RefinedOre.RefinedOreID, "Refined Ore", 500)};
            shipBlueprint.Stats[ShipStatistic.HullIntegrity].SetValue(1000);
            shipBlueprint.Stats[ShipStatistic.Speed].SetValue(20);

            shipYard.Build(shipBlueprint);

            ulong tick = 0L;
            while ( shipYard.Ships.Count == 0 )
            {
                shipYard.Tick(tick);
                tick++;
            }
        }
Пример #5
0
        public void Agent()
        {
            var templateXml = @"<universe nextTemplateID=""0"">
              <playercorporation templateID=""0"" startupEmployeeCount=""5"" startupCapital=""10000"" />
              <corporation templateID=""1"" startupEmployeeCount=""5"" startupCapital=""10000"" />
              <agent templateID=""2"">
            <stats variation=""0.5000"">
              <stat type=""Charisma"" value=""10"" current=""0"" />
              <stat type=""Intelligence"" value=""10"" current=""0"" />
              <stat type=""Perception"" value=""10"" current=""0"" />
              <stat type=""Memory"" value=""10"" current=""0"" />
              <stat type=""Willpower"" value=""10"" current=""0"" />
            </stats>
              </agent>
            </universe>";

            var universe = new Universe();

            var xdoc = new XmlDocument();
            xdoc.LoadXml(templateXml);

            var factory = universe.ObjectFactory;

            factory.Load(xdoc.SelectRootElement());
            foreach (AgentStatistic agentStat in Enum.GetValues(typeof(AgentStatistic)))
            {
                Assert.AreEqual(10, factory.Agent.DefaultAgentStats[agentStat].Value);
            }

            var corporation = new Corporation {Location = universe};

            var agent = factory.Agent.Create(corporation);
            foreach ( AgentStatistic agentStat in Enum.GetValues(typeof(AgentStatistic)) )
            {
                Assert.GreaterOrEqual(agent.Stats[agentStat].Value, 5);
                Assert.LessOrEqual(agent.Stats[agentStat].Value, 15);
            }
        }
Пример #6
0
        public void TakeOwnership(Corporation newOwner)
        {
            if (newOwner == null)
                throw new ArgumentNullException("newOwner");

            var oldOwner = Owner;
            if (oldOwner != null)
                oldOwner.LoseStructure(this, newOwner);

            Owner = newOwner;

            this.personnel.RemoveAll(a => a.Employer == oldOwner);

            CorporationItems(oldOwner).ForEach(i => i.Owner = newOwner);
            CorporationShips(oldOwner).ForEach(s => s.Owner = newOwner);

            Owner.TakeStructure(this, oldOwner);
        }
Пример #7
0
 public List<Ship> CorporationShips(Corporation corporation)
 {
     return this.ships.FindAll(s => s.Owner == corporation);
 }
Пример #8
0
 public List<Agent> CorporationPersonnel(Corporation corporation)
 {
     return this.personnel.FindAll(a => a.Employer == corporation);
 }
Пример #9
0
 public List<IItem> CorporationItems(Corporation corporation)
 {
     return this.stores.FindAll(i => i.Owner == corporation);
 }
Пример #10
0
 /// <summary>Destroys the item</summary>
 public void Destroy()
 {
     Owner.RemoveAsset(this);
     owner = null;
 }
Пример #11
0
        public void TakeStructure(Structure structure, Corporation oldOwner)
        {
            structure.CorporationShips(this).ForEach(s => this.ships.Add(s));
            structure.Stores.ForEach(AddAsset);

            this.structures.Add(structure);

            Universe.EventPump.RaiseEvent(this, EventType.StructureLost, "Took {0} (a {1}) from {2}", Name, structure.StructureType, oldOwner);
        }
Пример #12
0
        public void LoseStructure(Structure structure, Corporation newOwner)
        {
            structure.Personnel.ForEach(p => this.employees.Remove(p));
            structure.Ships.ForEach(s => this.ships.Remove(s));
            structure.Stores.ForEach(RemoveAsset);

            this.structures.Remove(structure);

            Universe.EventPump.RaiseEvent(this, EventType.StructureLost, "Lost {0} (a {1}) to {2}", Name, structure.StructureType, newOwner);
        }
Пример #13
0
 public ShipYard(ILocation orbiting, Corporation owner)
     : base(orbiting, owner)
 {
 }
Пример #14
0
        public void RefineOre()
        {
            Rand.Initialise(0);

            var universe = new Universe();
            var sol = new SolarSystem { Location = universe };

            var corporation = new Corporation() { Location = universe };
            var mPilot = corporation.Recruit();
            var tPilot = corporation.Recruit();

            var asteroidBelt = new AsteroidBelt(sol) {Richness = 100};
            sol.OrbitSun(asteroidBelt, 100d);

            var refinery = new Refinery(sol, corporation) {OreProcessedPerTick = 5, Efficiency = 2.5d };
            sol.OrbitSun(refinery, 200d);

            var manufactory = new Manufactory(sol, corporation);
            sol.OrbitSun(manufactory, 400d);

            var m1 = new Ship(mPilot) { Speed = 5d, CargoHoldSize = 100d, Name = "M1", UniversalCoordinates = refinery.UniversalCoordinates };
            refinery.Dock(m1);

            var t1 = new Ship(tPilot) { Speed = 5d, CargoHoldSize = 10d, Name = "T1", UniversalCoordinates = refinery.UniversalCoordinates };
            refinery.Dock(t1);

            var start = new ShipTask(asteroidBelt, (ship, target) => asteroidBelt.Mine(ship));
            start = start.Join(refinery, (ship, target) => refinery.UnloadOre(ship)).Join(start);

            refinery.Undock(m1, mPilot);
            m1.SetTask(start);

            start = new ShipTask(refinery, (ship, target) => { refinery.LoadRefinedOre(ship); return ship.Cargo.Count > 0 && ship.Cargo[0].Quantity > 50; });
            start = start.Join(manufactory, (ship, target) => manufactory.UnloadRefinedOre(ship)).Join(start);

            refinery.Undock(t1, tPilot);
            t1.SetTask(start);

            CollectionAssert.Contains(sol.Objects, m1);
            CollectionAssert.Contains(sol.Objects, t1);

            ulong tick = 0L;
            while ( manufactory.OreRemaining < 100 )
            {
                Assert.Less(tick, 1000, "Ssytem took more than 1000 days to complete the task.  {0:n0} products manufactured", manufactory.ProductCount);

                sol.Tick(tick);
                tick++;
            }

            Console.WriteLine("System took {0} days to manufacture {1:n0} items", tick, manufactory.ProductCount);
            Console.WriteLine("The refinery had {0:n0} unprocessed ore", refinery.UnrefinedOre);
            Console.WriteLine("The manufactory has {0:n0} unprocessed ore for building", manufactory.OreRemaining);
        }
Пример #15
0
            public TestCase()
            {
                Universe = new Universe();

                Seller = new Corporation {Name = "Seller", Location = Universe };
                Buyer = new Corporation {Name = "Buyer", Location = Universe };

                var starCluster = new StarCluster();
                Universe.AddStarCluster(starCluster);

                var sol = new SolarSystem();
                starCluster.AddSolarSystem(sol);

                Refinery = new Refinery(sol, Seller);
                sol.OrbitSun(Refinery, 100d);

                var m1 = new Ship(Seller.Recruit()) {Name = "M1"};
                sol.EnterSystem(m1, Refinery.LocalCoordinates);
                Refinery.Dock(m1);

                var m2 = new Ship(Buyer.Recruit()) {Name = "M2"};
                sol.EnterSystem(m2, Refinery.LocalCoordinates);
                Refinery.Dock(m2);

                this.item = new Ore {Quantity = 1000, Location = Refinery, Owner = Seller};
            }
Пример #16
0
 public Refinery(ILocation orbiting, Corporation owner)
     : base(orbiting, owner)
 {
     OreProcessedPerTick = 100;
     Efficiency = 0.1d;
 }
Пример #17
0
 public Agent(Corporation employer)
 {
     Employer = employer;
     Stats = new AgentStatistics();
 }