Пример #1
0
        public override void Generate()
        {
            _hulks = new List <StarshipHulk>();
            int randValue = Globals.RollD100();

            if (randValue <= 15)
            {
                bool dominantSpeciesMinority; // Identifies which side this system's dominant species (if any) would be on
                if (Globals.RollD10() <= 5)
                {
                    _fleetComposition       = "Crushed Defence Force";
                    dominantSpeciesMinority = false;
                }
                else
                {
                    _fleetComposition       = "Routed Invasion";
                    dominantSpeciesMinority = true;
                }

                int numShipsTotal    = Globals.RollD5(2);
                int numMinorityShips = Globals.RollD5() - 3;
                if (numMinorityShips < 0)
                {
                    numMinorityShips = 0;
                }
                int     numMajorityShips = numShipsTotal - numMinorityShips;
                Species majoritySpecies  = StarshipTools.GetRandomSpecies();
                if (!dominantSpeciesMinority && Globals.RollD10() <= 6)
                {
                    Species tempSpecies = ConvertXenosRuinsSpeciesToSpecies(_systemCreationRules.DominantRuinedSpecies);
                    if (tempSpecies != Species.None)
                    {
                        majoritySpecies = tempSpecies;
                    }
                }
                if (!dominantSpeciesMinority && _systemCreationRules.DominantRuinedSpecies == XenosRuinsSpecies.Undefined && Globals.RollD10() <= 7)
                {
                    XenosRuinsSpecies tempSpecies = ConvertSpeciesToXenosRuinsSpecies(majoritySpecies);
                    if (tempSpecies != XenosRuinsSpecies.Undefined)
                    {
                        _systemCreationRules.DominantRuinedSpecies = tempSpecies;
                    }
                }
                Species minoritySpecies;
                do
                {
                    minoritySpecies = StarshipTools.GetRandomSpecies();
                    if (dominantSpeciesMinority && Globals.RollD10() <= 6)
                    {
                        Species tempSpecies = ConvertXenosRuinsSpeciesToSpecies(_systemCreationRules.DominantRuinedSpecies);
                        if (tempSpecies != Species.None)
                        {
                            minoritySpecies = tempSpecies;
                        }
                    }
                    if (dominantSpeciesMinority && _systemCreationRules.DominantRuinedSpecies == XenosRuinsSpecies.Undefined && Globals.RollD10() <= 7)
                    {
                        XenosRuinsSpecies tempSpecies = ConvertSpeciesToXenosRuinsSpecies(minoritySpecies);
                        if (tempSpecies != XenosRuinsSpecies.Undefined)
                        {
                            _systemCreationRules.DominantRuinedSpecies = tempSpecies;
                        }
                    }
                } while (minoritySpecies == majoritySpecies);

                // Limit Kroot and Stryxis ships
                if (majoritySpecies == Species.Kroot || majoritySpecies == Species.Stryxis)
                {
                    numMajorityShips /= 5;
                    if (numMajorityShips < 1)
                    {
                        numMajorityShips = 1;
                    }
                }
                if (minoritySpecies == Species.Kroot || minoritySpecies == Species.Stryxis)
                {
                    numMinorityShips /= 5;
                }
                for (int i = 0; i < numMajorityShips; i++)
                {
                    _hulks.Add(GenerateHulk(0, majoritySpecies));
                }
                for (int i = 0; i < numMinorityShips; i++)
                {
                    _hulks.Add(GenerateHulk(0, minoritySpecies));
                }
                GenerateResources(majoritySpecies, minoritySpecies);
            }
            else if (randValue <= 20)
            {
                _fleetComposition = "Fleet Engagement";
                int     numShipsTotal    = Globals.RollD10() + 6;
                int     numMinorityShips = numShipsTotal / 2;
                int     numMajorityShips = numShipsTotal - numMinorityShips;
                Species majoritySpecies  = StarshipTools.GetRandomSpecies();
                if (_systemCreationRules.DominantRuinedSpecies != XenosRuinsSpecies.Undefined && Globals.RollD10() <= 6)
                {
                    Species tempSpecies = ConvertXenosRuinsSpeciesToSpecies(_systemCreationRules.DominantRuinedSpecies);
                    if (tempSpecies != Species.None)
                    {
                        majoritySpecies = tempSpecies;
                    }
                }
                if (_systemCreationRules.DominantRuinedSpecies == XenosRuinsSpecies.Undefined && Globals.RollD10() <= 7)
                {
                    XenosRuinsSpecies tempSpecies = ConvertSpeciesToXenosRuinsSpecies(majoritySpecies);
                    if (tempSpecies != XenosRuinsSpecies.Undefined)
                    {
                        _systemCreationRules.DominantRuinedSpecies = tempSpecies;
                    }
                }
                Species minoritySpecies;
                do
                {
                    minoritySpecies = StarshipTools.GetRandomSpecies();
                } while (minoritySpecies == majoritySpecies);

                // Limit Kroot and Stryxis ships
                if (majoritySpecies == Species.Kroot || majoritySpecies == Species.Stryxis)
                {
                    numMajorityShips /= 5;
                    if (numMajorityShips < 1)
                    {
                        numMajorityShips = 1;
                    }
                }
                if (minoritySpecies == Species.Kroot || minoritySpecies == Species.Stryxis)
                {
                    numMinorityShips /= 5;
                    if (numMinorityShips < 1)
                    {
                        numMinorityShips = 1;
                    }
                }
                for (int i = 0; i < numMajorityShips; i++)
                {
                    _hulks.Add(GenerateHulk(2, majoritySpecies));
                }
                for (int i = 0; i < numMinorityShips; i++)
                {
                    _hulks.Add(GenerateHulk(2, minoritySpecies));
                }
                GenerateResources(majoritySpecies, minoritySpecies);
            }
            else if (randValue <= 35)
            {
                _fleetComposition = "Lost Explorers";
                int     numShipsTotal   = Globals.Rand.Next(1, 7);
                Species majoritySpecies = StarshipTools.GetRandomSpecies();

                // Limit Kroot and Stryxis ships
                if (majoritySpecies == Species.Kroot || majoritySpecies == Species.Stryxis)
                {
                    numShipsTotal /= 5;
                    if (numShipsTotal < 1)
                    {
                        numShipsTotal = 1;
                    }
                }
                for (int i = 0; i < numShipsTotal; i++)
                {
                    _hulks.Add(GenerateHulk(8, majoritySpecies));
                }
                GenerateResources(majoritySpecies, Species.None);
            }
            else if (randValue <= 65)
            {
                _fleetComposition = "Plundered Convoy";
                int     numShipsTotal   = Globals.RollD5() + 2;
                Species majoritySpecies = StarshipTools.GetRandomSpecies();

                // Limit Kroot and Stryxis ships
                if (majoritySpecies == Species.Kroot || majoritySpecies == Species.Stryxis)
                {
                    numShipsTotal /= 5;
                    if (numShipsTotal < 1)
                    {
                        numShipsTotal = 1;
                    }
                }
                for (int i = 0; i < numShipsTotal; i++)
                {
                    _hulks.Add(GenerateHulk(1, majoritySpecies, true));
                }
                GenerateResources(majoritySpecies, Species.None);
            }
            else if (randValue <= 90)
            {
                _fleetComposition = "Skirmish";
                int     numShipsTotal    = Globals.RollD5() + 3;
                int     numMinorityShips = numShipsTotal / 2;
                int     numMajorityShips = numShipsTotal - numMinorityShips;
                Species majoritySpecies  = StarshipTools.GetRandomSpecies();
                if (_systemCreationRules.DominantRuinedSpecies != XenosRuinsSpecies.Undefined && Globals.RollD10() <= 6)
                {
                    Species tempSpecies = ConvertXenosRuinsSpeciesToSpecies(_systemCreationRules.DominantRuinedSpecies);
                    if (tempSpecies != Species.None)
                    {
                        majoritySpecies = tempSpecies;
                    }
                }
                if (_systemCreationRules.DominantRuinedSpecies == XenosRuinsSpecies.Undefined && Globals.RollD10() <= 7)
                {
                    XenosRuinsSpecies tempSpecies = ConvertSpeciesToXenosRuinsSpecies(majoritySpecies);
                    if (tempSpecies != XenosRuinsSpecies.Undefined)
                    {
                        _systemCreationRules.DominantRuinedSpecies = tempSpecies;
                    }
                }
                Species minoritySpecies;
                do
                {
                    minoritySpecies = StarshipTools.GetRandomSpecies();
                } while (minoritySpecies == majoritySpecies);

                // Limit Kroot and Stryxis ships
                if (majoritySpecies == Species.Kroot || majoritySpecies == Species.Stryxis)
                {
                    numMajorityShips /= 5;
                    if (numMajorityShips < 1)
                    {
                        numMajorityShips = 1;
                    }
                }
                if (minoritySpecies == Species.Kroot || minoritySpecies == Species.Stryxis)
                {
                    numMinorityShips /= 5;
                    if (numMinorityShips < 1)
                    {
                        numMinorityShips = 1;
                    }
                }
                for (int i = 0; i < numMajorityShips; i++)
                {
                    _hulks.Add(GenerateHulk(2, majoritySpecies));
                }
                for (int i = 0; i < numMinorityShips; i++)
                {
                    _hulks.Add(GenerateHulk(2, minoritySpecies));
                }
                GenerateResources(majoritySpecies, minoritySpecies);
            }
            else
            {
                _fleetComposition = "Unknown Provenance";
                int            numShipsTotal    = Globals.RollD5() + 2;
                int            generatedShips   = 0;
                List <Species> speciesGenerated = new List <Species>();
                while (generatedShips < numShipsTotal)
                {
                    Species race = StarshipTools.GetRandomSpecies();
                    if (speciesGenerated.Contains(race))
                    {
                        continue;
                    }
                    StarshipHulk hulk = GenerateHulk(3, race);
                    _hulks.Add(hulk);
                    speciesGenerated.Add(race);
                    generatedShips++;
                }
                GenerateResources(Species.Other, Species.None);
            }
        }
