Esempio n. 1
0
        /*
         * Not feeling too spectaculary well today, want to get this started though.
         * Will have to come back and do a lot of fixing at a guess. 03-24-2021
         */

        /******************************************************************************
        * Made a method for this as it was sidelining me a bit.
        *
        * Finds the next most valuable system/target to attack
        * It is part of the old combat code that is buried in resources.
        * Yet it is pretty important.
        *
        ******************************************************************************/
        internal void FindMostValubleTarget(SystemStatus system, DeathListTracker deathListTracker)
        {
            //contracts--code-------
            var factionRep   = Globals.Sim.GetRawReputation(Globals.FactionValues.Find(x => x.Name == warFaction.faction));
            var maxContracts = HotSpots.ProcessReputation(factionRep);
            //end------contracts---code-----

            //Hatred--------------------------this could almost just be a segment on it's own
            var hatred           = deathListTracker.deathList[system.owner];
            var targetWarFaction = Globals.WarStatusTracker.warFactionTracker.Find(x => x.faction == system.owner);

            //Continue from here have to go out.

            //Find most valuable target for attacking for later. Used in HotSpots.----------------------
            if (hatred >= Globals.Settings.PriorityHatred &&
                system.DifficultyRating <= maxContracts &&
                system.DifficultyRating >= maxContracts - 4)
            {
                system.PriorityAttack = true;                                 //another item i'm not so sure on, have to dig some to find out.

                if (!system.CurrentlyAttackedBy.Contains(warFaction.faction)) //does a check to see if the opposing system is currently beiing attacked
                {                                                             //by this faction
                    system.CurrentlyAttackedBy.Add(warFaction.faction);
                }

                if (!Globals.WarStatusTracker.PrioritySystems.Contains(system.starSystem.Name))
                {
                    Globals.WarStatusTracker.PrioritySystems.Add(system.starSystem.Name);
                }
            }
            //end hatred--------------------------------------------------------------------------------
        }
