private static string GetAdvisorText() { string text = string.Empty; ClientApplication client = ClientApplication.Instance; Country player = client.Player; if (player.Government.Fallback) { text = ClientResources.GetString("domesticAdvisor_anarchy"); } else { if (RandomNumber.GetRandomNumber(10) > 5) { //tell them we need more cities. text = ClientResources.GetString("domesticAdvisor_needCities"); } else { //say something about a city. int count = player.Cities.Count; int idx = RandomNumber.GetRandomNumber(count - 1); City city = client.Player.Cities[idx]; string format = ClientResources.GetString("domesticAdvisor_cityHappiness"); text = string.Format(CultureInfo.CurrentCulture, format, player.Government.LeaderTitle, city.Name, ""); } } return(text); }
private static string GetPeaceGreeting(DiplomaticTie tie) { if(tie == null) throw new ArgumentNullException("tie"); int index = RandomNumber.GetRandomNumber(47); index++; //make it 1 based. string key = "peaceGreeting" + index.ToString(CultureInfo.InvariantCulture); InitializeResourceManager(); string phrase = _resMgr.GetString(key); Country me = ClientApplication.Instance.Player; Country you = tie.ForeignCountry; phrase = phrase.Replace("$PLAYER0", me.LeaderName); phrase = phrase.Replace("$CIVNAME1", me.Civilization.Name); phrase = phrase.Replace("$CIVADJ2", me.Civilization.Adjective); phrase = phrase.Replace("$AI3", you.LeaderName); phrase = phrase.Replace("$CIVNAME4", you.Civilization.Name); phrase = phrase.Replace("$CIVADJ5", you.Civilization.Adjective); phrase = phrase.Replace("$CIVADJ6", you.Civilization.Noun); return phrase; }
/// <summary> /// Gets a phrase that the AI player will say when the human player backs out from proposing /// a trade. /// </summary> /// <returns>The ai phrase.</returns> public static string GenerateBackOutResponse() { int index = RandomNumber.GetRandomNumber(42); InitializeResourceManager(); string key = "whatever" + index.ToString(CultureInfo.InvariantCulture); string phrase = _resMgr.GetString(key); return phrase; }
/// <summary> /// Gets a phrase that the AI player will say when a trade is initially proposed to them. /// </summary> /// <returns>The ai phrase.</returns> public static string GetProposalResponse(DiplomaticTie tie) { if(tie == null) throw new ArgumentNullException("tie"); int index = RandomNumber.GetRandomNumber(22); index++; //make it 1 based string key = "proposalResponse" + index.ToString(CultureInfo.InvariantCulture); Country us = ClientApplication.Instance.Player; InitializeResourceManager(); string phrase = _resMgr.GetString(key); phrase = phrase.Replace("$PLAYER0", us.LeaderName); phrase = phrase.Replace("$CIVNAME1", us.Civilization.Name); phrase = phrase.Replace("$CIVADJ2", us.Civilization.Adjective); return phrase; }
/// <summary> /// Gets the phrase that the Ai will speak during first contact. /// </summary> /// <param name="tie">The newly created diplomatic tie.</param> /// <returns>A <c>string</c> containing the spoken phrase.</returns> public static string GetFirstContactPhrase(DiplomaticTie tie) { if(tie == null) throw new ArgumentNullException("tie"); int index = RandomNumber.GetRandomNumber(15); index++; //make it 1 based string key = "firstContact" + index.ToString(CultureInfo.InvariantCulture); InitializeResourceManager(); string phrase = _resMgr.GetString(key); phrase = phrase.Replace("$AI0", tie.ForeignCountry.LeaderName); phrase = phrase.Replace("$CIVNAME1", tie.ForeignCountry.Civilization.Name); phrase = phrase.Replace("$CIVADJ2", tie.ForeignCountry.Civilization.Adjective); phrase = phrase.Replace("$CIVADJ3", tie.ForeignCountry.Civilization.Noun); return phrase; }
private static string GetAllianceGreeting(DiplomaticTie tie) { if(tie == null) throw new ArgumentNullException("tie"); int index = RandomNumber.GetRandomNumber(47); index++; //make it 1 based. string key = "allianceGreeting" + index.ToString(CultureInfo.InvariantCulture); InitializeResourceManager(); string phrase = _resMgr.GetString(key); Country me = ClientApplication.Instance.Player; Country you = tie.ForeignCountry; //grab the correct alliance treaty from the tie. MilitaryAlliance alliance = null; foreach(DiplomaticAgreement agreement in tie.DiplomaticAgreements) { MilitaryAlliance militaryAlliance = agreement as MilitaryAlliance; if(militaryAlliance != null) { alliance = militaryAlliance; break; } } phrase = phrase.Replace("$PLAYER0", me.LeaderName); phrase = phrase.Replace("$CIVNAME1", me.Civilization.Name); phrase = phrase.Replace("$CIVADJ2", me.Civilization.Adjective); phrase = phrase.Replace("$CIVNAME3", alliance.AllianceVictim.Civilization.Name); phrase = phrase.Replace("$CIVADJ4", alliance.AllianceVictim.Civilization.Adjective); phrase = phrase.Replace("CIVNOUN5", me.Civilization.Noun); phrase = phrase.Replace("$AI6", you.LeaderName); phrase = phrase.Replace("$CIVNAME7", you.Civilization.Name); phrase = phrase.Replace("$CIVADJ8", you.Civilization.Adjective); phrase = phrase.Replace("$CIVADJ9", you.Civilization.Noun); return phrase; }
/// <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); }