コード例 #1
0
        public CreateAvatar(AvatarType type, Race race, Civilisation nation, Order order)
        {
            _type   = type;
            _race   = race;
            _nation = nation;
            _order  = order;

            initialize();
        }
コード例 #2
0
 public CreateOrder(OrderType type, OrderPurpose purpose, Civilisation nation, Race race)
 {
     _type     = type;
     _purpose  = purpose;
     _nation   = nation;
     _race     = race;
     isCreated = false;
     initialize();
 }
コード例 #3
0
ファイル: War.cs プロジェクト: Kordishal/dawn-of-worlds
 public bool isWarLeader(Civilisation nation)
 {
     if (Attackers[0] == nation || Defenders[0] == nation)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #4
0
ファイル: War.cs プロジェクト: Kordishal/dawn-of-worlds
        public bool isAttacker(Civilisation nation)
        {
            foreach (Civilisation attacker in Attackers)
            {
                if (attacker == nation)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #5
0
        public void ChangeOwnership(Civilisation winner)
        {
            List <City> local_cities = Owner.Cities.FindAll(x => x.TerrainFeature.Province == this);

            foreach (City city in local_cities)
            {
                Owner.Cities.Remove(city);
                city.Owner = winner;
            }
            Owner.Territory.Remove(this);
            Owner = winner;
        }
コード例 #6
0
ファイル: War.cs プロジェクト: Kordishal/dawn-of-worlds
        public bool isDefender(Civilisation nation)
        {
            foreach (Civilisation defender in Defenders)
            {
                if (defender == nation)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #7
0
        public override int Effect(Deity creator)
        {
            compile_candidate_nations();

            // The new contact will be chosen amongst the possible contacts at random.
            Civilisation new_contact = candidate_nations[rnd.Next(candidate_nations.Count)];

            _commanded_nation.Relationships.Find(x => x.Target.Equals(new_contact)).Status = RelationStatus.Known;
            new_contact.Relationships.Find(x => x.Target.Equals(_commanded_nation)).Status = RelationStatus.Known;
            creator.LastCreation = null;

            return(0);
        }
コード例 #8
0
        public override int Effect(Deity creator)
        {
            compile_candidate_nations();

            // The new ally will be chosen amongst the possible allies at random.
            Civilisation new_ally = candidate_nations[rnd.Next(candidate_nations.Count)];

            _commanded_nation.Relationships.Find(x => x.Target == new_ally).Status = RelationStatus.Allied;
            new_ally.Relationships.Find(x => x.Target == _commanded_nation).Status = RelationStatus.Allied;
            creator.LastCreation = null;

            return(0);
        }
コード例 #9
0
        public string printRecordType(RecordType type, Civilisation nation)
        {
            List <Record> selected_records = Records.FindAll(x => x.Nation != null && x.Type == type && x.Nation.Equals(nation));

            selected_records.Sort(Record.CompareTo);

            string records = "";

            foreach (Record record in selected_records)
            {
                records += record.printRecord() + "\n";
            }
            return(records);
        }
コード例 #10
0
        public void AddRecord(RecordType type, Civilisation nation, char[,] map, PrintFunction print)
        {
            Record record = new Record();

            record.Type   = type;
            record.Nation = nation;
            record.Map    = map;

            record.Turn = Simulation.Time.Turn;
            record.Year = Simulation.Time.Shuffle;

            record.printFunction = print;
            Records.Add(record);
        }
コード例 #11
0
ファイル: Map.cs プロジェクト: Kordishal/dawn-of-worlds
        public static char[,] generateNationTerritoryMap(Civilisation nation)
        {
            char[,] nation_territory_map = new char[Constants.TILE_GRID_X, Constants.TILE_GRID_Y];

            foreach (Province province in Program.State.ProvinceGrid)
            {
                if (nation.Territory.Contains(province))
                {
                    nation_territory_map[province.Coordinates.X, province.Coordinates.Y] = 'T';
                }
                else
                {
                    nation_territory_map[province.Coordinates.X, province.Coordinates.Y] = 'U';
                }
            }

            return(nation_territory_map);
        }
コード例 #12
0
 public DeclareWar(Civilisation commanded_nation) : base(commanded_nation)
 {
     initialize();
 }
コード例 #13
0
 public CreateCity(Civilisation commanded_nation) : base(commanded_nation)
 {
     initialize();
 }
コード例 #14
0
 public WhitePeace(Civilisation commanded_nation, War white_peace_war) : base(commanded_nation)
 {
     _white_peaced_war = white_peace_war;
     initialize();
 }
コード例 #15
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);
        }
コード例 #16
0
 public AttackNation(Civilisation commanded_nation, Civilisation target_nation, War war) : base(commanded_nation)
 {
     _attacked_nation = target_nation;
     _war             = war;
     initialize();
 }
コード例 #17
0
 public CivilisationEvents(Civilisation nation)
 {
     _nation = nation;
     initialize();
 }
コード例 #18
0
 public VastGoldMineEstablised(Civilisation nation) : base(nation)
 {
 }
コード例 #19
0
 public VastGoldMineDepleted(Civilisation nation) : base(nation)
 {
 }
コード例 #20
0
ファイル: War.cs プロジェクト: Kordishal/dawn-of-worlds
 public bool isInWar(Civilisation nation)
 {
     return(isDefender(nation) || isAttacker(nation));
 }
コード例 #21
0
 public FormAlliance(Civilisation commanded_nation) : base(commanded_nation)
 {
     initialize();
 }
コード例 #22
0
 public void changeOwnership(Civilisation to)
 {
     Owner.Cities.Remove(this);
     Owner = to;
 }
コード例 #23
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);
        }
コード例 #24
0
 public CommandNation(Civilisation commanded_nation)
 {
     _commanded_nation = commanded_nation;
 }
コード例 #25
0
ファイル: Relations.cs プロジェクト: Kordishal/dawn-of-worlds
 public Relations(Civilisation target)
 {
     Target = target;
     Status = RelationStatus.Unknown;
 }
コード例 #26
0
 public ConstructFortification(Civilisation commanded_nation, BuildingType type) : base(commanded_nation)
 {
     _type = type;
     initialize();
 }
コード例 #27
0
 public ExpandTerritory(Civilisation commanded_nation) : base(commanded_nation)
 {
     initialize();
 }
コード例 #28
0
 public EstablishContact(Civilisation commanded_nation) : base(commanded_nation)
 {
     initialize();
 }
コード例 #29
0
 public SurrenderWar(Civilisation surrendering_nation, War surrendered_war) : base(surrendering_nation)
 {
     _surrendered_war = surrendered_war;
     initialize();
 }