public void TryDeclareWar()
 {
     if (CivilizationToRecord != null && WarCanon.CanDeclareWar(GameCore.ActiveCiv, CivilizationToRecord))
     {
         WarCanon.DeclareWar(GameCore.ActiveCiv, CivilizationToRecord);
     }
 }
Пример #2
0
        public void DecomposeDiplomacy(SerializableMapData mapData)
        {
            var diplomacyData = mapData.DiplomacyData;

            if (diplomacyData == null)
            {
                return;
            }

            var allCivs = CivFactory.AllCivilizations;

            foreach (var warData in diplomacyData.ActiveWars)
            {
                var attacker = allCivs.Where(civ => civ.Template.Name.Equals(warData.Item1)).FirstOrDefault();

                if (attacker == null)
                {
                    throw new InvalidOperationException("Could not find a civ with name " + warData.Item1);
                }

                var defender = allCivs.Where(civ => civ.Template.Name.Equals(warData.Item2)).FirstOrDefault();

                if (defender == null)
                {
                    throw new InvalidOperationException("Could not find a civ with name " + warData.Item2);
                }

                if (!WarCanon.CanDeclareWar(attacker, defender))
                {
                    throw new InvalidOperationException(string.Format(
                                                            "Cannot declare the specified war between {0} and {1}",
                                                            attacker.Template.Name, defender.Template.Name
                                                            ));
                }

                WarCanon.DeclareWar(attacker, defender);
            }

            foreach (var proposalData in diplomacyData.ActiveProposals)
            {
                var proposal = ProposalComposer.DecomposeProposal(proposalData);

                DiplomacyCore.SendProposal(proposal);
            }

            foreach (var ongoingDealData in diplomacyData.ActiveOngoingDeals)
            {
                var ongoingDeal = OngoingDealComposer.DecomposeOngoingDeal(ongoingDealData);

                DiplomacyCore.SubscribeOngoingDeal(ongoingDeal);
            }
        }