Beispiel #1
0
        private static void SimulateMorrigiRelics(
            Random rand,
            GameSession game,
            int systemId,
            FleetInfo randomsFleet,
            int aiPlayerID,
            List <FleetInfo> aiPlayerFleets)
        {
            int numToKill = rand.NextInclusive(5, 6);
            Dictionary <FleetInfo, List <ShipInfo> > shipsInFleets = CombatSimulatorRandoms.GetShipsInFleets(game, aiPlayerFleets);

            if (shipsInFleets.Sum <KeyValuePair <FleetInfo, List <ShipInfo> > >((Func <KeyValuePair <FleetInfo, List <ShipInfo> >, int>)(x => x.Value.Count)) == 0)
            {
                return;
            }
            CombatSimulatorRandoms.UpdateShipsKilled(game, rand, shipsInFleets, randomsFleet.PlayerID, numToKill);
            MorrigiRelicInfo relicInfo = game.GameDatabase.GetMorrigiRelicInfos().ToList <MorrigiRelicInfo>().FirstOrDefault <MorrigiRelicInfo>((Func <MorrigiRelicInfo, bool>)(x => x.FleetId == randomsFleet.ID));

            if (relicInfo != null && relicInfo.IsAggressive)
            {
                List <ShipInfo> list = game.GameDatabase.GetShipInfoByFleetID(randomsFleet.ID, false).ToList <ShipInfo>();
                game.ScriptModules.MorrigiRelic.ApplyRewardsToPlayers(game.App, relicInfo, list, new List <Player>()
                {
                    game.GetPlayerObject(aiPlayerID)
                });
            }
            else
            {
                CombatSimulatorRandoms.FleetDestroyed(game, aiPlayerID, randomsFleet, (ShipInfo)null);
                game.GameDatabase.RemoveFleet(randomsFleet.ID);
            }
        }
Beispiel #2
0
        private static void SimulateAsteroidMonitors(
            Random rand,
            GameSession game,
            int systemId,
            FleetInfo randomsFleet,
            int aiPlayerID,
            List <FleetInfo> aiPlayerFleets)
        {
            int numToKill = rand.NextInclusive(1, 3);
            Dictionary <FleetInfo, List <ShipInfo> > shipsInFleets = CombatSimulatorRandoms.GetShipsInFleets(game, aiPlayerFleets);

            if (shipsInFleets.Sum <KeyValuePair <FleetInfo, List <ShipInfo> > >((Func <KeyValuePair <FleetInfo, List <ShipInfo> >, int>)(x => x.Value.Count)) == 0)
            {
                return;
            }
            CombatSimulatorRandoms.UpdateShipsKilled(game, rand, shipsInFleets, randomsFleet.PlayerID, numToKill);
            int      encounterIdAtSystem = game.GameDatabase.GetEncounterIDAtSystem(EasterEgg.EE_ASTEROID_MONITOR, systemId);
            ShipInfo shipInfo            = game.GameDatabase.GetShipInfoByFleetID(randomsFleet.ID, false).ToList <ShipInfo>().FirstOrDefault <ShipInfo>((Func <ShipInfo, bool>)(x => x.DesignID == game.ScriptModules.AsteroidMonitor.MonitorCommandDesignId));

            if (shipInfo != null)
            {
                AsteroidMonitorInfo asteroidMonitorInfo = game.GameDatabase.GetAsteroidMonitorInfo(encounterIdAtSystem);
                if (asteroidMonitorInfo != null)
                {
                    asteroidMonitorInfo.IsAggressive = false;
                    game.GameDatabase.UpdateAsteroidMonitorInfo(asteroidMonitorInfo);
                }
                shipInfo.DesignInfo = game.GameDatabase.GetDesignInfo(shipInfo.DesignID);
                List <DesignModuleInfo> source = new List <DesignModuleInfo>();
                foreach (DesignSectionInfo designSection in shipInfo.DesignInfo.DesignSections)
                {
                    source.AddRange((IEnumerable <DesignModuleInfo>)designSection.Modules.ToList <DesignModuleInfo>());
                }
                if (source.Any <DesignModuleInfo>())
                {
                    foreach (SectionInstanceInfo sectionInstanceInfo in game.GameDatabase.GetShipSectionInstances(shipInfo.ID).ToList <SectionInstanceInfo>())
                    {
                        foreach (ModuleInstanceInfo module in game.GameDatabase.GetModuleInstances(sectionInstanceInfo.ID).ToList <ModuleInstanceInfo>())
                        {
                            module.Structure = 0;
                            game.GameDatabase.UpdateModuleInstance(module);
                        }
                    }
                    game.InsertNewMonitorSpecialProject(aiPlayerID, encounterIdAtSystem, randomsFleet.ID);
                }
                else
                {
                    game.GameDatabase.RemoveFleet(randomsFleet.ID);
                    game.GameDatabase.RemoveEncounter(encounterIdAtSystem);
                }
            }
            else
            {
                game.GameDatabase.RemoveFleet(randomsFleet.ID);
                game.GameDatabase.RemoveEncounter(encounterIdAtSystem);
            }
        }
