Ejemplo n.º 1
0
        public void ShipUnloadingSelling()
        {
            Universe        u      = new Universe(0);
            Station         city   = u.GetStation(1);
            Station         city2  = u.GetStation(2);
            Corporation     player = u.CreateCorp(1);
            Ship            ship   = city.CreateShip(player);
            ResourceElement e      = new ResourceElement(ResourceElement.ResourceType.Food, city2, 100, 1);
            ResourceStack   stack  = new ResourceStack(e);

            ship.Cargo.Add(stack);

            Hangar h = city.CreateHangar(player);

            ShipDestination dest = ship.AddDestination(city);

            dest.AddUnload(ResourceElement.ResourceType.Food, 100);
            ship.Start();

            //ca prend 10 fois pour decharger
            for (int i = 0; i < 11; i++)
            {
                u.Update();
            }

            Assert.AreEqual(0, ship.Cargo.GetResourceQte(ResourceElement.ResourceType.Food));
            Assert.AreEqual(15000, ship.Owner.ICU);
            Assert.AreEqual(100, city.GetHangar(-1).GetResourceQte(ResourceElement.ResourceType.Food));
        }
Ejemplo n.º 2
0
        public void StandingTest1()
        {
            Universe        universe = new Universe(0);
            Station         s        = universe.GetStation(1);
            Corporation     corp     = universe.CreateCorp(1);
            Ship            ship     = s.CreateShip(corp);
            ShipDestination dest     = ship.AddDestination(s);

            dest.AddLoad(ResourceElement.ResourceType.Wastes, 1000);
            ship.Start();

            Hangar corpHangar = s.CreateHangar(corp);

            ResourceElement elem  = new ResourceElement(ResourceElement.ResourceType.Wastes, s, 2000, 1);
            ResourceStack   stack = new ResourceStack(elem);

            corpHangar.Add(stack);

            Assert.IsTrue(s.Type == Station.StationType.City);
            Assert.IsTrue(System.Math.Abs(s.GetStanding(ResourceElement.ResourceType.Water, 1) - Station.defaultStanding) < 0.0001);
            Assert.IsTrue(System.Math.Abs(s.GetStanding(ResourceElement.ResourceType.Wastes, 1) - Station.defaultStanding) < 0.0001);

            //simuler une augmentation de standing
            for (int i = 0; i < 10; i++)
            {
                universe.Update();
            }

            //apres 2 jours de chargement...
            // day1 : 0.0 + (1 * 0.05) = 0.05
            // day2 : 0.05 + ((1-0.05) * 0.05) = 0.0975
            Assert.IsTrue(System.Math.Abs(s.GetStanding(ResourceElement.ResourceType.Wastes, 1) - 0.0975) < 0.0001);
        }
Ejemplo n.º 3
0
        public void ShipLoading1()
        {
            Universe        u    = new Universe(0);
            Station         s    = u.GetStation(1);
            Station         s2   = u.GetStation(2);
            Corporation     corp = u.CreateCorp(1);
            Ship            ship = s.CreateShip(corp);
            Hangar          h    = s.CreateHangar(corp);
            ResourceElement e    = new ResourceElement(ResourceElement.ResourceType.Wastes, s, 100, 1);

            h.Add(new ResourceStack(e));

            s.CreateHangar(corp);
            ShipDestination dest = ship.AddDestination(s);

            dest.AddLoad(ResourceElement.ResourceType.Wastes, 100);

            ShipDestination dest2 = ship.AddDestination(s2);

            ship.Start();

            for (int ite = 0; ite < 10; ite++)
            {
                u.Update();
            }

            Assert.AreEqual(100, ship.Cargo.GetResourceQte(ResourceElement.ResourceType.Wastes));

            u.Update(); //chargerment
            u.Update(); //sortie
            Assert.IsNull(ship.CurrentStation);
        }
Ejemplo n.º 4
0
        public void ShipMoving1()
        {
            Universe    u    = new Universe(0);
            Station     s    = u.GetStation(1);
            Station     s2   = u.GetStation(2);
            Corporation corp = u.CreateCorp(1);
            Ship        ship = s.CreateShip(corp);

            ShipDestination dest  = ship.AddDestination(s2);
            ShipDestination dest2 = ship.AddDestination(s);

            ship.Start();
            Assert.NotNull(ship.CurrentStation);
            Assert.AreEqual(s.ID, ship.CurrentStation.ID);

            u.Update();//on devrait sortir
            Assert.IsNull(ship.CurrentStation);

            for (int ite = 0; ite < 9; ite++)   //station suivante
            {
                u.Update();
            }
            Assert.NotNull(ship.CurrentStation);
            Assert.AreEqual(s2.ID, ship.CurrentStation.ID);

            for (int ite = 0; ite < 11; ite++)   //sortir + station suivante
            {
                u.Update();
            }
            Assert.NotNull(ship.CurrentStation);
            Assert.AreEqual(s.ID, ship.CurrentStation.ID);
        }
Ejemplo n.º 5
0
        public void CorporationICUs1()
        {
            Universe    u    = new Universe(0);
            Corporation corp = u.CreateCorp(1);

            Assert.AreEqual(100, corp.ICU);

            bool eventTest = false;

            corp.onICUChange += (i) => { eventTest = true; };

            corp.AddICU(1000, "");
            Assert.AreEqual(1100, corp.ICU);
            Assert.IsTrue(eventTest);
            eventTest = false;

            corp.RemoveICU(750, "");
            Assert.AreEqual(350, corp.ICU);
            Assert.IsTrue(eventTest);
            eventTest = false;

            corp.RemoveICU(750, "");
            Assert.AreEqual(-400, corp.ICU);
            Assert.IsTrue(eventTest);
            eventTest = false;
        }
Ejemplo n.º 6
0
        public void ShipCreation1()
        {
            Universe    u    = new Universe(0);
            Station     s    = u.GetStation(1);
            Corporation corp = u.CreateCorp(1);
            Ship        ship = s.CreateShip(corp);

            Assert.NotNull(ship);
        }
Ejemplo n.º 7
0
        public void ShipDestinations()
        {
            Universe    u    = new Universe(0);
            Corporation corp = u.CreateCorp(1);
            Ship        ship = s1.CreateShip(corp);

            ship.AddDestination(s1);
            ship.AddDestination(s2);
            ship.AddDestination(s3, 1);

            Assert.AreEqual(s1.ID, ship.GetDestination(0).Destination.ID);
            Assert.AreEqual(s3.ID, ship.GetDestination(1).Destination.ID);
            Assert.AreEqual(s2.ID, ship.GetDestination(2).Destination.ID);
        }
Ejemplo n.º 8
0
 public void init()
 {
     u    = new Universe(0);
     corp = u.CreateCorp(1);
     corp.AddICU(300, "");
 }