Commit 1b803042 by 周君强

1.建议系统初步实现

parent 882e0bb4
......@@ -933,7 +933,7 @@ public class TimingAcquisition {
feedText.deleteCharAt(feedText.length() - 1);
//获取对应话术
text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "goods_check_type_success");
text = SpeechUtil.speechReplaceNum(text, itemLevelName, itemAttribute, itemType, String.valueOf(size), feedText.toString());
text = SpeechUtil.speechReplaceNum(text, itemLevelName, itemAttribute, itemType, String.valueOf(itemIdList.size()), feedText.toString());
text += SpeechUtil.getMarketSpeech(gender, "goods_check_type_success");
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
resultResponse.set后台附加返回("查看商品回复2");
......
......@@ -56,6 +56,33 @@ public class HttpUtil {
log.info(phraseName + "的动态词组更新结果:" + forObject.getBody());
}
//更新动态词组
public static void doPutCrazyGardener(String phraseName, String phraseContent) {
RestTemplate template = new RestTemplate();
//获取时间戳
long timestamp = System.currentTimeMillis();
//签名
String authorization = DigestUtils.md5Hex(appSecret + ":" + timestamp);
//设置请求体
PhraseRequest phraseRequest = new PhraseRequest();
phraseRequest.setWorkName("园丁也疯狂");
phraseRequest.setPhraseName(phraseName);
phraseRequest.setPhraseContent(phraseContent);
JSONObject object = new JSONObject();
object.put("workName", "园丁也疯狂");
object.put("phraseName", phraseName);
object.put("phraseContent", phraseContent);
//设置请求头
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.set("Content-Type", "application/json;charset=utf-8");
httpHeaders.set("Timestamp", String.valueOf(timestamp));
httpHeaders.set("Authorization", authorization);
HttpEntity<JSONObject> request = new HttpEntity<>(object, httpHeaders);
ResponseEntity<PhraseResponse> forObject = template.exchange(updatePhraseUrl, HttpMethod.PUT, request, PhraseResponse.class);
log.info("《园丁也疯狂》" + phraseName + "的动态词组更新结果:" + forObject.getBody());
}
//获取app用户关联id
public static List<Object> getInviteUid(String uid) {
RestTemplate template = new RestTemplate();
......
......@@ -105,6 +105,20 @@ public class SpeechUtil {
}
/**
* 从建议模块话术获取话术
* @param someone
* @param feedText
* @return String
*/
public static String getAdviseSpeech(String someone, String feedText) {
String result = "";
List<String> speech = TimingAcquisition.adviseSpeechMap.get(someone).get(feedText);
Integer i = RandomDropUtil.getRandomNum(0, speech.size());
result = speech.get(i);
return result;
}
/**
* 替换话术中的一个数字
* @param one
* @return String
......
......@@ -716,6 +716,9 @@ public class CommonController {
case "建议指令":
result = adviseServiceProxy.adviseWithout(operationReq);
break;
case "种植建议指令":
result = adviseServiceProxy.adviseByPlant(operationReq);
break;
}
log.info(operationReq.getUid() + "已完成操作:【" + commonRequest.getVars().get操作名() + "】");
return result;
......
......@@ -63,7 +63,7 @@ public class BackPackDto {
itemBags.put(id, itemBag); //id对应背包中装不同物品类型id的袋子编号
}
public ItemBagDto get(int i) {
public ItemBagDto get(Integer i) {
return itemBags.get(i);
}
}
package com.qiwuai.garden.dto;
import lombok.Data;
@Data
public class FruitToNurseryDto {
/**
* 花圃编号
*/
private Integer nurseryNum;
/**
* 果实id
*/
private Integer fruitId;
/**
* 所需果实数量
*/
private Integer fruitNum;
}
......@@ -5,10 +5,7 @@ import com.qiwuai.garden.common.TimingAcquisition;
import com.qiwuai.garden.common.utils.AdviseUtil;
import com.qiwuai.garden.common.utils.SpeechUtil;
import com.qiwuai.garden.common.utils.TypeConvertUtil;
import com.qiwuai.garden.dto.BackPackDto;
import com.qiwuai.garden.dto.ItemBagDto;
import com.qiwuai.garden.dto.ItemDto;
import com.qiwuai.garden.dto.NurseryInfoDto;
import com.qiwuai.garden.dto.*;
import com.qiwuai.garden.dto.base.CommonResponse;
import com.qiwuai.garden.dto.base.ResultResponse;
import com.qiwuai.garden.dto.base.ResultVarsResponse;
......@@ -42,7 +39,7 @@ public class AdviseServiceImpl implements AdviseService {
//园丁等级满级
if (gardenerLevel >= gardenerLevelMax) {
//获取对应话术
String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "current_status_advise_success");
String text = SpeechUtil.getAdviseSpeech(Constants.SPEECH_ASIDE, "current_status_advise_success");
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(900101);
......@@ -74,6 +71,7 @@ public class AdviseServiceImpl implements AdviseService {
if (task.getEventId() == Constants.SEEDING_EVENT) {
if (eventCont < task.getTimes()) {
//进入种植植物判定
}
}
//2.收获事件对应的任务
......@@ -145,7 +143,7 @@ public class AdviseServiceImpl implements AdviseService {
}
}
//获取对应话术
String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "current_status_advise_success");
String text = SpeechUtil.getAdviseSpeech(Constants.SPEECH_ASIDE, "current_status_advise_success");
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(900101);
......@@ -164,10 +162,24 @@ public class AdviseServiceImpl implements AdviseService {
String uid = operationReq.getUid();
Integer plantId = operationReq.getPlantId();
log.info(uid + "根据指定植物" + plantId + "来提供建议");
//通过植物id找到能种植的空闲花圃
List<Integer> nurseryNumList = AdviseUtil.findFreeNurseryNumsByPlantId(uid, plantId);
//没有可种植该植物的空闲花圃
if (nurseryNumList.size() == 0) {
//根据植物id找到玩家能种植的所有花圃
List<Integer> nurseryNumList = AdviseUtil.findAllNurseryNumsByPlantId(uid, plantId);
//玩家有可种植该植物的花圃
if (nurseryNumList.size() != 0) {
for (Integer nurseryNum : nurseryNumList) {
NurseryInfoDto nurseryInfo = TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos().get(nurseryNum);
//花圃为空
if (StringUtils.isEmpty(nurseryInfo.getPlantId())) {
//果实和材料数量是否足够
boolean isItemEnough = AdviseUtil.checkPlantItems(uid, nurseryNum, plantId);
//数量足够
if (isItemEnough) {
//存在伴生宠物
}
}
}
} else { //玩家没有可种植该植物的花圃
//--------走其他植物的种植流程---------
//找到花圃等级升序的空闲花圃
List<Integer> freeNurseryNumList = AdviseUtil.findFreeNurseryNum(uid);
......@@ -180,7 +192,7 @@ public class AdviseServiceImpl implements AdviseService {
//存在可以种植的植物
if (plantIdList.size() != 0) {
//检查玩家是否有可种植的果实和材料
AdviseUtil.checkPlantItems(uid, nurseryNum, plantIdList.get(0));
boolean isPlant = AdviseUtil.checkPlantItems(uid, nurseryNum, plantIdList.get(0));
}
} else {
//不存在空闲花圃,查找是否有成熟植物的花圃,有则建议收取
......@@ -194,7 +206,7 @@ public class AdviseServiceImpl implements AdviseService {
}
}
//获取对应话术
String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "current_status_advise_success");
String text = SpeechUtil.getAdviseSpeech(Constants.SPEECH_ASIDE, "current_status_advise_success");
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(900101);
......
......@@ -5,6 +5,7 @@ import com.qiwuai.garden.common.Constants;
import com.qiwuai.garden.common.TimingAcquisition;
import com.qiwuai.garden.common.utils.PersistenceUtil;
import com.qiwuai.garden.common.utils.SpeechUtil;
import com.qiwuai.garden.dto.BackPackDto;
import com.qiwuai.garden.dto.GardenerDto;
import com.qiwuai.garden.dto.ItemBagDto;
import com.qiwuai.garden.dto.ItemDto;
......@@ -135,6 +136,12 @@ public class BackPackServiceImpl implements BackPackService {
//获取背包中的所有袋子
Map<Integer, ItemBagDto> itemBags = TimingAcquisition.gardenerMap.get(uid).getBackPack().getItemBags();
//根据种类id取出背包里的对应袋子
ItemBagDto itemBag = itemBags.get(itemTypeId);
//背包中没有该种类,则新增袋子
if (StringUtils.isEmpty(itemBag)) {
itemBag = new ItemBagDto(); //定义背包里新的袋子
TimingAcquisition.gardenerMap.get(uid).getBackPack().add(itemTypeId, itemBag);
}
Map<Integer, ItemDto> bag = itemBags.get(itemTypeId).getItemBag();
StringBuilder feedText = new StringBuilder();
//种类对应物品为空
......
......@@ -220,6 +220,7 @@ public class GardenerServiceImpl implements GardenerService {
}
String address = String.join("+", playerList);
HttpUtil.doPut("项目词组玩家地址", address);
HttpUtil.doPutCrazyGardener("项目词组玩家地址", address);
}
//玩家初始宠物id
String initialPet = TimingAcquisition.systemConfigMap.get("initial_pet").getValue();
......
......@@ -1257,7 +1257,7 @@ public class MarketServiceImpl implements MarketService {
}
//获取对应话术
String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "goods_check_type_success");
text = SpeechUtil.speechReplaceNum(text, itemLevelName, itemAttribute, itemType, String.valueOf(size), feedText.toString());
text = SpeechUtil.speechReplaceNum(text, itemLevelName, itemAttribute, itemType, String.valueOf(itemIdList.size()), feedText.toString());
text += SpeechUtil.getMarketSpeech(gender, "goods_check_type_success");
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
......
......@@ -2233,6 +2233,9 @@ public class PetServiceImpl implements PetService {
NurseryInfoDto nurseryInfo = TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos().get(nurseryNum);
nurseryInfo.setPetField(petId);
nurseryInfo.setPetCheck(Constants.PET_UNCHECK);
//----------获得宠物累计次数加1---------------
Map<Integer, Integer> taskCountMap = TimingAcquisition.gardenerMap.get(uid).getTaskCountMap();
taskCountMap.put(Constants.GET_PET_EVENT, taskCountMap.get(Constants.GET_PET_EVENT) + 1);
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(301004);
......
......@@ -246,12 +246,13 @@ public class PlantServiceImpl implements PlantService {
//获取对应话术
text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "plant_fail_planted_hava_free");
text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.plantMap.get(nurseryInfo.getPlantId()).getName(), nurseryText);
text += SpeechUtil.getPlantSpeech(gender, "plant_fail_planted_hava_free");
} else {
//获取对应话术
text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "plant_fail_planted_no_free");
text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.plantMap.get(nurseryInfo.getPlantId()).getName());
text += SpeechUtil.getPlantSpeech(gender, "plant_fail_planted_no_free");
}
text += SpeechUtil.getPlantSpeech(gender, "plant_fail_planted");
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
......@@ -1372,6 +1373,11 @@ public class PlantServiceImpl implements PlantService {
String gender = TimingAcquisition.getGardenerGender(uid);
int count = 0;
TaskResultDto taskResult = new TaskResultDto();
if (!StringUtils.isEmpty(nurseryNum)) {
if (nurseryNum == Constants.REQ_ALL) {
nurseryNum = null;
}
}
//玩家称呼
CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid);
//1.仅指定植物id的情况下-“收取某植物的果子”
......@@ -1805,7 +1811,7 @@ public class PlantServiceImpl implements PlantService {
//4.指定花圃id和植物id-“收取某花圃的某某果实”
//获取花圃类型id
Integer nurseryId = nurseryInfoMap.get(nurseryNum).getId();
// Integer nurseryId = nurseryInfoMap.get(nurseryNum).getId();
//获取指定花圃的信息
NurseryInfoDto nurseryInfo = nurseryInfoMap.get(nurseryNum);
if (nurseryInfo.getUsable() == Constants.NURSERY_UNUSABLE) {
......@@ -1821,7 +1827,7 @@ public class PlantServiceImpl implements PlantService {
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
PlantPojo plantConfig = TimingAcquisition.plantMap.get(plantId);
// PlantPojo plantConfig = TimingAcquisition.plantMap.get(plantId);
//花圃未种植植物
if (StringUtils.isEmpty(nurseryInfo.getPlantId())) {
//获取对应话术
......@@ -2485,6 +2491,7 @@ public class PlantServiceImpl implements PlantService {
commonResponse.setMsg("成功");
resultResponse.set反馈ID(101202);
resultResponse.set反馈文本(text);
resultResponse.set后台附加返回("查看植物成熟时间回复3");
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
......@@ -2571,6 +2578,7 @@ public class PlantServiceImpl implements PlantService {
commonResponse.setMsg("成功");
resultResponse.set反馈ID(101202);
resultResponse.set反馈文本(text);
resultResponse.set后台附加返回("查看植物成熟时间回复3");
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
......@@ -2695,6 +2703,7 @@ public class PlantServiceImpl implements PlantService {
commonResponse.setMsg("成功");
resultResponse.set反馈ID(101202);
resultResponse.set反馈文本(text);
resultResponse.set后台附加返回("查看植物成熟时间回复3");
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
......
......@@ -255,10 +255,12 @@ man:
- 【男园丁@正常】真遗憾,看来我们需要去找找植物果实了。
- 【男园丁@正常】找到植物果实再来种植吧。
- 【男园丁@正常】看来需要去丰富库存,采购植物果实储备了。
plant_fail_planted:
plant_fail_planted_hava_free:
- 【男园丁@正常】不如我们换其他{花圃称呼}种植吧?
- 【男园丁@正常】可以换另一块{花圃称呼}种植。
- 【男园丁@正常】看看别的空闲{花圃称呼}吧。
plant_fail_planted_no_free:
- 【男园丁@正常】【1】,现在暂时没有{花圃称呼}可种,等有{花圃称呼}空闲了再试试吧。
plant_fail_nursery_level:
- 【男园丁@正常】【1】,看来我们还需要再接再厉,努力升级啊!
- 【男园丁@正常】{花圃称呼}的等级还是太低了……【1】,我们要一起努力升级啊。
......@@ -467,10 +469,12 @@ woman:
- 【女园丁@正常】晕……居然是没有库存了,我们再去买点吧。
- 【女园丁@正常】去市场买点植物果实再来种植吧【1】!
- 【女园丁@正常】我们的库存竟然已经这么少了吗?快去买点吧【1】!
plant_fail_planted:
plant_fail_planted_hava_free:
- 【女园丁@正常】【1】,我们之前已经在这块{花圃称呼}上种了别的植物了,换一块试试吧!
- 【女园丁@正常】找一找空闲的{花圃称呼}吧。
- 【女园丁@正常】我们还有其他的{花圃称呼}啊!再去种植试试吧!
plant_fail_planted_no_free:
- 【女园丁@正常】【1】太勤奋了,所有{花圃称呼}都已经种满了耶。
plant_fail_nursery_level:
- 【女园丁@正常】我们的{花圃称呼}等级还差一点点就够升级了……主要我会陪【2】一起加油升级的!
- 【女园丁@正常】不要灰心!我会陪着【1】一起给{花圃称呼}升级的!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment