Example #1
0
        private void GraphAltitude(DateTime gStart, DateTime gEnd, Celestial.RADec gRaDec, Celestial.LatLon gloc, string gName, Color gcolor)
        {
            //Graph the altitude change on 10 min intervals between gstart and gend for the position gRaDec for th observer at location gloc
            const int gPoints = 60;  //number of points to graph

            double   gInterval = (gEnd - gStart).TotalHours / gPoints;
            DateTime gTime     = gStart;

            while (gTime <= gEnd)
            {
                double haR      = gRaDec.HourAngle(gTime, gloc);
                double haH      = Transform.RadiansToHours(haR);
                double altR     = gRaDec.Altitude(haR, gloc);
                double altitude = Transform.RadiansToDegrees(altR);
                //
                double gst = Celestial.DateUTCToGST(gTime);
                double lst = Celestial.GSTToLST(gst, gloc.Lon);
                //

                if (altitude > 0)
                {
                    DateTime localTime = gTime.ToLocalTime();
                    AltitudeChart.Series[gName].Points.AddXY(localTime, altitude);
                }
                //If (TargetControl.IsMoonUp(ImageForecastForm.tgtdata, ImageForecastForm.moondata, gTime))) Then
                //    AltitudeChart.Series("AltitudePath").Points.
                gTime = gTime.AddHours(gInterval);
            }
            return;
        }