Esempio n. 2
0
        public WarStatus()
        {
            Logger.LogDebug("WarStatus ctor");
            if (Globals.Settings.ISMCompatibility)
            {
                Globals.Settings.IncludedFactions = new List <string>(Globals.Settings.IncludedFactions_ISM);
            }

            CurSystem        = Globals.Sim.CurSystem.Name;
            TempPRGain       = 0;
            HotBoxTravelling = false;
            HotBox           = new List <string>();
            if (Globals.Settings.HyadesRimCompatible)
            {
                InactiveTHRFactions = Globals.Settings.HyadesAppearingPirates;
                FlashpointSystems   = Globals.Settings.HyadesFlashpointSystems;
                NeverControl        = Globals.Settings.HyadesNeverControl;
            }

            //initialize all WarFactions, DeathListTrackers, and SystemStatuses
            foreach (var faction in Globals.Settings.IncludedFactions)
            {
                var warFaction = new WarFaction(faction);
                var d          = new DeathListTracker(faction)
                {
                    WarFaction = warFaction
                };
                warFaction.DeathListTracker = d;
                warFactionTracker.Add(warFaction);
                deathListTracker.Add(d);
            }

            foreach (var system in Globals.GaWSystems)
            {
                if (system.OwnerValue.Name == "NoFaction" || system.OwnerValue.Name == "AuriganPirates")
                {
                    AbandonedSystems.Add(system.Name);
                }
                var warFaction = warFactionTracker.Find(x => x.faction == system.OwnerValue.Name);
                if (Globals.Settings.DefensiveFactions.Contains(warFaction.faction) && Globals.Settings.DefendersUseARforDR)
                {
                    warFaction.DefensiveResources += GetTotalAttackResources(system);
                }
                else
                {
                    warFaction.AttackResources += GetTotalAttackResources(system);
                }
                warFaction.DefensiveResources += GetTotalDefensiveResources(system);
            }

            Logger.LogDebug("WarFaction AR/DR set.");
            var maxAR = warFactionTracker.Select(x => x.AttackResources).Max();
            var maxDR = warFactionTracker.Select(x => x.DefensiveResources).Max();

            foreach (var faction in Globals.Settings.IncludedFactions)
            {
                var warFaction = warFactionTracker.Find(x => x.faction == faction);
                if (Globals.Settings.DefensiveFactions.Contains(faction) && Globals.Settings.DefendersUseARforDR)
                {
                    if (!Globals.Settings.ISMCompatibility)
                    {
                        warFaction.DefensiveResources = maxAR + maxDR + Globals.Settings.BonusAttackResources[faction] +
                                                        Globals.Settings.BonusDefensiveResources[faction];
                    }
                    else
                    {
                        warFaction.DefensiveResources = maxAR + maxDR + Globals.Settings.BonusAttackResources_ISM[faction] +
                                                        Globals.Settings.BonusDefensiveResources_ISM[faction];
                    }

                    warFaction.AttackResources = 0;
                }
                else
                {
                    if (!Globals.Settings.ISMCompatibility)
                    {
                        warFaction.AttackResources    = maxAR + Globals.Settings.BonusAttackResources[faction];
                        warFaction.DefensiveResources = maxDR + Globals.Settings.BonusDefensiveResources[faction];
                    }
                    else
                    {
                        warFaction.AttackResources    = maxAR + Globals.Settings.BonusAttackResources_ISM[faction];
                        warFaction.DefensiveResources = maxDR + Globals.Settings.BonusDefensiveResources_ISM[faction];
                    }
                }
            }

            Logger.LogDebug("WarFaction bonus AR/DR set.");
            if (!Globals.Settings.ISMCompatibility)
            {
                PirateResources = maxAR * Globals.Settings.FractionPirateResources + Globals.Settings.BonusPirateResources;
            }
            else
            {
                PirateResources = maxAR * Globals.Settings.FractionPirateResources_ISM + Globals.Settings.BonusPirateResources_ISM;
            }

            MinimumPirateResources  = PirateResources;
            StartingPirateResources = PirateResources;
            Logger.LogDebug("SystemStatus mass creation...");
            systems = new List <SystemStatus>(Globals.GaWSystems.Count);
            for (var index = 0; index < Globals.Sim.StarSystems.Count; index++)
            {
                var system = Globals.Sim.StarSystems[index];
                if (Globals.Settings.ImmuneToWar.Contains(system.OwnerValue.Name))
                {
                    continue;
                }

                var systemStatus = new SystemStatus(system, system.OwnerValue.Name);
                systems.Add(systemStatus);
                if (system.Tags.Contains("planet_other_pirate") && !system.Tags.Contains("planet_region_hyadesrim"))
                {
                    FullPirateSystems.Add(system.Name);
                    PiratesAndLocals.FullPirateListSystems.Add(systemStatus);
                }

                if (system.Tags.Contains("planet_region_hyadesrim") && !FlashpointSystems.Contains(system.Name) &&
                    (system.OwnerValue.Name == "NoFaction" || system.OwnerValue.Name == "Locals"))
                {
                    HyadesRimGeneralPirateSystems.Add(system.Name);
                }
            }

            Logger.LogDebug("Full pirate systems created.");
            systems            = systems.OrderBy(x => x.name).ToList();
            systemsByResources = systems.OrderBy(x => x.TotalResources).ToList();
            PrioritySystems    = new List <string>(systems.Count);
            Logger.LogDebug("SystemStatus ordered lists created.");
        }
