예제 #1
0
        internal override void CaptureSpy(DiplomaticTie diplomaticTie, EspionageAction espionageAction, bool espionageCompleted, City city)
        {
            base.CaptureSpy(diplomaticTie, espionageAction, espionageCompleted, city);

            //find the associated diplomaticTie
            Country       enemy = diplomaticTie.ParentCountry;
            DiplomaticTie tie   = GetDiplomaticTie(enemy);

            tie.Attitude = Attitude.Furious;

            //we may want to declare war here.
            double us   = Convert.ToDouble(this.PowerFactor);
            double them = Convert.ToDouble(enemy.PowerFactor);

            if (them == 0.0d)
            {
                DeclareWar(enemy);
                return;
            }

            double ratio = us / them;

            if (ratio >= .75d)
            {
                DeclareWar(enemy);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SpyCapturedEventArgs"/> class.
 /// </summary>
 /// <param name="diplomaticTie"></param>
 /// <param name="espionageAction"></param>
 /// <param name="espionageCompleted"></param>
 /// <param name="city"></param>
 public SpyCapturedEventArgs(DiplomaticTie diplomaticTie, EspionageAction espionageAction, bool espionageCompleted, City city)
 {
     this.diplomaticTie      = diplomaticTie;
     this.espionageCompleted = espionageCompleted;
     this.espionageAction    = espionageAction;
     this.city = city;
 }
예제 #3
0
        /// <summary>
        /// Does any needed wartime negotiation.  Calling this function
        /// will not neccessairily result in wartime negotiation, it depends
        /// on country types, country needs, etc...
        /// </summary>
        /// <param name="foreignCountry">The foreign colony to negotiate with</param>
        protected virtual void DoWartimeNegotiation(Country foreignCountry)
        {
            if (foreignCountry == null)
            {
                throw new ArgumentNullException("foreignCountry");
            }

            DiplomaticTie diplomaticTie = null;

            foreach (DiplomaticTie tie in DiplomaticTies)
            {
                if (tie.ForeignCountry == foreignCountry)
                {
                    diplomaticTie = tie;
                    break;
                }
            }

            if (diplomaticTie == null)
            {
                return;
            }

            if (diplomaticTie.DiplomaticState != DiplomaticState.War)
            {
                return;
            }

            CulturalPerception perception = GetCulturalPerception(foreignCountry);

            switch (perception)
            {
            case CulturalPerception.Admirer:
                break;

            case CulturalPerception.Disdainful:
                break;

            case CulturalPerception.Dismissive:
                break;

            case CulturalPerception.Impressed:
                break;

            case CulturalPerception.InAwe:
                break;

            case CulturalPerception.Unimpressed:
                break;
            }
        }
예제 #4
0
        private void HandleUnitCollectionChange(object sender, CollectionChangeEventArgs e)
        {
            if (e.Action != CollectionChangeAction.Add)
            {
                return;
            }

            Unit unit     = (Unit)e.Element;
            bool invasion = false;

            if (this.Owner != null)
            {
                if (unit.ParentCountry != this.Owner)
                {
                    Country       owner = (Country)this.Owner;
                    DiplomaticTie tie   = owner.GetDiplomaticTie(unit.ParentCountry);
                    if (tie != null)
                    {
                        invasion = true;
                        foreach (DiplomaticAgreement agreement in tie.DiplomaticAgreements)
                        {
                            if (agreement.GetType() == typeof(RightOfPassage))
                            {
                                invasion = false;
                                break;
                            }
                        }
                    }
                    else
                    {
                        invasion = true;
                    }
                }
            }

            if (invasion)
            {
                //TODO: should we notify non-ai players at all?
                if (this.Owner.GetType() == typeof(AICountry))
                {
                    ((AICountry)this.Owner).NotifyOfInvasion(unit, this);
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Notifies the <c>AICountry</c> that a unit has invaded their territory.
        /// </summary>
        /// <param name="invader">The <c>Unit</c> that has invaded the territory of
        /// the <c>AICountry</c>.</param>
        /// <param name="location">The <c>GridCell</c> that was invaded.</param>
        /// <remarks>The <c>AICountry</c> will not always respond to such an invasion,
        /// especially if the invader has a right of passage treaty with the AI Country.
        /// However, if the two countries have diplomatic ties, the host country will
        /// usually issue a warning to the invader.</remarks>
        public void NotifyOfInvasion(Unit invader, GridCell location)
        {
            if (invader == null)
            {
                throw new ArgumentNullException("invader");
            }
            if (location == null)
            {
                throw new ArgumentNullException("location");
            }

            Country       parent = invader.ParentCountry;
            DiplomaticTie tie    = GetDiplomaticTie(parent);

            if (tie == null)
            {
                parent.RequestAudience(this);
            }
        }