コード例 #1
0
ファイル: DeityGen.cs プロジェクト: AsheDev/WorldGenerator
        /// <summary>
        /// Generate a single deity.
        /// </summary>
        /// <param name="ChiefDiety">The chief deity of the pantheon. Will accept a null value if no chief deity exists.</param>
        /// <param name="prominence">The promince of the deity. Is it a primary, major, or minor deity? Primary will set the ChiefDeity value to null.</param>
        /// <returns>Returns an IDeity object</returns>
        public IDeity Generate(IDeity ChiefDiety, CoreEnums.Deity prominence)
        {
            IDeity deity = new Deity
            {
                Id = Random.Next(0, 78000000), // I need to ensure this is unique (at least until the database is up and running...
                Name = RandomNameGen(),
                Description = "DESCRIPTION",
                ChiefDiety = (prominence == CoreEnums.Deity.Primary) ? null : ChiefDiety,
                Prominence = prominence,
                Alignment = (CoreEnums.Alignment)Random.Next(0, 8)
            };
            AnnounceCreation(deity);

            return deity;
        }
コード例 #2
0
        public override int Weight(Deity creator)
        {
            int weight = base.Weight(creator);

            int army_count_attacker = 0;
            int army_count_defender = 0;

            foreach (Civilisation attacker in _white_peaced_war.Attackers)
            {
                for (int i = 0; i < attacker.Armies.Count; i++)
                {
                    if (!attacker.Armies[i].isScattered)
                    {
                        army_count_attacker += 1;
                    }
                }
            }
            foreach (Civilisation defender in _white_peaced_war.Defenders)
            {
                for (int i = 0; i < defender.Armies.Count; i++)
                {
                    if (!defender.Armies[i].isScattered)
                    {
                        army_count_defender += 1;
                    }
                }
            }

            // depending on the amount of armies on one side or the other the weight adjusted.
            if (_white_peaced_war.isAttacker(_commanded_nation))
            {
                // whithout armies the attacker is very likely to surrender.
                if (army_count_attacker == 0)
                {
                    weight += 10000;
                }
                else
                {
                    if (army_count_defender - army_count_attacker > 5)
                    {
                        weight += 10;
                    }
                    else if (army_count_defender - army_count_attacker > 10)
                    {
                        weight += 20;
                    }
                    else if (army_count_defender - army_count_attacker > 20)
                    {
                        weight += 50;
                    }
                }
            }
            else
            {
                // without armies the defender is very likely to surrender.
                if (army_count_defender == 0)
                {
                    weight += 10000;
                }
                else
                {
                    if (army_count_attacker - army_count_defender > 5)
                    {
                        weight += 10;
                    }
                    else if (army_count_attacker - army_count_defender > 10)
                    {
                        weight += 20;
                    }
                    else if (army_count_attacker - army_count_defender > 20)
                    {
                        weight += 50;
                    }
                }
            }


            return(weight >= 0 ? weight : 0);
        }
コード例 #3
0
 public override int Effect(Deity creator)
 {
     return(1);
 }
コード例 #4
0
 public Cave(string name, Province location, Deity creator) : base(name, location, creator)
 {
 }
コード例 #5
0
 public Mountain(string name, Province location, Deity creator) : base(name, location, creator)
 {
 }
コード例 #6
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);
        }
コード例 #7
0
        public override bool Precondition(Deity creator)
        {
            base.Precondition(creator);

            return(true);
        }