Esempio n. 3
0
        public WarStatus()
        {
            Logger.LogDebug("WarStatus ctor");
            if (Globals.Settings.ISMCompatibility)
            {
                Globals.Settings.IncludedFactions = new List <string>(Globals.Settings.IncludedFactions_ISM);
            }

            CurSystem        = Globals.Sim.CurSystem.Name;
            TempPRGain       = 0;
            HotBoxTravelling = false;
            HotBox           = new List <string>();
            if (Globals.Settings.HyadesRimCompatible)
            {
                InactiveTHRFactions = Globals.Settings.HyadesAppearingPirates;
                FlashpointSystems   = Globals.Settings.HyadesFlashpointSystems;
                NeverControl        = Globals.Settings.HyadesNeverControl;
            }

            //initialize all WarFactions, DeathListTrackers, and SystemStatuses
            foreach (var faction in Globals.Settings.IncludedFactions)
            {
                var warFaction = new WarFaction(faction);
                var d          = new DeathListTracker(faction)
                {
                    WarFaction = warFaction
                };
                warFaction.DeathListTracker = d;
                warFactionTracker.Add(warFaction);
                deathListTracker.Add(d);
            }

            foreach (var system in Globals.GaWSystems)
            {
                if (system.OwnerValue.Name == "NoFaction" || system.OwnerValue.Name == "AuriganPirates")
                {
                    AbandonedSystems.Add(system.Name);
                }
                var warFaction = warFactionTracker.Find(x => x.faction == system.OwnerValue.Name);

                /*if (Globals.Settings.DefensiveFactions.Contains(warFaction.faction) && Globals.Settings.DefendersUseARforDR)
                 *  warFaction.DefensiveResources += GetTotalAttackResources(system);
                 * else*/
                warFaction.AttackResources    += GetTotalAttackResources(system);
                warFaction.DefensiveResources += GetTotalDefensiveResources(system);
            }

            Logger.LogDebug("WarFaction AR/DR set.");

            /*var maxAR = warFactionTracker.Select(x => x.AttackResources).Max();
             * var maxDR = warFactionTracker.Select(x => x.DefensiveResources).Max();
             *
             * foreach (var faction in Globals.Settings.IncludedFactions)
             * {
             *  var warFaction = warFactionTracker.Find(x => x.faction == faction);
             *  if (Globals.Settings.DefensiveFactions.Contains(faction) && Globals.Settings.DefendersUseARforDR)
             *  {
             *      if (!Globals.Settings.ISMCompatibility)
             *          warFaction.DefensiveResources = maxAR + maxDR + Globals.Settings.BonusAttackResources[faction] +
             *                                          Globals.Settings.BonusDefensiveResources[faction];
             *      else
             *          warFaction.DefensiveResources = maxAR + maxDR + Globals.Settings.BonusAttackResources_ISM[faction] +
             *                                          Globals.Settings.BonusDefensiveResources_ISM[faction];
             *
             *      warFaction.AttackResources = 0;
             *  }
             *  else
             *  {
             *      if (!Globals.Settings.ISMCompatibility)
             *      {
             *          warFaction.AttackResources = maxAR + Globals.Settings.BonusAttackResources[faction];
             *          warFaction.DefensiveResources = maxDR + Globals.Settings.BonusDefensiveResources[faction];
             *      }
             *      else
             *      {
             *          warFaction.AttackResources = maxAR + Globals.Settings.BonusAttackResources_ISM[faction];
             *          warFaction.DefensiveResources = maxDR + Globals.Settings.BonusDefensiveResources_ISM[faction];
             *      }
             *  }
             * }*/

            Logger.LogDebug("WarFaction bonus AR/DR set.");

            /*if (!Globals.Settings.ISMCompatibility)
             *  PirateResources = maxAR * Globals.Settings.FractionPirateResources + Globals.Settings.BonusPirateResources;
             * else
             *  PirateResources = maxAR * Globals.Settings.FractionPirateResources_ISM + Globals.Settings.BonusPirateResources_ISM;
             *
             * MinimumPirateResources = PirateResources;
             * StartingPirateResources = PirateResources;*/
            Logger.LogDebug("SystemStatus mass creation...");
            systems = new List <SystemStatus>(Globals.GaWSystems.Count);
            for (var index = 0; index < Globals.Sim.StarSystems.Count; index++)
            {
                var system = Globals.Sim.StarSystems[index];
                if (Globals.Settings.ImmuneToWar.Contains(system.OwnerValue.Name))
                {
                    continue;
                }

                SystemStatus systemStatus = new SystemStatus(system, system.OwnerValue.Name);

                //--new-block------------------------
                systemStatus.absPosX = Math.Abs(0 - system.Position.x);
                systemStatus.absPosY = Math.Abs(0 - system.Position.y);
                systemStatus.systemsDistanceFromZero = (float)Math.Sqrt((systemStatus.absPosX * systemStatus.absPosX) + (systemStatus.absPosY * systemStatus.absPosY));
                systems.Add(systemStatus);

                foreach (SystemStatus curSystem in systems)
                {
                    curSystem.InitializeContracts();
                }
                //---end-new-block-------------------

                if (system.Tags.Contains("planet_other_pirate") && !system.Tags.Contains("planet_region_hyadesrim"))
                {
                    FullPirateSystems.Add(system.Name);
                    PiratesAndLocals.FullPirateListSystems.Add(systemStatus);
                }

                if (system.Tags.Contains("planet_region_hyadesrim") && !FlashpointSystems.Contains(system.Name) &&
                    (system.OwnerValue.Name == "NoFaction" || system.OwnerValue.Name == "Locals"))
                {
                    HyadesRimGeneralPirateSystems.Add(system.Name);
                }
            }

            Logger.LogDebug("Full pirate systems created.");
            systems            = systems.OrderBy(x => x.name).ToList();
            systemsByResources = systems.OrderBy(x => x.systemResources.TotalResources).ToList();
            PrioritySystems    = new List <string>(systems.Count);

            /*
             * an attempt at sorting the systems in a way that is good for resource distrobution.
             * Sort by faction, then by systems distance from 0 (zero), decending.
             */
            systems.Sort((f1, f2) =>
            {
                int result = string.Compare(f1.owner, f2.owner, StringComparison.Ordinal);
                return(result == 0 ? f2.systemsDistanceFromZero.CompareTo(f1.systemsDistanceFromZero) : result);
            });

            Logger.LogDebug("SystemStatus ordered lists created.");
        }