示例#1
0
        public List <string> GetChatMessage(ChatData chatData, Match matchData, string enemyName)
        {
            var responses = chatData.Responses[Random.Next(chatData.Responses.Count)];
            var name      = enemyName;

            if (string.IsNullOrEmpty(name))
            {
                name = "opponent";
            }
            for (var index = 0; index < responses.Count; index++)
            {
                responses[index] = responses[index].Replace("{name}", name).Replace("{match}", matchData.Groups[1].Value);
            }
            return(responses);
        }
示例#2
0
        List <ChatData> LoadDefaultChatData()
        {
            var chatData   = new List <ChatData>();
            var chatFolder = Directory.GetCurrentDirectory() + "/data/chat/default";

            if (Directory.Exists(chatFolder))
            {
                foreach (var fileName in Directory.GetFiles(chatFolder))
                {
                    using (StreamReader file = File.OpenText(fileName))
                    {
                        var data = ChatData.FromJson(file.ReadToEnd());
                        chatData.AddRange(data);
                    }
                }
            }

            for (int index = 0; index < chatData.Count; index++)
            {
                chatData[index].LastResponseFrame = 0;
            }
            return(chatData);
        }