Example #2
0
    private void Update()
    {
        Celestial selected = null;

        foreach (Celestial cel in celestials)
        {
            if (cel.mouse_hover)
            {
                if (selected == null || cel.click_distance < selected.click_distance)
                {
                    selected = cel;
                }
            }
        }
        if (selected == null)
        {
            planet_hover = CelestialData.None;
        }
        else
        {
            planet_hover = selected.data;
            if (Input.GetMouseButtonDown(0) && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
            {
                selected.in_focus = true;
                cam.Stick(selected);
                PlanetInformation.Active.UpdateLabels(selected.data);
                NatonInformation.Active.UpdateLabels();
            }
        }
        back_button.enabled = !planet_view.none;
    }
Example #3
0
        private DateTime GetSunsetDate(DateTime date)
        {
            Celestial celestial = Celestial.CalculateCelestialTimes(42.304428, -87.948996, date);
            var       sunset    = celestial.SunSet.Value;

            return(sunset);
        }
Example #4
0
        private DateTime GetSunriseDate(DateTime date)
        {
            Celestial celestial = Celestial.CalculateCelestialTimes(42.304428, -87.948996, date);
            var       sunrise   = celestial.SunRise.Value;

            return(sunrise);
        }
Example #5
0
    void CacheCelestials(Celestial orbit)
    {
        for (int i = 0; i < RuntimeData.system.celestials.Count; i++)
        {
            if (RuntimeData.system.celestials[i] != orbit)
            {
                _localCelestials.Add(
                    new LocalCelestial(
                        RuntimeData.system.celestials[i],
                        RuntimeData.system.celestials[i].location - _location));
            }
        }

        Vector3[] cardinals = new Vector3[]
        {
            Vector3.up,
            Vector3.down,
            Vector3.right,
            Vector3.left,
            Vector3.forward,
            Vector3.back
        };

        if (orbit != null)
        {
            _localCelestials.Add(new LocalCelestial(orbit, cardinals.RandomItem()));
        }
    }
Example #6
0
        public void CancelExpedition_CancelsExpedition_Only_After_Confirmation()
        {
            Celestial         celestial    = Build.A.Celestial.ThatHasNotBeenScanned();
            StarSystem        firstSystem  = Build.A.StarSystem.WithCelestial(celestial);
            StarSystem        secondSystem = Build.A.StarSystem.WithCelestial(celestial);
            List <StarSystem> starSystems  = Build.Many.StarSystems(firstSystem, secondSystem);

            _navigator.PlanExpedition(starSystems);

            TestEvent testEvent = Build.An.Event.WithEvent(_sut.SupportedCommand);

            _sut.Handle(testEvent);

            _navigator.ExpeditionStarted.Should().BeTrue();
            _navigator.ExpeditionComplete.Should().BeFalse();
            _navigator.CelestialsRemaining().Should().Be(2);
            _navigator.SystemsRemaining().Should().Be(2);

            _sut.Handle(testEvent);

            _navigator.ExpeditionStarted.Should().BeFalse();
            _navigator.ExpeditionComplete.Should().BeTrue();
            _navigator.CelestialsRemaining().Should().Be(0);
            _navigator.SystemsRemaining().Should().Be(0);
        }
        private static bool Extensions_Null(Celestial cel, EagerLoad_ExtensionsType t)
        {
            if (cel.SunSet != null && t != EagerLoad_ExtensionsType.Solar_Cycle)
            {
                return(false);
            }
            if (cel.MoonSet != null && t != EagerLoad_ExtensionsType.Lunar_Cycle)
            {
                return(false);
            }
            if (cel.LunarEclipse.NextEclipse.MidEclipse.Year > 0001 && t != EagerLoad_ExtensionsType.Lunar_Eclipse)
            {
                return(false);
            }
            if (cel.SolarEclipse.NextEclipse.MaximumEclipse.Year > 0001 && t != EagerLoad_ExtensionsType.Solar_Eclipse)
            {
                return(false);
            }
            if (cel.AstrologicalSigns.MoonName != null && cel.AstrologicalSigns.ZodiacSign != null && t != EagerLoad_ExtensionsType.Zodiac)
            {
                return(false);
            }

            return(true);
        }
Example #8
0
        public void Adjust(bool force)
        {
            mutex.WaitOne();

            if (force)
            {
                lightMode  = -1;
                brightness = -1;
            }

            Celestial celestial = Celestial.CalculateCelestialTimes
                                      (location.Latitude, location.Longitude, DateTime.UtcNow);

            if (celestial.IsSunUp)
            {
                SetLightMode(1);
            }
            else
            {
                SetLightMode(0);
            }

            double factor = (Sin(celestial.SunAltitude * PI / 180.0) + 0.3) * 1.0 / 1.3;

            if (factor > 0.0)
            {
                SetBrightness((int)(Sqrt(factor) * 100.0));
            }
            else
            {
                SetBrightness(0);
            }

            mutex.ReleaseMutex();
        }
        public void SkipSystem_With_System_Not_In_Expedition_Does_Nothing()
        {
            TestCommunicator       communicator = CreateCommunicator();
            Navigator              navigator    = CreateNavigator();
            PlayerStatusRepository playerStatus = CreatePlayerStatusRepository();
            var skipSystemPhrases     = TestPhraseBuilder.Build <SkipSystemPhrases>();
            var scansRemainingPhrases = TestPhraseBuilder.Build <ScansRemainingPhrases>();

            SkipSystemCommand sut = new SkipSystemCommand(communicator, navigator, playerStatus, skipSystemPhrases, scansRemainingPhrases);

            Celestial         celestial   = Build.A.Celestial.ThatHasNotBeenScanned();
            StarSystem        firstSystem = Build.A.StarSystem.WithCelestials(celestial, celestial, celestial);
            StarSystem        nextSystem  = Build.A.StarSystem.WithCelestials(celestial, celestial, celestial);
            List <StarSystem> systems     = Build.Many.StarSystems(firstSystem, nextSystem);

            navigator.PlanExpedition(systems);
            playerStatus.SetLocation("Test");

            TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand);

            sut.Handle(testEvent);

            List <StarSystem> storedSystems = navigator.GetAllExpeditionSystems();

            storedSystems.All(s => s.Scanned == false).Should().BeTrue();
            storedSystems.SelectMany(s => s.Celestials).All(s => s.Scanned == false).Should().BeTrue();

            navigator.GetNextSystem().ShouldBeEquivalentTo(firstSystem);
        }
        public void ScanEvent_WithCelestialsRemaining_ShouldUpdateDataStore()
        {
            TestPhraseBuilder.Build <CelestialScanPhrases>();

            IDataStore <StarSystemDocument> dataStore = CreateDataStore();
            Navigator navigator = CreateNavigator(dataStore);
            PlayerStatusRepository playerStatus = CreatePlayerStatusRepository();
            CelestialScanCommand   sut          = CreateSut(navigator, playerStatus, _phrases);

            Celestial         celestial     = Build.A.Celestial;
            Celestial         nextCelestial = Build.A.Celestial;
            StarSystem        currentSystem = Build.A.StarSystem.WithCelestials(celestial, nextCelestial);
            List <StarSystem> starSystems   = Build.Many.StarSystems(currentSystem);

            navigator.PlanExpedition(starSystems);
            playerStatus.SetLocation(currentSystem.Name);

            TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand)
                                  .WithPayload(_payloadKey, celestial.Name);

            sut.Handle(testEvent);

            dataStore.FindOne(s => s.Name == currentSystem.Name).Celestials.Single(c => c.Name == celestial.Name).Scanned.Should().BeTrue();
            dataStore.FindOne(s => s.Celestials.Any(c => c.Scanned == false)).Name.Should().Be(currentSystem.Name);
        }
