public override int Effect(Deity creator)
        {
            List <WeightedObjects <Province> > provinces = candidate_provinces();

            _chosen_location = WeightedObjects <Province> .ChooseRandomObject(provinces, rnd);

            // Set new climate
            switch (_chosen_location.LocalClimate)
            {
            case Climate.Tropical:
                _chosen_location.LocalClimate = Climate.SubTropical;
                break;

            case Climate.SubTropical:
                _chosen_location.LocalClimate = Climate.Temperate;
                break;

            case Climate.Temperate:
                _chosen_location.LocalClimate = Climate.SubArctic;
                break;

            case Climate.SubArctic:
                _chosen_location.LocalClimate = Climate.Arctic;
                break;
            }

            adjustTerrainFeatureBiomes();

            return(0);
        }
Beispiel #2
0
        public override int Effect(Deity creator)
        {
            TerrainFeatures terrain = WeightedObjects <TerrainFeatures> .ChooseRandomObject(potential_construction_sites(), rnd);

            Building building = new Building(null, creator, _type);

            building.Terrain = terrain;
            building.Effect();

            terrain.Buildings.Add(building);

            return(0);
        }
        public override int Effect(Deity creator)
        {
            possible_target_armies();

            Army target_army = WeightedObjects <Army> .ChooseRandomObject(_possible_targets, rnd);

            Army attacker_army = WeightedObjects <Army> .ChooseRandomObject(_possible_attackers, rnd);

            // Move the armies into the same terrain.
            if (!target_army.Location.Equals(attacker_army.Location))
            {
                attacker_army.Location = target_army.Location;
            }

            Battle battle = new Battle(attacker_army.Name + " vs. " + target_army.Name, creator, attacker_army, target_army, target_army.Location, _war);

            battle.Fight();

            creator.LastCreation = null;

            return(0);
        }
        public override int Effect(Deity creator)
        {
            List <WeightedObjects <Province> > possible_locations = new List <WeightedObjects <Province> >();

            foreach (Province province in _commanded_race.SettledProvinces)
            {
                if (!province.hasOwner)
                {
                    possible_locations.Add(new WeightedObjects <Province>(province));
                }
            }


            foreach (WeightedObjects <Province> weighted_feature in possible_locations)
            {
                weighted_feature.Weight += 5;
                // considers the biome of the terrain feature.
                switch (weighted_feature.Object.PrimaryTerrainFeature.BiomeType)
                {
                case BiomeType.BorealForest:
                case BiomeType.TemperateDeciduousForest:
                case BiomeType.TropicalDryForest:
                case BiomeType.TropicalRainforest:
                    if (_commanded_race.PreferredTerrain.Exists(x => x == RacialPreferredHabitatTerrain.ForestDwellers))
                    {
                        weighted_feature.Weight += Constants.WEIGHT_STANDARD_CHANGE;
                    }
                    break;

                case BiomeType.ColdDesert:
                case BiomeType.HotDesert:
                    if (_commanded_race.PreferredTerrain.Exists(x => x == RacialPreferredHabitatTerrain.DesertDwellers))
                    {
                        weighted_feature.Weight += Constants.WEIGHT_STANDARD_CHANGE;
                    }
                    break;

                case BiomeType.TemperateGrassland:
                case BiomeType.Tundra:
                case BiomeType.TropicalGrassland:
                    if (_commanded_race.PreferredTerrain.Exists(x => x == RacialPreferredHabitatTerrain.GrasslandDwellers))
                    {
                        weighted_feature.Weight += Constants.WEIGHT_STANDARD_CHANGE;
                    }
                    break;

                case BiomeType.Subterranean:
                    if (_commanded_race.PreferredTerrain.Exists(x => x == RacialPreferredHabitatTerrain.CaveDwellers))
                    {
                        weighted_feature.Weight += Constants.WEIGHT_STANDARD_CHANGE;
                    }
                    break;
                }
                // Considers the generall type of the terrain.
                switch (weighted_feature.Object.Type)
                {
                case TerrainType.HillRange:
                    if (_commanded_race.PreferredTerrain.Exists(x => x == RacialPreferredHabitatTerrain.HillDwellers))
                    {
                        weighted_feature.Weight += Constants.WEIGHT_STANDARD_CHANGE;
                    }
                    break;

                case TerrainType.MountainRange:
                    if (_commanded_race.PreferredTerrain.Exists(x => x == RacialPreferredHabitatTerrain.MountainDwellers))
                    {
                        weighted_feature.Weight += Constants.WEIGHT_STANDARD_CHANGE;
                    }
                    break;

                case TerrainType.Plain:
                    if (_commanded_race.PreferredTerrain.Exists(x => x == RacialPreferredHabitatTerrain.PlainDwellers))
                    {
                        weighted_feature.Weight += Constants.WEIGHT_STANDARD_CHANGE;
                    }
                    break;
                }
            }

            if (possible_locations.Count == 0)
            {
                return(1);
            }

            Province location = WeightedObjects <Province> .ChooseRandomObject(possible_locations, rnd);

            Civilisation founded_civilisation = new Civilisation("Nation of " + _commanded_race.Name, creator);

            founded_civilisation.PoliticalOrganisation = _polity;
            founded_civilisation.InhabitantRaces.Add(_commanded_race);

            // Nomadic?
            switch (founded_civilisation.PoliticalOrganisation.Organisation)
            {
            case SocialOrganisation.BandSociety:
                switch (founded_civilisation.PoliticalOrganisation.Form)
                {
                case PolityForm.Band:
                case PolityForm.Herd:
                case PolityForm.Pack:
                    founded_civilisation.isNomadic = true;
                    break;

                case PolityForm.Brood:
                    founded_civilisation.isNomadic = false;
                    break;
                }
                break;

            case SocialOrganisation.TribalSociety:
                int _dice = rnd.Next(50);
                if (_dice < 25)
                {
                    founded_civilisation.isNomadic = true;
                }
                else
                {
                    founded_civilisation.isNomadic = false;
                }
                break;
            }

            // Diplomacy
            if (_commanded_race.Type == SpeciesType.Beasts)
            {
                founded_civilisation.hasDiplomacy = false;
            }
            else
            {
                founded_civilisation.hasDiplomacy = true;
                foreach (Civilisation nation in Program.State.Civilizations)
                {
                    nation.Relationships.Add(new Relations(founded_civilisation));
                    founded_civilisation.Relationships.Add(new Relations(nation));
                }
            }

            // Cities
            // Nomadic civilisations do not have cities
            if (founded_civilisation.isNomadic)
            {
                founded_civilisation.hasCities = false;
            }
            else
            {
                founded_civilisation.hasCities = true;
                founded_civilisation.Cities.Add(new City("Capital City of " + founded_civilisation.Name, creator));
                founded_civilisation.CapitalCity.TerrainFeature = location.PrimaryTerrainFeature;
                founded_civilisation.CapitalCity.Owner          = founded_civilisation;

                location.PrimaryTerrainFeature.City = founded_civilisation.CapitalCity;
            }

            // Territory
            founded_civilisation.Territory.Add(location);
            if (founded_civilisation.isNomadic)
            {
                location.NomadicPresence.Add(founded_civilisation);
            }
            else
            {
                location.Owner = founded_civilisation;
            }


            // Add origin order -> church. This church is needed to be able to command this nation.
            Order founder_origin_order = new Order(Program.GenerateNames.GetName(), creator, OrderType.Church, OrderPurpose.FounderWorship);

            founder_origin_order.OrderNation = founded_civilisation;
            founder_origin_order.OrderRace   = null;

            founded_civilisation.NationalOrders.Add(founder_origin_order);
            creator.CreatedOrders.Add(founder_origin_order);

            // Possible War Goals
            WarGoal        war_goal;
            List <WarGoal> war_goals = new List <WarGoal>();

            switch (founded_civilisation.PoliticalOrganisation.Organisation)
            {
            case SocialOrganisation.BandSociety:
                break;

            case SocialOrganisation.TribalSociety:
                break;

            case SocialOrganisation.Chiefdom:
                break;

            case SocialOrganisation.State:
                break;
            }

            founded_civilisation.PossibleWarGoals.AddRange(war_goals);

            // Add nation to the creator and Powers related to this nation.
            creator.FoundedNations.Add(founded_civilisation);
            Program.State.Civilizations.Add(founded_civilisation);
            creator.CreatedOrders.Add(founded_civilisation.OriginOrder);

            if (founded_civilisation.hasCities)
            {
                creator.Powers.Add(new CreateCity(founded_civilisation));
                creator.FoundedCities.Add(founded_civilisation.CapitalCity);
                Program.State.Cities.Add(founded_civilisation.CapitalCity);
            }

            if (founded_civilisation.hasDiplomacy)
            {
                creator.Powers.Add(new ExpandTerritory(founded_civilisation));
                creator.Powers.Add(new EstablishContact(founded_civilisation));
                creator.Powers.Add(new FormAlliance(founded_civilisation));
                creator.Powers.Add(new DeclareWar(founded_civilisation));
            }


            foreach (Deity deity in Program.State.Deities)
            {
                // Add avatars
                foreach (AvatarType type in Enum.GetValues(typeof(AvatarType)))
                {
                    deity.Powers.Add(new CreateAvatar(type, founded_civilisation.FoundingRace, founded_civilisation, null));
                }

                // Add Events
                deity.Powers.Add(new VastGoldMineEstablised(founded_civilisation));
                deity.Powers.Add(new VastGoldMineDepleted(founded_civilisation));
            }

            foreach (Deity deity in Program.State.Deities)
            {
                if (!(deity == creator))
                {
                    deity.Powers.Add(new CreateOrder(OrderType.Church, OrderPurpose.FounderWorship, founded_civilisation, null));
                }
            }

            creator.LastCreation = founded_civilisation;

            return(0);
        }
