/// <summary>
        /// Gets a culture-specific string appropriate for the given diplomatic
        /// task.
        /// </summary>
        /// <param name="task">The <c>DiplomacyTask</c> the description is for.</param>
        /// <param name="tie">The <c>DiplomaticTie</c> between the two negotiating parties.</param>
        /// <returns>The description of the task.</returns>
        /// <remarks>This will return a random string for the specified task.  Most
        /// tasks have several different strings approprate to the task to make the game
        /// seem less repetitive.</remarks>
        public static string GetTaskString(DiplomacyTask task, DiplomaticTie tie)
        {
            if (tie == null)
            {
                throw new ArgumentNullException("tie");
            }

            if (_resMgr == null)
            {
                InitializeResourceManager();
            }

            string[] taskTexts = null;

            switch (task)
            {
            case DiplomacyTask.ExitDiplomacy:
                taskTexts = DiplomacyStringKey.GetExitDiplomacyStrings();
                break;

            case DiplomacyTask.DeclareWar:
                taskTexts = DiplomacyStringKey.GetDeclareWarStrings();
                break;

            case DiplomacyTask.AutoRetreatTroops:
                taskTexts = DiplomacyStringKey.GetAutoRetreatTroopsStrings();
                break;

            case DiplomacyTask.ProposeNegotiation:
                taskTexts = DiplomacyStringKey.GetProposeNegotiationStrings();
                break;

            case DiplomacyTask.TradeWorldMaps:
                taskTexts = DiplomacyStringKey.GetTradeWorldMapsStrings();
                break;

            case DiplomacyTask.BackOutFromNegotiation:
                taskTexts = DiplomacyStringKey.GetBackOutFromNegotiationStrings();
                break;

            case DiplomacyTask.PassiveRetreatTroops:
                taskTexts = DiplomacyStringKey.GetPassiveRetreatTroopsStrings();
                break;

            case DiplomacyTask.RefuseTribute:
                taskTexts = DiplomacyStringKey.GetRefuseTributeStrings();
                break;

            case DiplomacyTask.GiveTribute:
                taskTexts = DiplomacyStringKey.GetGiveTributeStrings();
                break;

            case DiplomacyTask.ThreatenWarForBorderInvasion:
                taskTexts = DiplomacyStringKey.GetThreatenWarForBorderInvasionStrings();
                break;

            case DiplomacyTask.WarningForBorderInvasion:
                taskTexts = DiplomacyStringKey.GetWarningForBorderInvasionStrings();
                break;

            case DiplomacyTask.OfferRightOfPassage:
                taskTexts = DiplomacyStringKey.GetOfferRightOfPassageStrings();
                break;

            case DiplomacyTask.OfferPeaceTreatyDuringWar:
                taskTexts = DiplomacyStringKey.GetOfferPeaceTreatyDuringWarStrings();
                break;

            case DiplomacyTask.OfferPeaceTreatyCityInvasion:
                taskTexts = DiplomacyStringKey.GetOfferPeaceTreatyCityInvasionStrings();
                break;

            case DiplomacyTask.AskForLoan:
                taskTexts = DiplomacyStringKey.GetAskForLoanStrings();
                break;

            case DiplomacyTask.PresentEvenUpTrade:
                taskTexts = DiplomacyStringKey.GetUserOfferStrings();
                break;

            case DiplomacyTask.PresentGiftTrade:
                taskTexts = DiplomacyStringKey.GetUserGiftStrings();
                break;

            case DiplomacyTask.DemandTribute:
                taskTexts = DiplomacyStringKey.GetDemandTributeStrings();
                break;

            case DiplomacyTask.AskForCounter:
                taskTexts = DiplomacyStringKey.GetAskForCounterofferStrings();
                break;

            case DiplomacyTask.AskForExchange:
                taskTexts = DiplomacyStringKey.GetAskForExchangeStrings();
                break;
            }

            int    idx    = RandomNumber.GetRandomNumber(taskTexts.GetUpperBound(0));
            string phrase = GetString(taskTexts[idx]);

            phrase = phrase.Replace("$LEADER0", tie.ForeignCountry.LeaderName);

            return(phrase);
        }
        private void HandleTradeProposalChange(object sender, CollectionChangeEventArgs e)
        {
            TradeResponse probableResponse = GetProbableResponse();

            DiplomacyControl.AdvisorPhrase = DiplomacyHelper.GetProbableTradeResponseString(probableResponse);

            DiplomacyControl.TaskLinks.Clear();

            bool gift = (DiplomacyControl.GivenItems.Count > 0) && (DiplomacyControl.TakenItems.Count == 0);

            IDiplomacyTaskLinkFactory factory = DiplomacyControl.GetTaskLinkFactory();
            IDiplomacyTaskLink        taskLink;
            string taskText;
            int    randIndex;

            //add the backout task
            string[] backoutStrings = DiplomacyStringKey.GetBackOutFromNegotiationStrings();
            randIndex = RandomNumber.GetRandomNumber(backoutStrings.GetUpperBound(0));
            taskText  = DiplomacyHelper.GetString(backoutStrings.GetValue(randIndex).ToString());
            taskLink  = factory.CreateTaskLink(taskText, DiplomacyHelper.GetTaskCommand(DiplomacyTask.BackOutFromNegotiation, DiplomacyControl));
            DiplomacyControl.TaskLinks.Add(taskLink);

            if (gift)
            {
                //gift
                string[] giftStrings = DiplomacyStringKey.GetUserGiftStrings();
                randIndex = RandomNumber.GetRandomNumber(giftStrings.GetUpperBound(0));
                taskText  = DiplomacyHelper.GetString(giftStrings.GetValue(randIndex).ToString());
                taskLink  = factory.CreateTaskLink(taskText, new OfferGiftCommand());
                DiplomacyControl.TaskLinks.Add(taskLink);

                //trade for item
                string[] tradeStrings = DiplomacyStringKey.GetAskForExchangeStrings();
                randIndex = RandomNumber.GetRandomNumber(tradeStrings.GetUpperBound(0));
                taskText  = DiplomacyHelper.GetString(tradeStrings.GetValue(randIndex).ToString());
                taskLink  = factory.CreateTaskLink(taskText, new AskForExchangeCommand());
                DiplomacyControl.TaskLinks.Add(taskLink);

                return;
            }

            bool evenUp = (DiplomacyControl.GivenItems.Count > 0) && (DiplomacyControl.TakenItems.Count > 0);

            if (evenUp)
            {
                //offer trade
                string[] offerStrings = DiplomacyStringKey.GetUserOfferStrings();
                randIndex = RandomNumber.GetRandomNumber(offerStrings.GetUpperBound(0));
                taskText  = DiplomacyHelper.GetString(offerStrings.GetValue(randIndex).ToString());
                taskLink  = factory.CreateTaskLink(taskText, new OfferEvenUpTradeCommand());
                DiplomacyControl.TaskLinks.Add(taskLink);
                return;
            }

            //demand tribute
            string[] tributeStrings = DiplomacyStringKey.GetDemandTributeStrings();
            randIndex = RandomNumber.GetRandomNumber(tributeStrings.GetUpperBound(0));
            taskText  = DiplomacyHelper.GetString(tributeStrings.GetValue(randIndex).ToString());
            taskLink  = factory.CreateTaskLink(taskText, new DemandTributeCommand());
            DiplomacyControl.TaskLinks.Add(taskLink);

            //ask for counter
            string[] counterOfferStrings = DiplomacyStringKey.GetAskForExchangeStrings();
            randIndex = RandomNumber.GetRandomNumber(counterOfferStrings.GetUpperBound(0));
            taskText  = DiplomacyHelper.GetString(counterOfferStrings.GetValue(randIndex).ToString());
            taskLink  = factory.CreateTaskLink(taskText, new AskForCounterofferCommand());
            DiplomacyControl.TaskLinks.Add(taskLink);
        }