/// <summary>
        /// Invokes the command.
        /// </summary>
        public override void Invoke()
        {
            OnInvoking();
            ClientApplication          ca     = ClientApplication.Instance;
            IDiplomaticTiePicker       picker = (IDiplomaticTiePicker)ca.GetControl(typeof(IDiplomaticTiePicker));
            Collection <DiplomaticTie> ties   = new Collection <DiplomaticTie>();

            foreach (DiplomaticTie t in ca.Player.DiplomaticTies)
            {
                //TODO:  account for needed improvements
                if (t.HasEmbassy)
                {
                    ties.Add(t);
                }
            }
            picker.InitializePicker(ties);
            picker.ShowSimilizationControl();
            this.DiplomaticTie = picker.DiplomaticTie;
            this.City          = this.DiplomaticTie.ForeignCountry.CapitalCity;
            string          text   = string.Empty;
            EspionageResult result = this.DiplomaticTie.StealWorldMap();

            switch (result)
            {
            case EspionageResult.ImmuneToEspionage:
                text = ClientResources.GetString("stealworldmap_immune");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.DiplomaticTie.ForeignCountry.Civilization.Adjective);
                break;

            case EspionageResult.Success:
                text = ClientResources.GetString("stealworldmap_success");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.DiplomaticTie.ForeignCountry.Civilization.Noun);
                break;

            case EspionageResult.Failure:
                text = ClientResources.GetString("stealworldmap_failure");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.City.Name);
                break;

            case EspionageResult.SpyCaught:
                text = ClientResources.GetString("stealworldmap_spycaught");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.City.Name,
                    this.DiplomaticTie.ForeignCountry.Government.LeaderTitle,
                    this.DiplomaticTie.ForeignCountry.LeaderName);
                break;
            }
            OnInvoked();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the <see cref="McKnight.Similization.Server.City"/>, and if necessary,
        /// the <see cref="McKnight.Similization.Server.DiplomaticTie"/> from the user.
        /// </summary>
        protected virtual void SelectCity(string cityPickerTitle)
        {
            ClientApplication ca = ClientApplication.Instance;

            IDiplomaticTiePicker picker = (IDiplomaticTiePicker)ca.GetControl(typeof(IDiplomaticTiePicker));

            picker.PickerTitle = ClientResources.GetString("espionageTiePickerTitle");
            Collection <DiplomaticTie> ties = new Collection <DiplomaticTie>();

            foreach (DiplomaticTie t in ca.Player.DiplomaticTies)
            {
                //TODO:  account for needed improvements
                if (t.HasEmbassy)
                {
                    ties.Add(t);
                }
            }
            picker.InitializePicker(ties);
            picker.ShowSimilizationControl();
            this.tie = picker.DiplomaticTie;

            ICityPicker cityPicker = (ICityPicker)ca.GetControl(typeof(ICityPicker));

            cityPicker.PickerTitle = cityPickerTitle;
            cityPicker.InitializePicker(this.DiplomaticTie.ForeignCountry);
            cityPicker.ShowSimilizationControl();
            this.city = cityPicker.City;
        }
        /// <summary>
        /// Invokes the command.
        /// </summary>
        public override void Invoke()
        {
            OnInvoking();
            ClientApplication    client = ClientApplication.Instance;
            IDiplomaticTiePicker picker = (IDiplomaticTiePicker)client.GetControl(typeof(IDiplomaticTiePicker));

            picker.ShowSimilizationControl();
            DiplomaticTie tie = picker.DiplomaticTie;

            if (tie == null)
            {
                return;
            }

            //get an instance of the diplomacy control
            DiplomacyControl = (IDiplomacyControl)client.GetControl(typeof(IDiplomacyControl));
            IDiplomacyTaskLinkFactory factory = DiplomacyControl.GetTaskLinkFactory();

            //initialize the properties of the control
            DiplomacyControl.DiplomaticTie = tie;

            DiplomacyControl.ForeignLeaderHeaderText = string.Format(
                CultureInfo.InvariantCulture,
                ClientResources.GetString(StringKey.DiplomacyCountryHeader),
                tie.ForeignCountry.Name,
                ClientApplication.GetAttitudeString(tie.Attitude));

            DiplomacyControl.ForeignLeaderPhrase   = AIDiplomacyPhraseHelper.GetForeignLeaderGreeting(tie);
            DiplomacyControl.AdvisorHelpRequested += new EventHandler(HandleAdvisorHelpRequested);
            _advice = DiplomacyAdvice.GetAdvice(tie);
            DiplomacyControl.AdvisorPhrase = _advice[_adviceIndex];

            //get the tasks
            DiplomacyTask[] tasks = DiplomacyHelper.GetDiplomacyTasks(tie, null, null);

            string             taskText;
            DiplomacyCommand   command;
            IDiplomacyTaskLink taskLink;

            //add the tasks to the diplomacy control.
            foreach (DiplomacyTask task in tasks)
            {
                taskText = DiplomacyHelper.GetTaskString(task, tie);
                command  = DiplomacyHelper.GetTaskCommand(task, DiplomacyControl);
                taskLink = factory.CreateTaskLink(taskText, command);
                DiplomacyControl.TaskLinks.Add(taskLink);
            }

            DiplomacyControl.ShowSimilizationControl();
            OnInvoked();
        }
        /// <summary>
        /// Invokes the command.
        /// </summary>
        public override void Invoke()
        {
            OnInvoking();
            ClientApplication    ca     = ClientApplication.Instance;
            IDiplomaticTiePicker picker = (IDiplomaticTiePicker)ca.GetControl(typeof(IDiplomaticTiePicker));

            picker.ShowSimilizationControl();
            DiplomaticTie tie = picker.DiplomaticTie;

            if (tie == null)
            {
                OnCanceled();
                return;
            }
            ICityPicker cityPicker = (ICityPicker)ca.GetControl(typeof(ICityPicker));

            cityPicker.PickerTitle = ClientResources.GetString("investigateCity_cityPickerTitle");
            cityPicker.ShowSimilizationControl();
            City city = cityPicker.City;

            if (city == null)
            {
                OnCanceled();
                return;
            }
            bool   success = tie.InvestigateCity(city);
            string text    = string.Empty;

            if (success)
            {
                text = ClientResources.GetString("investigateCity_success");
                text = string.Format(CultureInfo.CurrentCulture, text, city.Name);
                ca.GameWindow.ShowMessageBox(text, ClientResources.GetString(StringKey.GameTitle));
                ICityControl cityControl = (ICityControl)ca.GetControl(typeof(ICityControl));
                cityControl.Editable = false;
                cityControl.City     = city;
                cityControl.ShowSimilizationControl();
            }
            else
            {
                text = ClientResources.GetString("investigateCity_immune");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    tie.ForeignCountry.Civilization.Adjective);
                ca.GameWindow.ShowMessageBox(text, ClientResources.GetString(StringKey.GameTitle));
            }
            OnInvoked();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Invokes the command.
        /// </summary>
        public override void Invoke()
        {
            OnInvoking();
            ClientApplication    ca     = ClientApplication.Instance;
            IDiplomaticTiePicker picker = (IDiplomaticTiePicker)ca.GetControl(typeof(IDiplomaticTiePicker));

            picker.PickerTitle = ClientResources.GetString("establishEmbassy_tiePickerTitle");
            Collection <DiplomaticTie> ties = new Collection <DiplomaticTie>();

            foreach (DiplomaticTie t in ca.Player.DiplomaticTies)
            {
                //TODO:  account for needed improvements
                if (!t.HasEmbassy)
                {
                    ties.Add(t);
                }
            }
            if (ties.Count == 0)
            {
                string msg = ClientResources.GetString("establishEmbassy_noTies");
                ca.GameWindow.ShowMessageBox(msg, ClientResources.GetString(StringKey.GameTitle));
                OnCanceled();
            }
            picker.InitializePicker(ties);
            picker.ShowSimilizationControl();
            this.tie            = picker.DiplomaticTie;
            this.tie.HasEmbassy = true;
            string text = ClientResources.GetString("establishEmbassy_success");

            text = string.Format(
                CultureInfo.CurrentCulture,
                text,
                ca.Player.Government.LeaderTitle,
                this.tie.ForeignCountry.Civilization.Adjective,
                ClientResources.GetCitySizeString(this.tie.ForeignCountry.CapitalCity.SizeClass),
                this.tie.ForeignCountry.CapitalCity.Name
                );


            ca.GameWindow.ShowMessageBox(text, ClientResources.GetString(StringKey.GameTitle));
            OnInvoked();
        }
        /// <summary>
        /// Invokes the command.
        /// </summary>
        public override void Invoke()
        {
            OnInvoking();
            ClientApplication          ca     = ClientApplication.Instance;
            IDiplomaticTiePicker       picker = (IDiplomaticTiePicker)ca.GetControl(typeof(IDiplomaticTiePicker));
            Collection <DiplomaticTie> ties   = new Collection <DiplomaticTie>();

            foreach (DiplomaticTie t in ca.Player.DiplomaticTies)
            {
                //TODO:  account for needed improvements
                if (t.HasEmbassy)
                {
                    ties.Add(t);
                }
            }
            picker.InitializePicker(ties);
            picker.ShowSimilizationControl();
            this.DiplomaticTie = picker.DiplomaticTie;
            IGameWindow gw       = ClientApplication.Instance.GameWindow;
            bool        canSteal = CheckForStealableTechnologies();

            if (!canSteal)
            {
                string msg = ClientResources.GetString("stealtechnology_noneavailable");
                msg = string.Format(
                    CultureInfo.CurrentCulture,
                    ClientApplication.Instance.Player.Government.LeaderTitle,
                    this.DiplomaticTie.ForeignCountry.Civilization.Noun);
                gw.ShowMessageBox(msg, ClientResources.GetString(StringKey.GameTitle));
                OnCanceled();
            }
            this.City = this.DiplomaticTie.ForeignCountry.CapitalCity;
            EspionageResult result = this.DiplomaticTie.StealTechnology();
            string          text   = string.Empty;

            switch (result)
            {
            case EspionageResult.Failure:
                text = ClientResources.GetString("stealtechnology_failure");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.City.Name);
                break;

            case EspionageResult.ImmuneToEspionage:
                text = ClientResources.GetString("stealtechnology_immune");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.DiplomaticTie.ForeignCountry.Civilization.Adjective);
                break;

            case EspionageResult.SpyCaught:
                text = ClientResources.GetString("stealtechnology_spycaught");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.City.Name,
                    this.DiplomaticTie.ForeignCountry.Government.LeaderTitle,
                    this.DiplomaticTie.ForeignCountry.LeaderName);
                break;

            case EspionageResult.Success:
                text = ClientResources.GetString("stealtechnology_success");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.DiplomaticTie.ForeignCountry.Civilization.Noun);
                break;
            }

            gw.ShowMessageBox(text, ClientResources.GetString(StringKey.GameTitle));
            OnInvoked();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Invokes the command.
        /// </summary>
        public override void Invoke()
        {
            ClientApplication    ca     = ClientApplication.Instance;
            IDiplomaticTiePicker picker = (IDiplomaticTiePicker)ca.GetControl(typeof(IDiplomaticTiePicker));

            picker.PickerTitle = ClientResources.GetString("exposespy_tiePickerTitle");
            Collection <DiplomaticTie> ties = new Collection <DiplomaticTie>();

            foreach (DiplomaticTie t in ca.Player.DiplomaticTies)
            {
                //TODO:  account for needed improvements
                if (t.HasEmbassy)
                {
                    ties.Add(t);
                }
            }
            picker.InitializePicker(ties);
            picker.ShowSimilizationControl();
            this.DiplomaticTie = picker.DiplomaticTie;
            IGameWindow gw = ClientApplication.Instance.GameWindow;

            this.City = this.DiplomaticTie.ForeignCountry.CapitalCity;
            EspionageResult result = this.DiplomaticTie.ExposeSpy();
            string          text   = string.Empty;

            switch (result)
            {
            case EspionageResult.ImmuneToEspionage:
                text = ClientResources.GetString("exposespy_immune");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.DiplomaticTie.ForeignCountry.Government.LeaderTitle,
                    this.DiplomaticTie.ForeignCountry.LeaderName,
                    ClientApplication.Instance.Player.CapitalCity.Name,
                    this.DiplomaticTie.ForeignCountry.Government.LeaderTitle,
                    this.DiplomaticTie.ForeignCountry.LeaderName);
                break;

            case EspionageResult.SpyCaught:
                text = ClientResources.GetString("exposespy_spycaught");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.City.Name,
                    this.DiplomaticTie.ForeignCountry.Government.LeaderTitle,
                    this.DiplomaticTie.ForeignCountry.LeaderName);
                break;

            case EspionageResult.Success:
                text = ClientResources.GetString("exposespy_success");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text, this.DiplomaticTie.ForeignCountry.Government.LeaderTitle,
                    this.DiplomaticTie.ForeignCountry.LeaderName,
                    ClientApplication.Instance.Player.CapitalCity.Name);
                break;

            case EspionageResult.SuccessWithCapturedSpy:
                text = ClientResources.GetString("exposespy_success_spycaught");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    ClientApplication.Instance.Player.CapitalCity.Name,
                    this.DiplomaticTie.ForeignCountry.Government.LeaderTitle,
                    this.DiplomaticTie.ForeignCountry.LeaderName);
                break;
            }

            gw.ShowMessageBox(text, ClientResources.GetString(StringKey.GameTitle));
            OnInvoked();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Invokes the command.
        /// </summary>
        public override void Invoke()
        {
            OnInvoking();
            ClientApplication ca        = ClientApplication.Instance;
            bool hasValidTies           = false;
            IDiplomaticTiePicker picker = (IDiplomaticTiePicker)ca.GetControl(typeof(IDiplomaticTiePicker));

            picker.PickerTitle = ClientResources.GetString("plantSpy_tiePickerTitle");
            Collection <DiplomaticTie> ties = new Collection <DiplomaticTie>();

            foreach (DiplomaticTie t in ca.Player.DiplomaticTies)
            {
                //TODO:  account for needed improvements
                if (t.HasEmbassy)
                {
                    hasValidTies = true;
                    if (!t.HasSpy)
                    {
                        ties.Add(t);
                    }
                }
            }
            if (ties.Count == 0 && hasValidTies)
            {
                //all the valid civs already have spys.
                string msg = ClientResources.GetString("plantSpy_spysExists");
                ca.GameWindow.ShowMessageBox(msg, ClientResources.GetString(StringKey.GameTitle));
                OnCanceled();
                return;
            }
            picker.InitializePicker(ties);
            picker.ShowSimilizationControl();
            this.tie = picker.DiplomaticTie;
            EspionageResult result = this.DiplomaticTie.PlantSpy();
            string          text   = string.Empty;

            switch (result)
            {
            case EspionageResult.Success:
                text = ClientResources.GetString("plantspy_success");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.DiplomaticTie.ForeignCountry.CapitalCity.Name);
                break;

            case EspionageResult.Failure:
                text = ClientResources.GetString("plantspy_failure");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.DiplomaticTie.ForeignCountry.CapitalCity.Name,
                    this.DiplomaticTie.ForeignCountry.Government.LeaderTitle,
                    this.DiplomaticTie.ForeignCountry.LeaderName);
                break;
            }
            IGameWindow gw = ClientApplication.Instance.GameWindow;

            gw.ShowMessageBox(text, ClientResources.GetString(StringKey.GameTitle));
            OnInvoked();
        }