コード例 #8
0
 public Order(string name, Deity creator, OrderType type, OrderPurpose purpose) : base(name, creator)
 {
     Type    = type;
     Purpose = purpose;
     Members = new List <Avatar>();
 }
        private void ElementListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count <= 0)
            {
                return;
            }

            BaseMythObject myth_object = (BaseMythObject)e.AddedItems[0];

            textBlock_name_value.Text       = myth_object.Name;
            textBlock_tag_value.Text        = myth_object.Tag;
            textBlock_identifier_value.Text = myth_object.Identifier.ToString();

            if (myth_object.Creator != null)
            {
                textBlock_creator_value.Text = myth_object.Creator.ToString();
            }
            else
            {
                textBlock_creator_value.Text = "NONE";
            }

            if (e.AddedItems[0].GetType() == typeof(PrimordialForce))
            {
            }
            else if (e.AddedItems[0].GetType() == typeof(Plane))
            {
                Plane plane = (Plane)e.AddedItems[0];

                LabelOtherInformation.Content = "Plane Information";

                textBlock_other1.Text = "Plane Type: ";
                if (plane.PlaneType != null)
                {
                    textBlock_other1_value.Text = plane.PlaneType.ToString();
                }
                else
                {
                    textBlock_other1_value.Text = "NONE";
                }

                textBlock_other2.Text = "Plane Size: ";
                if (plane.PlaneSize != null)
                {
                    textBlock_other2_value.Text = plane.PlaneSize.ToString();
                }
                else
                {
                    textBlock_other2_value.Text = "NONE";
                }

                textBlock_other3.Text = "Plane Element: ";
                if (plane.PlaneElement != null)
                {
                    textBlock_other3_value.Text = plane.PlaneElement.ToString();
                }
                else
                {
                    textBlock_other3_value.Text = "NONE";
                }

                listBox_other.ItemsSource = plane.NeighbourPlanes;
            }
            else if (e.AddedItems[0].GetType() == typeof(Deity))
            {
                Deity deity = (Deity)e.AddedItems[0];

                LabelOtherInformation.Content = "Deity Information";

                textBlock_other1.Text       = "Personality: ";
                textBlock_other1_value.Text = deity.Personality.Name;
                textBlock_other2.Text       = "Power: ";
                textBlock_other2_value.Text = deity.Power.ToString();


                listBox_other.ItemsSource = deity.Domains;
            }
        }
コード例 #10
0
        public override int Effect(Deity creator)
        {
            Civilisation war_target = candidate_nations[rnd.Next(candidate_nations.Count)];

            // The war to be declared.
            War declared_war = new War("War of " + _commanded_nation.Name + " vs. " + war_target.Name, creator);

            declared_war.Attackers.Add(_commanded_nation);
            declared_war.Defenders.Add(war_target);

            // Add allies to the war. The order is important as all nations which are allied to both nations will side with the defender.
            foreach (Relations relation in war_target.Relationships)
            {
                if (relation.Status == RelationStatus.Allied)
                {
                    declared_war.Defenders.Add(relation.Target);
                }
            }

            foreach (Relations relation in _commanded_nation.Relationships)
            {
                if (relation.Status == RelationStatus.Allied)
                {
                    if (!declared_war.Defenders.Contains(relation.Target))
                    {
                        declared_war.Attackers.Add(relation.Target);
                    }
                }
            }


            List <WeightedObjects <WarGoal> >[] war_goals = new List <WeightedObjects <WarGoal> > [2];
            for (int i = 0; i < 2; i++)
            {
                war_goals[i] = new List <WeightedObjects <WarGoal> >();
                foreach (WarGoal war_goal in war_target.PossibleWarGoals)
                {
                    war_goals[i].Add(new WeightedObjects <WarGoal>(war_goal));
                }

                // determine the weights of each war goal. Certain types of polities can only take certain types of war goals.
                foreach (WeightedObjects <WarGoal> weighted_war_goal in war_goals[i])
                {
                    Civilisation taker, target;
                    if (i == 0)
                    {
                        taker  = _commanded_nation;
                        target = war_target;
                    }
                    else
                    {
                        taker  = war_target;
                        target = _commanded_nation;
                    }

                    weighted_war_goal.Object.Winner = taker;

                    if (taker.isNomadic)
                    {
                        if (target.isNomadic)
                        {
                            if (weighted_war_goal.Object.Type == WarGoalType.Conquest)
                            {
                                weighted_war_goal.Weight += Constants.WEIGHT_STANDARD_CHANGE;
                            }
                            else
                            if (weighted_war_goal.Object.Type == WarGoalType.VassalizeCity)
                            {
                                weighted_war_goal.Weight += Constants.WEIGHT_STANDARD_CHANGE;
                            }
                        }
                    }
                    else
                    {
                        if (target.isNomadic)
                        {
                            if (weighted_war_goal.Object.Type == WarGoalType.RemoveNomadicPresence)
                            {
                                weighted_war_goal.Weight += Constants.WEIGHT_STANDARD_CHANGE;
                            }
                        }
                        else
                        {
                            if (weighted_war_goal.Object.Type == WarGoalType.CityConquest)
                            {
                                weighted_war_goal.Weight += Constants.WEIGHT_STANDARD_CHANGE * 2;
                            }
                            if (weighted_war_goal.Object.Type == WarGoalType.Conquest)
                            {
                                weighted_war_goal.Weight += Constants.WEIGHT_STANDARD_CHANGE;
                            }
                        }
                    }
                }
            }

            List <WarGoal> weighted_war_goals = WeightedObjects <WarGoal> .ChooseHeaviestObjects(war_goals[0]);

            declared_war.WarGoalAttackers = weighted_war_goals[rnd.Next(weighted_war_goals.Count)];

            weighted_war_goals = WeightedObjects <WarGoal> .ChooseHeaviestObjects(war_goals[1]);

            declared_war.WarGoalDefenders = weighted_war_goals[rnd.Next(weighted_war_goals.Count)];


            // Add war to the list of ongoing conflicts.
            Program.State.OngoingWars.Add(declared_war);

            declared_war.Begin = Simulation.Time.Shuffle;

            // Add powers related to the war to connected deities.
            // attacker related
            // Only the war leader can surrender as only he stands to lose anything, all other participants can only white peace.
            creator.Powers.Add(new SurrenderWar(_commanded_nation, declared_war));
            foreach (Civilisation attacker in declared_war.Attackers)
            {
                creator.Powers.Add(new WhitePeace(attacker, declared_war));

                foreach (Civilisation defender in declared_war.Defenders)
                {
                    creator.Powers.Add(new AttackNation(attacker, defender, declared_war));
                }
            }


            // defender related
            declared_war.Defenders[0].Creator.Powers.Add(new SurrenderWar(declared_war.Defenders[0], declared_war));
            foreach (Civilisation defender in declared_war.Defenders)
            {
                defender.Creator.Powers.Add(new WhitePeace(defender, declared_war));

                foreach (Civilisation attacker in declared_war.Defenders)
                {
                    creator.Powers.Add(new AttackNation(defender, attacker, declared_war));
                }
            }
            creator.LastCreation = declared_war;

            Program.WorldHistory.AddRecord(RecordType.WarReport, declared_war, War.printWar);

            return(0);
        }
