protected Species ConvertXenosRuinsSpeciesToSpecies(XenosRuinsSpecies ruinsSpecies)
        {
            switch (ruinsSpecies)
            {
            case XenosRuinsSpecies.Egarian:
            case XenosRuinsSpecies.YuVath:
            case XenosRuinsSpecies.Undefined:
                return(Species.None);

            case XenosRuinsSpecies.UndiscoveredSpecies:
                return(Species.Other);

            case XenosRuinsSpecies.Eldar:
                return(Species.Eldar);

            case XenosRuinsSpecies.Ork:
                return(Species.Ork);

            case XenosRuinsSpecies.Kroot:
                return(Species.Kroot);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        protected void ReduceAllResources(int amountToReduce)
        {
            _resourceIndustrialMetal -= amountToReduce;
            if (_resourceIndustrialMetal < 0)
            {
                _resourceIndustrialMetal = 0;
            }

            _resourceOrnamental -= amountToReduce;
            if (_resourceOrnamental < 0)
            {
                _resourceOrnamental = 0;
            }

            _resourceRadioactive -= amountToReduce;
            if (_resourceRadioactive < 0)
            {
                _resourceRadioactive = 0;
            }

            _resourceExoticMaterial -= amountToReduce;
            if (_resourceExoticMaterial < 0)
            {
                _resourceExoticMaterial = 0;
            }

            _resourceArcheotechCache -= amountToReduce;
            if (_resourceArcheotechCache < 0)
            {
                _resourceArcheotechCache = 0;
            }

            _resourceXenosRuins -= amountToReduce;
            if (_resourceXenosRuins <= 0)
            {
                _resourceXenosRuins        = 0;
                _resourceXenosRuinsSpecies = XenosRuinsSpecies.Undefined;
            }

            List <OrganicCompound> compoundsToRemove = new List <OrganicCompound>();

            foreach (OrganicCompound organicCompound in OrganicCompounds)
            {
                organicCompound.Abundance -= amountToReduce;
                if (organicCompound.Abundance <= 0)
                {
                    compoundsToRemove.Add(organicCompound);
                }
            }

            foreach (OrganicCompound organicCompound in compoundsToRemove)
            {
                OrganicCompounds.Remove(organicCompound);
            }
        }
        public void GenerateXenosRuins(int bonusAbundance = 0)
        {
            if (_systemCreationRules.DominantRuinedSpecies != XenosRuinsSpecies.Undefined &&
                Globals.RollD10() <= 6)
            {
                _resourceXenosRuinsSpecies = _systemCreationRules.DominantRuinedSpecies;
            }
            if (_resourceXenosRuinsSpecies == XenosRuinsSpecies.Undefined)
            {
                switch (Globals.RollD10())
                {
                case 1:
                case 2:
                case 3:
                case 4:
                    _resourceXenosRuinsSpecies = XenosRuinsSpecies.UndiscoveredSpecies;
                    break;

                case 5:
                case 6:
                    _resourceXenosRuinsSpecies = XenosRuinsSpecies.Eldar;
                    break;

                case 7:
                    _resourceXenosRuinsSpecies = XenosRuinsSpecies.Egarian;
                    break;

                case 8:
                    _resourceXenosRuinsSpecies = XenosRuinsSpecies.YuVath;
                    break;

                case 9:
                    _resourceXenosRuinsSpecies = XenosRuinsSpecies.Ork;
                    break;

                case 10:
                    _resourceXenosRuinsSpecies = XenosRuinsSpecies.Kroot;
                    break;
                }
                if (_systemCreationRules.DominantRuinedSpecies == XenosRuinsSpecies.Undefined && Globals.RollD10() <= 7)
                {
                    _systemCreationRules.DominantRuinedSpecies = _resourceXenosRuinsSpecies;
                }
            }
            int amountToAdd = Globals.RollD100() + bonusAbundance;

            _resourceXenosRuins += amountToAdd;
        }
        public virtual void ResetVariables()
        {
            _children.Clear();
            _flowDocument                   = new FlowDocument();
            _systemCreationRules            = new SystemCreationRules();
            _travelTimeFromSystemEdgeInDays = 0;
            _description           = "";
            _dirty                 = false;
            _inhabitants           = Species.None;
            _inhabitantDevelopment = new DocContentItem("");

            _resourceIndustrialMetal   = 0;
            _resourceOrnamental        = 0;
            _resourceRadioactive       = 0;
            _resourceExoticMaterial    = 0;
            _resourceArcheotechCache   = 0;
            _resourceXenosRuins        = 0;
            _resourceXenosRuinsSpecies = XenosRuinsSpecies.Undefined;
            OrganicCompounds           = new List <OrganicCompound>();
        }
Exemplo n.º 5
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);
            }
        }
        protected void ReduceRandomResource(int amountToReduce)
        {
            List <ResourceType> resourcePool = new List <ResourceType>();

            if (_resourceIndustrialMetal > 0)
            {
                for (int i = 0; i < 25; i++)
                {
                    resourcePool.Add(ResourceType.IndustrialMetal);
                }
            }
            if (_resourceOrnamental > 0)
            {
                for (int i = 0; i < 25; i++)
                {
                    resourcePool.Add(ResourceType.Ornamental);
                }
            }
            if (_resourceRadioactive > 0)
            {
                for (int i = 0; i < 25; i++)
                {
                    resourcePool.Add(ResourceType.Radioactive);
                }
            }
            if (_resourceExoticMaterial > 0)
            {
                for (int i = 0; i < 25; i++)
                {
                    resourcePool.Add(ResourceType.ExoticMaterial);
                }
            }
            if (_resourceArcheotechCache > 0)
            {
                for (int i = 0; i < 5; i++)
                {
                    resourcePool.Add(ResourceType.ArcheotechCache);
                }
            }
            if (_resourceXenosRuins > 0)
            {
                for (int i = 0; i < 3; i++)
                {
                    resourcePool.Add(ResourceType.XenosRuin);
                }
            }
            foreach (OrganicCompound organicCompound in OrganicCompounds)
            {
                switch (organicCompound.OrganicResourceType)
                {
                case OrganicResourceTypes.Curative:
                    for (int i = 0; i < 5; i++)
                    {
                        resourcePool.Add(ResourceType.Curative);
                    }
                    break;

                case OrganicResourceTypes.JuvenatCompound:
                    for (int i = 0; i < 5; i++)
                    {
                        resourcePool.Add(ResourceType.JuvenatCompound);
                    }
                    break;

                case OrganicResourceTypes.Toxin:
                    for (int i = 0; i < 5; i++)
                    {
                        resourcePool.Add(ResourceType.Toxin);
                    }
                    break;

                case OrganicResourceTypes.VividAccessory:
                    for (int i = 0; i < 5; i++)
                    {
                        resourcePool.Add(ResourceType.VividAccessory);
                    }
                    break;

                case OrganicResourceTypes.ExoticCompound:
                    for (int i = 0; i < 5; i++)
                    {
                        resourcePool.Add(ResourceType.ExoticCompound);
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            OrganicCompound resourceToRemove = null;

            if (resourcePool.Count <= 0)
            {
                return;
            }
            switch (resourcePool[Globals.Rand.Next(resourcePool.Count)])
            {
            case ResourceType.IndustrialMetal:
                _resourceIndustrialMetal -= amountToReduce;
                if (_resourceIndustrialMetal < 0)
                {
                    _resourceIndustrialMetal = 0;
                }
                break;

            case ResourceType.Ornamental:
                _resourceOrnamental -= amountToReduce;
                if (_resourceOrnamental < 0)
                {
                    _resourceOrnamental = 0;
                }
                break;

            case ResourceType.Radioactive:
                _resourceRadioactive -= amountToReduce;
                if (_resourceRadioactive < 0)
                {
                    _resourceRadioactive = 0;
                }
                break;

            case ResourceType.ExoticMaterial:
                _resourceExoticMaterial -= amountToReduce;
                if (_resourceExoticMaterial < 0)
                {
                    _resourceExoticMaterial = 0;
                }
                break;

            case ResourceType.ArcheotechCache:
                _resourceArcheotechCache -= amountToReduce;
                if (_resourceArcheotechCache < 0)
                {
                    _resourceArcheotechCache = 0;
                }
                break;

            case ResourceType.XenosRuin:
                _resourceXenosRuins -= amountToReduce;
                if (_resourceXenosRuins <= 0)
                {
                    _resourceXenosRuins        = 0;
                    _resourceXenosRuinsSpecies = XenosRuinsSpecies.Undefined;
                }
                break;

            case ResourceType.Curative:
                foreach (OrganicCompound organicCompound in OrganicCompounds)
                {
                    if (organicCompound.OrganicResourceType == OrganicResourceTypes.Curative)
                    {
                        organicCompound.Abundance -= amountToReduce;
                        if (organicCompound.Abundance <= 0)
                        {
                            resourceToRemove = organicCompound;
                        }
                    }
                }
                break;

            case ResourceType.JuvenatCompound:
                foreach (OrganicCompound organicCompound in OrganicCompounds)
                {
                    if (organicCompound.OrganicResourceType == OrganicResourceTypes.JuvenatCompound)
                    {
                        organicCompound.Abundance -= amountToReduce;
                        if (organicCompound.Abundance <= 0)
                        {
                            resourceToRemove = organicCompound;
                        }
                    }
                }
                break;

            case ResourceType.Toxin:
                foreach (OrganicCompound organicCompound in OrganicCompounds)
                {
                    if (organicCompound.OrganicResourceType == OrganicResourceTypes.Toxin)
                    {
                        organicCompound.Abundance -= amountToReduce;
                        if (organicCompound.Abundance <= 0)
                        {
                            resourceToRemove = organicCompound;
                        }
                    }
                }
                break;

            case ResourceType.VividAccessory:
                foreach (OrganicCompound organicCompound in OrganicCompounds)
                {
                    if (organicCompound.OrganicResourceType == OrganicResourceTypes.VividAccessory)
                    {
                        organicCompound.Abundance -= amountToReduce;
                        if (organicCompound.Abundance <= 0)
                        {
                            resourceToRemove = organicCompound;
                        }
                    }
                }
                break;

            case ResourceType.ExoticCompound:
                foreach (OrganicCompound organicCompound in OrganicCompounds)
                {
                    if (organicCompound.OrganicResourceType == OrganicResourceTypes.ExoticCompound)
                    {
                        organicCompound.Abundance -= amountToReduce;
                        if (organicCompound.Abundance <= 0)
                        {
                            resourceToRemove = organicCompound;
                        }
                    }
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (resourceToRemove != null)
            {
                OrganicCompounds.Remove(resourceToRemove);
            }
        }