Example #11
0
        private void Check_Solar_Only_Times()
        {
            bool pass = true;

            //Check if values populate.
            Celestial c = Celestial.CalculateSunData(45, 45, DateTime.Now);
        }
Example #12
0
    public void Stick(Celestial parent)
    {
        UnStick();
        Vector3 parent_pos = parent.parent_celestial.transform.position;
        Vector3 pred_point;

        if (parent.parent_celestial.is_static)
        {
            pred_point = Quaternion.AngleAxis(parent.angular_velocity * zoom_time, parent.orbit_plane) * parent.transform.position;
        }
        else
        {
            pred_point = Quaternion.AngleAxis(parent.parent_celestial.angular_velocity * zoom_time, parent.parent_celestial.orbit_plane) * parent_pos +
                         Quaternion.AngleAxis(parent.angular_velocity * zoom_time, parent.orbit_plane) * (parent.transform.position - parent_pos);
        }
        float max_sattelite_radius = parent.Radius;

        foreach (Celestial satelite in parent.satellites)
        {
            if (satelite.OrbitalRadius > max_sattelite_radius)
            {
                max_sattelite_radius = satelite.OrbitalRadius;
            }
        }
        MoveTo(pred_point - transform.rotation * new Vector3(0.2f, 0, 1) * (1 + max_sattelite_radius), zoom_time);
        planed_parent = parent.transform;
        CampagneManager.planet_view = parent.data;
    }
        public void ScanEvent_WithSystemNotNextInSequence_ShouldUpdateCorrectSystem()
        {
            IDataStore <StarSystemDocument> dataStore = CreateDataStore();
            Navigator navigator = CreateNavigator(dataStore);
            PlayerStatusRepository playerStatus = CreatePlayerStatusRepository();
            CelestialScanCommand   sut          = CreateSut(navigator, playerStatus, _phrases);
            Celestial         celestial         = Build.A.Celestial;
            StarSystem        firstSystem       = Build.A.StarSystem.WithCelestial(Build.A.Celestial);
            StarSystem        secondSystem      = Build.A.StarSystem.WithCelestial(celestial);
            StarSystem        thirdSystem       = Build.A.StarSystem.WithCelestial(celestial);
            List <StarSystem> starSystems       = Build.Many.StarSystems(firstSystem, secondSystem, thirdSystem);

            navigator.PlanExpedition(starSystems);
            playerStatus.SetLocation(secondSystem.Name);

            TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand)
                                  .WithPayload(_payloadKey, celestial.Name);

            sut.Handle(testEvent);

            StarSystemDocument firstSystemStored  = dataStore.FindOne(s => s.Name == firstSystem.Name);
            StarSystemDocument secondSystemStored = dataStore.FindOne(s => s.Name == secondSystem.Name);
            StarSystemDocument thirdSystemStored  = dataStore.FindOne(s => s.Name == thirdSystem.Name);

            firstSystemStored.Scanned.Should().BeFalse();
            firstSystemStored.Celestials.All(c => c.Scanned == false).Should().BeTrue();

            secondSystemStored.Scanned.Should().BeTrue();
            secondSystemStored.Celestials.All(c => c.Scanned).Should().BeTrue();

            thirdSystemStored.Scanned.Should().BeFalse();
            thirdSystemStored.Celestials.All(c => c.Scanned == false).Should().BeTrue();
        }