コード例 #11
0
ファイル: War.cs プロジェクト: Kordishal/dawn-of-worlds
 public War(string name, Deity creator) : base(name, creator)
 {
     Attackers = new List <Civilisation>();
     Defenders = new List <Civilisation>();
     hasEnded  = false;
 }
コード例 #12
0
ファイル: Ocean.cs プロジェクト: Kordishal/dawn-of-worlds
 public Ocean(string name, Province location, Deity creator) : base(name, location, creator)
 {
     BiomeType = BiomeType.Ocean;
 }
コード例 #13
0
 public River(string name, Province location, Deity creator) : base(name, location, creator)
 {
     Riverbed       = new List <Province>();
     ConnectedLakes = new List <Lake>();
     SourceRivers   = new List <River>();
 }
コード例 #14
0
 abstract public int Effect(Deity creator);
コード例 #15
0
        public override int Effect(Deity creator)
        {
            HillRange hill_range = new HillRange(Program.GenerateNames.GetName("hill_range_names"), SelectedProvince, creator);

            SelectedProvince.Type = TerrainType.HillRange;
            SelectedProvince.PrimaryTerrainFeature = hill_range;
            SelectedProvince.isDefault             = false;
            creator.TerrainFeatures.Add(hill_range);
            creator.LastCreation = hill_range;

            int chance = rnd.Next(100);

            switch (SelectedProvince.LocalClimate)
            {
            case Climate.Arctic:
                hill_range.BiomeType = BiomeType.PolarDesert;
                break;

            case Climate.SubArctic:
                if (chance < 50)
                {
                    hill_range.BiomeType = BiomeType.Tundra;
                }
                else
                {
                    hill_range.BiomeType = BiomeType.BorealForest;
                }
                break;

            case Climate.Temperate:
                if (chance < 50)
                {
                    hill_range.BiomeType = BiomeType.TemperateGrassland;
                }
                else
                {
                    hill_range.BiomeType = BiomeType.TemperateDeciduousForest;
                }
                break;

            case Climate.SubTropical:
                if (chance < 50)
                {
                    hill_range.BiomeType = BiomeType.TropicalGrassland;
                }
                else
                {
                    hill_range.BiomeType = BiomeType.TropicalDryForest;
                }
                break;

            case Climate.Tropical:
                if (chance < 50)
                {
                    hill_range.BiomeType = BiomeType.TropicalGrassland;
                }
                else
                {
                    hill_range.BiomeType = BiomeType.TropicalRainforest;
                }
                break;
            }

            Program.WorldHistory.AddRecord(hill_range, hill_range.printTerrainFeature);

            return(0);
        }