Beispiel #3
0
        private static void SimulateSwarmerNest(
            Random rand,
            GameSession game,
            int systemId,
            FleetInfo randomsFleet,
            int aiPlayerID,
            List <FleetInfo> aiPlayerFleets)
        {
            int numToKill = rand.NextInclusive(2, 4);
            Dictionary <FleetInfo, List <ShipInfo> > shipsInFleets = CombatSimulatorRandoms.GetShipsInFleets(game, aiPlayerFleets);

            shipsInFleets.Sum <KeyValuePair <FleetInfo, List <ShipInfo> > >((Func <KeyValuePair <FleetInfo, List <ShipInfo> >, int>)(x => x.Value.Count));
            if (shipsInFleets.Sum <KeyValuePair <FleetInfo, List <ShipInfo> > >((Func <KeyValuePair <FleetInfo, List <ShipInfo> >, int>)(x =>
            {
                if (x.Value.Count <= 0)
                {
                    return(0);
                }
                return(x.Value.Sum <ShipInfo>((Func <ShipInfo, int>)(y =>
                {
                    if (y.DesignInfo == null)
                    {
                        return 0;
                    }
                    return CombatAI.GetShipStrength(y.DesignInfo.Class) / 3;
                })));
            })) <= 2)
            {
                foreach (KeyValuePair <FleetInfo, List <ShipInfo> > keyValuePair in shipsInFleets)
                {
                    foreach (ShipInfo shipInfo in keyValuePair.Value)
                    {
                        game.GameDatabase.RemoveShip(shipInfo.ID);
                    }
                    CombatSimulatorRandoms.FleetDestroyed(game, randomsFleet.PlayerID, keyValuePair.Key, (ShipInfo)null);
                    game.GameDatabase.RemoveFleet(keyValuePair.Key.ID);
                }
                if (game.GameDatabase.GetShipInfoByFleetID(randomsFleet.ID, false).ToList <ShipInfo>().Count != 0)
                {
                    return;
                }
                game.GameDatabase.RemoveFleet(randomsFleet.ID);
            }
            else
            {
                CombatSimulatorRandoms.UpdateShipsKilled(game, rand, shipsInFleets, randomsFleet.PlayerID, numToKill);
                List <ShipInfo> list = game.GameDatabase.GetShipInfoByFleetID(randomsFleet.ID, false).ToList <ShipInfo>();
                if (list.Count > 0)
                {
                    CombatSimulatorRandoms.FleetDestroyed(game, aiPlayerID, randomsFleet, list.First <ShipInfo>());
                }
                game.GameDatabase.RemoveFleet(randomsFleet.ID);
            }
        }