Example #14
0
        public void GetSunriseTime_Should_Return_Correct_Results()
        {
            var sunriseTime = Celestial.GetSunriseTime(0.0, 0.0);

            sunriseTime.Hour.Should().Be(0);
            sunriseTime.Minute.Should().Be(0);

            sunriseTime = Celestial.GetSunriseTime(0.14583333333333, 0.0);
            sunriseTime.Hour.Should().Be(3);
            sunriseTime.Minute.Should().Be(29);

            sunriseTime = Celestial.GetSunriseTime(0.25, 0.0);
            sunriseTime.Hour.Should().Be(6);
            sunriseTime.Minute.Should().Be(0);

            sunriseTime = Celestial.GetSunriseTime(0.48958333333333, 0.0);
            sunriseTime.Hour.Should().Be(11);
            sunriseTime.Minute.Should().Be(44);

            sunriseTime = Celestial.GetSunriseTime(0.5, 0.0);
            sunriseTime.Hour.Should().Be(12);
            sunriseTime.Minute.Should().Be(0);

            sunriseTime = Celestial.GetSunriseTime(0.68402777777778, 0.0);
            sunriseTime.Hour.Should().Be(16);
            sunriseTime.Minute.Should().Be(25);

            sunriseTime = Celestial.GetSunriseTime(0.75, 0.0);
            sunriseTime.Hour.Should().Be(18);
            sunriseTime.Minute.Should().Be(0);
        }
Example #15
0
 public void ThreeRelation_Should_Return_Correct_Results()
 {
     Celestial.ThreeRelation(-1, 1, 3).Should().Be(1);
     Celestial.ThreeRelation(1, -1, -3).Should().Be(-1);
     Celestial.ThreeRelation(1, 1, 1).Should().Be(0);
     Celestial.ThreeRelation(1, 5, -3).Should().Be(0); //invalid scenario
 }
        public void RescanSystem_With_System_In_Expedition_Marks_System_As_Unscanned()
        {
            TestCommunicator       communicator = CreateCommunicator();
            Navigator              navigator    = CreateNavigator();
            PlayerStatusRepository playerStatus = CreatePlayerStatusRepository();
            var rescanSystemPhrases             = TestPhraseBuilder.Build <RescanSystemPhrases>();
            var scansRemainingPhrases           = TestPhraseBuilder.Build <ScansRemainingPhrases>();

            RescanSystemCommand sut = new RescanSystemCommand(communicator, navigator, playerStatus, rescanSystemPhrases, scansRemainingPhrases);

            Celestial         scannedCelestial   = Build.A.Celestial.ThatHasBeenScanned();
            Celestial         unscannedCelestial = Build.A.Celestial.ThatHasNotBeenScanned();
            StarSystem        firstSystem        = Build.A.StarSystem.WithCelestials(scannedCelestial, scannedCelestial, scannedCelestial);
            StarSystem        nextSystem         = Build.A.StarSystem.WithCelestials(unscannedCelestial, unscannedCelestial, unscannedCelestial);
            List <StarSystem> systems            = Build.Many.StarSystems(firstSystem);

            navigator.PlanExpedition(systems);
            playerStatus.SetLocation(firstSystem.Name);

            TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand);

            sut.Handle(testEvent);

            List <StarSystem> storedSystems = navigator.GetAllExpeditionSystems();

            storedSystems.All(s => s.Scanned == false).Should().BeTrue();
            storedSystems.SelectMany(s => s.Celestials).All(s => s.Scanned == false).Should().BeTrue();

            navigator.GetNextSystem().Name.ShouldBeEquivalentTo(firstSystem.Name);

            communicator.MessagesCommunicated.Single().Should().Be(rescanSystemPhrases.SystemUnscanned.Single());
        }
