예제 #1
0
        private void _handleBountyAwardedEvent(BountyAwardedEvent @event, bool test = false)
        {
            // 20% bonus for Arissa Lavigny-Duval 'controlled' and 'exploited' systems
            StarSystem currentSystem = EDDI.Instance?.CurrentStarSystem;

            if (currentSystem != null)
            {
                currentSystem = LegacyEddpService.SetLegacyData(currentSystem, true, false, false);
            }

            // Default to 1.0 for unit testing
            double bonus = (!test && currentSystem?.Power == Power.FromEDName("ALavignyDuval")) ? 1.2 : 1.0;

            // Get the victim faction data
            Faction faction = bgsService.GetFactionByName(@event.faction);

            foreach (Reward reward in @event.rewards.ToList())
            {
                int           shipId = EDDI.Instance?.CurrentShip?.LocalId ?? 0;
                long          amount = Convert.ToInt64(reward.amount * bonus);
                FactionReport report = new FactionReport(@event.timestamp, true, shipId, Crime.None, currentSystem?.systemname, amount)
                {
                    station          = EDDI.Instance?.CurrentStation?.name,
                    body             = EDDI.Instance?.CurrentStellarBody?.bodyname,
                    victim           = @event.faction,
                    victimAllegiance = (faction.Allegiance ?? Superpower.None).invariantName
                };

                FactionRecord record = GetRecordWithFaction(reward.faction)
                                       ?? AddRecord(reward.faction);
                record.factionReports.Add(report);
                record.claims += amount;
            }
        }
예제 #2
0
        public void TestNullLegacy()
        {
            StarSystem starSystem = LegacyEddpService.SetLegacyData(new StarSystem()
            {
                systemname = "No such system"
            });

            Assert.IsNotNull(starSystem);
            Assert.AreEqual("No such system", starSystem.systemname);
        }
예제 #3
0
        public void TestLegacyData()
        {
            /// Test legacy data from api.eddp.co
            StarSystem system = DeserializeJsonResource <StarSystem>(Resources.sqlStarSystem1);

            Assert.AreEqual("Nijland Terminal", system.stations[0].name);
            Assert.IsNull(system.stations[0].EDDBID);
            Assert.AreEqual("Pinzon Hub", system.stations[1].name);
            Assert.IsNull(system.stations[1].EDDBID);

            system = LegacyEddpService.SetLegacyData(system);
            Assert.AreEqual(32548, system.stations[0].EDDBID);
            Assert.AreEqual(58341, system.stations[1].EDDBID);
        }
예제 #4
0
        public void TestLegacyData()
        {
            /// Test legacy data from api.eddp.co

            string legagySystemSql = System.IO.File.ReadAllText("sqlStarSystem1.json");

            StarSystem system = JsonConvert.DeserializeObject <StarSystem>(legagySystemSql);

            Assert.AreEqual("Nijland Terminal", system.stations[0].name);
            Assert.IsNull(system.stations[0].EDDBID);
            Assert.AreEqual("Pinzon Hub", system.stations[1].name);
            Assert.IsNull(system.stations[1].EDDBID);

            system = LegacyEddpService.SetLegacyData(system);
            Assert.AreEqual(32548, system.stations[0].EDDBID);
            Assert.AreEqual(58341, system.stations[1].EDDBID);
        }