package com.qiwuai.garden.common.utils; import com.qiwuai.garden.common.TimingAcquisition; import java.util.List; import java.util.Map; public class SpeechUtil { /** * 从种植模块话术获取话术 * @param someone * @param feedText * @return String */ public static String getPlantSpeech(String someone, String feedText) { String result = ""; List speech = TimingAcquisition.plantSpeechMap.get(someone).get(feedText); Integer i = RandomDropUtil.getRandomNum(0, speech.size()); result = speech.get(i); return result; } /** * 从园丁模块话术获取话术 * @param someone * @param feedText * @return String */ public static String getGardenerSpeech(String someone, String feedText) { String result = ""; List speech = TimingAcquisition.gardenerSpeechMap.get(someone).get(feedText); Integer i = RandomDropUtil.getRandomNum(0, speech.size()); result = speech.get(i); return result; } /** * 从宠物模块话术获取话术 * @param someone * @param feedText * @return String */ public static String getPetSpeech(String someone, String feedText) { String result = ""; List speech = TimingAcquisition.petSpeechMap.get(someone).get(feedText); Integer i = RandomDropUtil.getRandomNum(0, speech.size()); result = speech.get(i); return result; } /** * 从市场模块话术获取话术 * @param someone * @param feedText * @return String */ public static String getMarketSpeech(String someone, String feedText) { String result = ""; List speech = TimingAcquisition.marketSpeechMap.get(someone).get(feedText); Integer i = RandomDropUtil.getRandomNum(0, speech.size()); result = speech.get(i); return result; } /** * 从社交模块话术获取话术 * @param someone * @param feedText * @return String */ public static String getSocialSpeech(String someone, String feedText) { String result = ""; List speech = TimingAcquisition.socialSpeechMap.get(someone).get(feedText); Integer i = RandomDropUtil.getRandomNum(0, speech.size()); result = speech.get(i); return result; } /** * 从任务模块话术获取话术 * @param someone * @param feedText * @return String */ public static String getTaskSpeech(String someone, String feedText) { String result = ""; List speech = TimingAcquisition.taskSpeechMap.get(someone).get(feedText); Integer i = RandomDropUtil.getRandomNum(0, speech.size()); result = speech.get(i); return result; } /** * 替换话术中的一个数字 * @param one * @return String */ public static String speechReplaceNum(String text, String one) { return text.replace("【1】", one); } /** * 替换话术中的两个数字 * @param one * @param two * @return String */ public static String speechReplaceNum(String text, String one, String two) { return text.replace("【1】", one).replace("【2】", two); } /** * 替换话术中的三个数字 * @param one * @param two * @param three * @return String */ public static String speechReplaceNum(String text, String one, String two, String three) { return text.replace("【1】", one).replace("【2】", two).replace("【3】", three); } /** * 替换话术中的四个数字 * @param one * @param two * @param three * @param four * @return String */ public static String speechReplaceNum(String text, String one, String two, String three, String four) { return text.replace("【1】", one).replace("【2】", two).replace("【3】", three).replace("【4】", four); } /** * 替换话术中的五个数字 * @param one * @param two * @param three * @param four * @param five * @return String */ public static String speechReplaceNum(String text, String one, String two, String three, String four, String five) { return text.replace("【1】", one).replace("【2】", two).replace("【3】", three) .replace("【4】", four).replace("【5】", five); } /** * 替换话术中的六个数字 * @param one * @param two * @param three * @param four * @param five * @param six * @return String */ public static String speechReplaceNum(String text, String one, String two, String three, String four, String five, String six) { return text.replace("【1】", one).replace("【2】", two).replace("【3】", three) .replace("【4】", four).replace("【5】", five).replace("【6】", six); } /** * 替换话术中的七个数字 * @param one * @param two * @param three * @param four * @param five * @param six * @param seven * @return String */ public static String speechReplaceNum(String text, String one, String two, String three, String four, String five, String six, String seven) { return text.replace("【1】", one).replace("【2】", two).replace("【3】", three) .replace("【4】", four).replace("【5】", five).replace("【6】", six).replace("【7】", seven); } public static void main(String[] args) { String s = "我已经按照你的吩咐,在【1】花圃种上了【2】植物。"; System.out.println("转化结果:" + speechReplaceNum(s, "2")); } }