Example #17
0
    private void Start()
    {
        CampagneManager.celestials.Add(this);
        ChapterUpdate();
        if (!is_static)
        {
            parent_celestial = transform.parent.GetComponent <Celestial>();
            parent_celestial.satellites.Add(this);
            OrbitalRadius    = Vector3.Distance(transform.position, ParentPosition);
            angular_velocity = Mathf.PI * 2 / Mathf.Sqrt(OrbitalRadius * OrbitalRadius * OrbitalRadius) * parent_celestial.mass;
            transform.RotateAround(ParentPosition, Vector3.Cross(Vector3.up, orbit_plane), Vector3.Angle(Vector3.up, orbit_plane));

            transform.RotateAround(ParentPosition, orbit_plane, Random.Range(0, 360));

            // Make Collider
            GameObject collider_object = new GameObject("Plane Collider");
            collider_object.transform.up = orbit_plane;
            collider_object.transform.SetParent(transform.parent);
            collider_object.transform.localPosition = Vector3.zero;

            plane_collider           = collider_object.AddComponent <BoxCollider>();
            plane_collider.size      = new Vector3(OrbitalRadius * 3, .01f, OrbitalRadius * 3);
            plane_collider.isTrigger = true;
        }
    }
        public void SkipSystem_With_System_In_Expedition_Marks_System_As_Scanned()
        {
            TestCommunicator       communicator = CreateCommunicator();
            Navigator              navigator    = CreateNavigator();
            PlayerStatusRepository playerStatus = CreatePlayerStatusRepository();
            var skipSystemPhrases     = TestPhraseBuilder.Build <SkipSystemPhrases>();
            var scansRemainingPhrases = TestPhraseBuilder.Build <ScansRemainingPhrases>();

            SkipSystemCommand sut = new SkipSystemCommand(communicator, navigator, playerStatus, skipSystemPhrases, scansRemainingPhrases);

            Celestial         celestial     = Build.A.Celestial.ThatHasNotBeenScanned();
            StarSystem        currentSystem = Build.A.StarSystem.WithCelestials(celestial, celestial, celestial);
            StarSystem        nextSystem    = Build.A.StarSystem.WithCelestials(celestial, celestial, celestial);
            List <StarSystem> systems       = Build.Many.StarSystems(currentSystem, nextSystem);

            navigator.PlanExpedition(systems);
            playerStatus.SetLocation(currentSystem.Name);

            TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand);

            sut.Handle(testEvent);

            StarSystem storedSystem = navigator.GetSystem(currentSystem.Name);

            storedSystem.Scanned.Should().BeTrue();
            storedSystem.Celestials.All(c => c.Scanned).Should().BeTrue();

            navigator.GetNextSystem().ShouldBeEquivalentTo(nextSystem);
        }
Example #19
0
        private int ValueForCelestial(Celestial celestial)
        {
            CelestialData data;

            if (_celestialValues.CelestialData.TryGetValue(celestial.Classification, out data) == false)
            {
                return(0);
            }

            if (celestial.Scanned)
            {
                if (celestial.SurfaceScanned)
                {
                    if (celestial.Efficient)
                    {
                        return(data.FSSPlusDSSEfficient);
                    }
                    else
                    {
                        return(data.FSSPlusDSS);
                    }
                }
                else
                {
                    return(data.FSS);
                }
            }
            return(0);
        }
Example #20
0
 private static int SendFleet(Celestial origin, Ships ships, Coordinate destination, Missions mission, Speeds speed, Model.Resources payload = null, bool force = false)
 {
     Helpers.WriteLog(LogType.Info, LogSender.Tbot, "Sending fleet from " + origin.Coordinate.ToString() + " to " + destination.ToString() + ". Mission: " + mission.ToString() + ". Ships: " + ships.ToString());
     UpdateSlots();
     if (slots.Free > 1 || force)
     {
         if (payload == null)
         {
             payload = new Resources {
                 Metal = 0, Crystal = 0, Deuterium = 0
             };
         }
         try
         {
             Fleet fleet = ogamedService.SendFleet(origin, ships, destination, mission, speed, payload);
             fleets = ogamedService.GetFleets();
             UpdateSlots();
             return(fleet.ID);
         }
         catch (Exception e)
         {
             Helpers.WriteLog(LogType.Error, LogSender.Defender, "Exception: " + e.Message);
             return(0);
         }
     }
     else
     {
         Helpers.WriteLog(LogType.Warning, LogSender.Tbot, "Unable to send fleet, no slots available");
         return(0);
     }
 }
Example #21
0
    public LocalMapData(string name, float[] resourceDensities, Vector3 location, Celestial orbit = null)
    {
        _name = name;
        _resourceDensities = resourceDensities;
        _location          = location;

        CacheCelestials(orbit);
    }
 public CelestialDocument(Celestial celetial)
 {
     Id            = celetial.Id;
     Name          = celetial.Name;
     System        = celetial.System;
     Clasification = celetial.Clasification;
     Scanned       = celetial.Scanned;
     Landable      = celetial.Landable;
 }
