/// <summary> /// Gets a random string from a datachunk string list /// It automatically prevents the same string from being selected twice in a row /// </summary> /// <param name="chunkName"></param> /// <returns></returns> protected string GetRandomStringFromChoices(DataOvlReference.DataChunkName chunkName) { List <string> responses = DataOvlReference.GetDataChunk(chunkName) .GetChunkAsStringList().Strs; // if this hasn't been access before, then lets add a chunk to make sure we don't repeat the same thing // twice in a row if (!_previousRandomSelectionByChunk.ContainsKey(chunkName)) { _previousRandomSelectionByChunk.Add(chunkName, -1); } int nResponseIndex = ShoppeKeeperDialogueReference.GetRandomIndexFromRange(0, responses.Count); // if this response is the same as the last response, then we add one and make sure it is still in bounds // by modding it if (nResponseIndex == _previousRandomSelectionByChunk[chunkName]) { nResponseIndex = (nResponseIndex + 1) % responses.Count; } _previousRandomSelectionByChunk[chunkName] = nResponseIndex; return(responses[nResponseIndex]); }
/// <summary> /// Gets the response string when vendor is trying to sell a particular piece of equipment /// </summary> /// <param name="nGold">how much to charge?</param> /// <param name="equipmentName">the name of the equipment</param> /// <returns>the complete response string</returns> public string GetEquipmentSellingOutput(int nGold, string equipmentName) { int sellStringIndex = ShoppeKeeperDialogueReference.GetRandomIndexFromRange(49, 56); return(ShoppeKeeperDialogueReference.GetMerchantString(sellStringIndex, nGold: nGold, equipmentName: equipmentName)); }