Beispiel #4
0
        private static void SimulateProteans(
            Random rand,
            GameSession game,
            int systemId,
            FleetInfo randomsFleet,
            int aiPlayerID,
            List <FleetInfo> aiPlayerFleets)
        {
            int numToKill = rand.NextInclusive(3, 5);
            Dictionary <FleetInfo, List <ShipInfo> > shipsInFleets = CombatSimulatorRandoms.GetShipsInFleets(game, aiPlayerFleets);

            if (shipsInFleets.Sum <KeyValuePair <FleetInfo, List <ShipInfo> > >((Func <KeyValuePair <FleetInfo, List <ShipInfo> >, int>)(x => x.Value.Count)) == 0)
            {
                return;
            }
            CombatSimulatorRandoms.UpdateShipsKilled(game, rand, shipsInFleets, randomsFleet.PlayerID, numToKill);
            CombatSimulatorRandoms.FleetDestroyed(game, aiPlayerID, randomsFleet, (ShipInfo)null);
            game.GameDatabase.RemoveFleet(randomsFleet.ID);
        }
Beispiel #5
0
        private static void SimulatePirateBase(
            Random rand,
            GameSession game,
            int systemId,
            FleetInfo randomsFleet,
            int aiPlayerID,
            List <FleetInfo> aiPlayerFleets)
        {
            int numToKill = rand.NextInclusive(5, 6);
            Dictionary <FleetInfo, List <ShipInfo> > shipsInFleets = CombatSimulatorRandoms.GetShipsInFleets(game, aiPlayerFleets);
            int num1 = shipsInFleets.Sum <KeyValuePair <FleetInfo, List <ShipInfo> > >((Func <KeyValuePair <FleetInfo, List <ShipInfo> >, int>)(x => x.Value.Count));

            if (num1 == 0)
            {
                return;
            }
            PirateBaseInfo pirateBaseInfo = game.GameDatabase.GetPirateBaseInfos().FirstOrDefault <PirateBaseInfo>((Func <PirateBaseInfo, bool>)(x => x.SystemId == systemId));

            if (pirateBaseInfo == null)
            {
                return;
            }
            CombatSimulatorRandoms.UpdateShipsKilled(game, rand, shipsInFleets, randomsFleet.PlayerID, numToKill);
            if (num1 < numToKill)
            {
                return;
            }
            int bounty            = game.AssetDatabase.GlobalPiracyData.Bounties[0];
            List <FleetInfo> list = game.GameDatabase.GetFleetsByPlayerAndSystem(randomsFleet.PlayerID, systemId, FleetType.FL_NORMAL).ToList <FleetInfo>();
            int maxValue          = 0;

            foreach (FleetInfo fleetInfo in list)
            {
                maxValue = game.GameDatabase.GetShipInfoByFleetID(fleetInfo.ID, true).Count <ShipInfo>((Func <ShipInfo, bool>)(x => x.DesignInfo.Class != ShipClass.Station));
            }
            if (maxValue > 0)
            {
                int num2 = rand.NextInclusive(0, maxValue);
                int num3 = bounty + num2 * game.AssetDatabase.GlobalPiracyData.Bounties[1];
            }
            foreach (int num2 in game.GameDatabase.GetStandardPlayerIDs().ToList <int>())
            {
                if (num2 != aiPlayerID)
                {
                    string factionName    = game.GameDatabase.GetFactionName(game.GameDatabase.GetPlayerFactionID(num2));
                    int    reactionAmount = 0;
                    game.AssetDatabase.GlobalPiracyData.ReactionBonuses.TryGetValue(factionName, out reactionAmount);
                    game.GameDatabase.ApplyDiplomacyReaction(num2, aiPlayerID, reactionAmount, new StratModifiers?(StratModifiers.DiplomacyReactionElimPirates), 1);
                }
            }
            game.GameDatabase.InsertTurnEvent(new TurnEvent()
            {
                EventType    = TurnEventType.EV_PIRATE_BASE_DESTROYED,
                EventMessage = TurnEventMessage.EM_PIRATE_BASE_DESTROYED,
                PlayerID     = aiPlayerID,
                SystemID     = systemId,
                TurnNumber   = game.GameDatabase.GetTurnCount(),
                ShowsDialog  = false
            });
            game.GameDatabase.DestroyStation(game, pirateBaseInfo.BaseStationId, 0);
        }