Example #23
0
        public static void Run_Test()
        {
            Coordinate tc = null;

            Console.WriteLine("Starting Benchmarks, this test may take a while to finish...");
            Console.WriteLine();
            //Benchmark Standard Object Initialization
            Benchmark(() => { tc = new Coordinate(39.891219, -74.872435, new DateTime(2018, 7, 26, 15, 49, 0)); }, 100, "Standard Initialization");

            Benchmark(() => {
                tc           = new Coordinate();
                tc.Latitude  = new CoordinatePart(39, 45, 34, CoordinatesPosition.N);
                tc.Longitude = new CoordinatePart(74, 34, 45, CoordinatesPosition.W);
                tc.GeoDate   = new DateTime(2018, 7, 26, 15, 49, 0);
            }, 100, "Secondary Initialization");

            //Benchmark TryParse Object Initialization
            Benchmark(() => { Coordinate.TryParse("39.891219, -74.872435", new DateTime(2010, 7, 26, 15, 49, 0), out tc); }, 100, "TryParse() Initialization");

            //Benchmark with EagerLoad fully off
            Benchmark(() => {
                EagerLoad eg = new EagerLoad(false);

                tc = new Coordinate(39.891219, -74.872435, new DateTime(2018, 7, 26, 15, 49, 0), eg);
            }, 100, "EagerLoad Off Initialization");
            tc = new Coordinate(39.891219, -74.872435, new DateTime(2018, 7, 26, 15, 49, 0));

            //Benchmark property change
            Random r = new Random();

            Benchmark(() => { tc.Latitude.DecimalDegree = r.Next(-90, 90); }, 100, "Property Change");

            //Benchmark Celestial Times
            Benchmark(() => { Celestial cel = new Celestial(45, 45, DateTime.Now); }, 100, "Celestial Time Calculations");
            Benchmark(() => { Celestial cel = Celestial.CalculateSunData(45, 45, DateTime.Now); }, 100, "Solar Time Calculations");
            Benchmark(() => { Celestial cel = Celestial.CalculateMoonData(45, 45, DateTime.Now); }, 100, "Lunar Time Calculations");

            //Benchmark Local Times
            Benchmark(() => { Coordinate c = new Coordinate(45, 45, DateTime.Now, new EagerLoad(false)); Celestial cel = Celestial.Celestial_LocalTime(c, -7); }, 100, "Local Celestial Times");
            Benchmark(() => { Coordinate c = new Coordinate(45, 45, DateTime.Now, new EagerLoad(false)); Celestial cel = Celestial.Solar_LocalTime(c, -7); }, 100, "Local Sun Only Times");
            Benchmark(() => { Coordinate c = new Coordinate(45, 45, DateTime.Now, new EagerLoad(false)); Celestial cel = Celestial.Lunar_LocalTime(c, -7); }, 100, "Local Moon Only Times");

            //Benchmark EagerLoadin Exentsion Times
            Benchmark(() =>
            {
                EagerLoad el  = new EagerLoad();
                el.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.Solar_Cycle);
                Coordinate c  = new Coordinate(45, 45, DateTime.Now, el);
            }, 100, "Coordinate Initialization with Solar Cycle Calculations Only.");

            Benchmark(() =>
            {
                EagerLoad el  = new EagerLoad();
                el.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.Lunar_Cycle);
                Coordinate c  = new Coordinate(45, 45, DateTime.Now, el);
            }, 100, "Coordinate Initialization with Lunar Cycle Calculations Only.");
        }
Example #24
0
    public static float GetCelestialBonus(GameObject attacker, GameObject defender)
    {
        Celestial attackerCelestial = attacker.GetComponent <Unit>().GetCelestial();
        Celestial defenderCelestial = defender.GetComponent <Unit>().GetCelestial();

        // Earth > Sun > Moon > Earth
        if (attackerCelestial == Celestial.Sun)
        {
            if (defenderCelestial == Celestial.Moon)
            {
                return(1.2f);
            }
            else if (defenderCelestial == Celestial.Earth)
            {
                return(0.8f);
            }
            else
            {
                return(1.0f);
            }
        }
        else if (attackerCelestial == Celestial.Moon)
        {
            if (defenderCelestial == Celestial.Earth)
            {
                return(1.2f);
            }
            else if (defenderCelestial == Celestial.Sun)
            {
                return(0.8f);
            }
            else
            {
                return(1.0f);
            }
        }
        else if (attackerCelestial == Celestial.Earth)
        {
            if (defenderCelestial == Celestial.Sun)
            {
                return(1.2f);
            }
            else if (defenderCelestial == Celestial.Moon)
            {
                return(0.8f);
            }
            else
            {
                return(1.0f);
            }
        }

        else
        {
            return(1);
        }
    }
        public ExtendExpeditionCommandTests()
        {
            Celestial celestial = Build.A.Celestial.ThatHasNotBeenScanned();

            _starSystems     = Build.A.StarSystem.WithCelestial(celestial).InAList();
            _userDataService = new TestUserDataService(_starSystems);
            _navigator       = CreateNavigator(new MemoryDataStore <StarSystemDocument>());
            _communicator    = CreateCommunicator();
            _sut             = new ExtendExpeditionCommand(_communicator, _navigator, _userDataService, BuildPhrases());
        }
Example #26
0
        /// <summary>
        /// Benchmarks lunar cycle calculations.
        /// </summary>
        public static void Lunar_Cycle_Calculations(OutputOption opt)
        {
            EagerLoad  el = new EagerLoad();
            Coordinate c  = new Coordinate(45, 45, DateTime.Now, el);

            el.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.Lunar_Cycle);
            Benchmark(() => {
                Celestial cel = c.Celestial_LocalTime(-7);
            }, 100, "Local Lunar Cycle Only Times From Coordinate", opt);
        }
Example #27
0
        /// <summary>
        /// Benchmarks all celestial calculations occurring in local time.
        /// </summary>
        public static void Celestial_Calculations_Local_Time_From_Coordinate(OutputOption opt)
        {
            EagerLoad  el = new EagerLoad();
            Coordinate c  = new Coordinate(45, 45, DateTime.Now, el);

            //Benchmark Local Times
            Benchmark(() => {
                Celestial cel = c.Celestial_LocalTime(-7);
            }, 100, "Local Celestial Times From Coordinate", opt);
        }
Example #28
0
 public void Declination_Should_Return_Correct_Results()
 {
     Celestial.Declination(31.3101877453024).Should().BeCloseTo(12.2026059914001, MathHelper.Epsilon);
     Celestial.Declination(42.2597957259723).Should().BeCloseTo(15.8742931864835, MathHelper.Epsilon);
     Celestial.Declination(59.2349729472294).Should().BeCloseTo(20.4565845497204, MathHelper.Epsilon);
     Celestial.Declination(62.5975972349908).Should().BeCloseTo(21.1677169773821, MathHelper.Epsilon);
     Celestial.Declination(80.4818781723799).Should().BeCloseTo(23.6492922420057, MathHelper.Epsilon);
     Celestial.Declination(121.1497130809087).Should().BeCloseTo(20.3707052985127, MathHelper.Epsilon);
     Celestial.Declination(320.8687779979979).Should().BeCloseTo(-14.8738036439391, MathHelper.Epsilon);
 }
Example #29
0
        public void ValueForSystem_Uses_EfficiencyMultiplier()
        {
            Navigator sut = CreateSut();
            Celestial efficientCelestial = Build.A.Celestial.WithClassification(_Classification).ThatHasBeenTotallyScanned().Efficiently();

            List <StarSystem> starSystems = Build.A.StarSystem.WithCelestial(efficientCelestial).InAList();

            sut.PlanExpedition(starSystems);
            sut.ValueForSystem(starSystems.First().Name).Should().Be(_DSSEfficientValue);
        }
Example #30
0
        public JumpCommandTests()
        {
            Celestial celestial  = Build.A.Celestial.ThatHasNotBeenScanned();
            Celestial celestial2 = Build.A.Celestial.ThatHasNotBeenScanned();

            _starSystems     = Build.A.StarSystem.WithCelestials(celestial, celestial, celestial2).InAList();
            _userDataService = new TestUserDataService(_starSystems);
            _navigator       = CreateNavigator(new MemoryDataStore <StarSystemDocument>());
            _communicator    = CreateCommunicator();
        }
 public static int DistanceSort(Celestial first, Celestial second)
 {
     return first.distance.CompareTo(second.distance);
 }
 public static int AlphabeticSort(Celestial first, Celestial second)
 {
     return string.Compare(first.name, second.name, StringComparison.Ordinal);
 }