Beispiel #5
0
        protected Province selectProvince()
        {
            List <WeightedObjects <Province> > weighted_provinces = new List <WeightedObjects <Province> >();
            List <Province> obsolete_provinces = new List <Province>();

            foreach (Province province in PotentialProvinces)
            {
                bool add_province = true;

                add_province = selectionModifier(province);

                // Do not change the primary terrain feature more than once.
                if (!province.isDefault && isPrimary)
                {
                    add_province = false;
                    obsolete_provinces.Add(province);
                }


                foreach (Modifier modifier in province.ProvincialModifiers)
                {
                    if (modifier.Forbids != null)
                    {
                        for (int i = 0; i < modifier.Forbids.Length; i++)
                        {
                            if (Tags.Contains(modifier.Forbids[i]))
                            {
                                add_province = false;
                            }
                        }
                    }
                }

                if (add_province)
                {
                    weighted_provinces.Add(new WeightedObjects <Province>(province));
                }
            }

            foreach (Province province in obsolete_provinces)
            {
                PotentialProvinces.Remove(province);
            }

            foreach (WeightedObjects <Province> weighted_province in weighted_provinces)
            {
                weighted_province.Weight += 5;

                foreach (Modifier modifier in weighted_province.Object.ProvincialModifiers)
                {
                    if (modifier.IncreasesWeight != null)
                    {
                        for (int i = 0; i < modifier.IncreasesWeight.Length; i++)
                        {
                            if (Tags.Contains(modifier.IncreasesWeight[i]))
                            {
                                weighted_province.Weight += WeightChange;
                            }
                        }
                    }
                }

                // Primary terrain features are more likely to appear next to each other.
                if (isPrimary)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        SystemCoordinates coords = weighted_province.Object.Coordinates;
                        coords = coords.GetNeighbour(i);

                        if (coords.isInTileGridBounds())
                        {
                            if (Program.State.ProvinceGrid[coords.X, coords.Y].PrimaryTerrainFeature.GetType() == weighted_province.Object.PrimaryTerrainFeature.GetType())
                            {
                                weighted_province.Weight += WeightChange;
                            }
                        }
                    }
                }
            }

            return(WeightedObjects <Province> .ChooseRandomObject(weighted_provinces, rnd));
        }