Пример #2
0
        private static StarshipHulk GenerateHulk(int salvageChance, Species race, bool increasedChanceOfBoarding = false)
        {
            StarshipHulk hulk = new StarshipHulk();

            if (race == Species.Random)
            {
                race = StarshipTools.GetRandomSpecies();
            }
            hulk.Race = Globals.GetSpeciesString(race);

            int salvageRoll = Globals.RollD10();

            if (salvageRoll <= salvageChance)
            {
                hulk.Integrity = "May be possible to salvage";
            }
            else if ((salvageRoll <= (salvageChance + 2)) ||
                     (increasedChanceOfBoarding && salvageRoll <= (salvageChance + 6)))
            {
                hulk.Integrity = "Intact enough to allow boarding, but little else";
            }
            else
            {
                hulk.Integrity = "Shattered beyond any value";
            }

            if (race == Species.DarkEldar && Properties.Settings.Default.BookTheSoulReaver == false)
            {
                // Make sure we don't generate Dark Eldar if we don't have The Soul Reaver
                race = Species.Eldar;
            }

            Starship ship = new Starship
            {
                Race = race
            };

            switch (race)
            {
            case Species.Human:
                StarshipTools.GenerateRandomHumanShip(ref ship);
                break;

            case Species.Ork:
                StarshipTools.GenerateRandomOrkShip(ref ship);
                break;

            case Species.Eldar:
                StarshipTools.GenerateRandomEldarShip(ref ship);
                break;

            case Species.DarkEldar:
                StarshipTools.GenerateRandomDarkEldarShip(ref ship);
                hulk.BookSource = RuleBook.TheSoulReaver;
                break;

            case Species.Stryxis:
                ship.ShipName   = "Xebec";
                ship.PageNumber = 96;
                ship.BookSource = RuleBook.BattlefleetKoronus;
                ship.ShipClass  = ShipClass.LightCruiser;
                break;

            case Species.RakGol:
                StarshipTools.GenerateRandomRakGolShip(ref ship);
                break;

            case Species.Kroot:
                ship.ShipName   = "Warsphere";
                ship.PageNumber = 101;
                ship.BookSource = RuleBook.BattlefleetKoronus;
                ship.ShipClass  = ShipClass.Battleship;
                break;

            case Species.ChaosReaver:
                StarshipTools.GenerateRandomChaosReaverShip(ref ship);
                break;

            case Species.Other:
                ship.ShipName   = "Starship";
                ship.PageNumber = 0;
                ship.BookSource = RuleBook.CoreRuleBook;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            hulk.ShipType   = ship.ShipName;
            hulk.BookPage   = ship.PageNumber;
            hulk.BookSource = ship.BookSource;

            hulk.GenerateDocItem();
            return(hulk);
        }