Commit 453f64c4 by 周君强

1.排行榜模块实现;

parent 26a780a3
...@@ -540,6 +540,19 @@ public class Constants { ...@@ -540,6 +540,19 @@ public class Constants {
*/ */
public static final String HELP_FRIEND_OPERATE = "帮助好友"; public static final String HELP_FRIEND_OPERATE = "帮助好友";
/**
* 财富榜
*/
public static final String MONEY_RANKING = "财富榜";
/**
* 战斗榜
*/
public static final String FIGHT_RANKING = "偷菜榜";
/**
* 友情榜
*/
public static final String FRIENDSHIP_RANKING = "友情榜";;
/** /**
* 翻页查看,每页3个 * 翻页查看,每页3个
......
package com.qiwuai.garden.common; package com.qiwuai.garden.common;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.qiwuai.garden.common.utils.HttpUtil; import com.qiwuai.garden.common.utils.HttpUtil;
import com.qiwuai.garden.common.utils.PersistenceUtil;
import com.qiwuai.garden.common.utils.RankingUtil;
import com.qiwuai.garden.common.utils.TypeConvertUtil; import com.qiwuai.garden.common.utils.TypeConvertUtil;
import com.qiwuai.garden.dao.*; import com.qiwuai.garden.dao.*;
import com.qiwuai.garden.dto.GardenerDto; import com.qiwuai.garden.dto.*;
import com.qiwuai.garden.dto.PlantPeriodDto;
import com.qiwuai.garden.dto.RegionDto;
import com.qiwuai.garden.pojo.*; import com.qiwuai.garden.pojo.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -497,6 +499,42 @@ public class InitSysServlet implements InitializingBean { ...@@ -497,6 +499,42 @@ public class InitSysServlet implements InitializingBean {
// log.info("缓存中玩家地址对应的地区信息" + TimingAcquisition.addressMap); // log.info("缓存中玩家地址对应的地区信息" + TimingAcquisition.addressMap);
log.info("玩家地址对应的地区信息缓存完成"); log.info("玩家地址对应的地区信息缓存完成");
//----------------------缓存排行榜信息----------------------------
//世界财富排行榜
TimingAcquisition.moneyRankingList.clear();
List<PlayerTimesDto> moneyRankingList = RankingUtil.moneyRankingListSort();
TimingAcquisition.moneyRankingList.addAll(moneyRankingList);
//世界战斗排行榜
TimingAcquisition.fightRankingList.clear();
List<PlayerTimesDto> fightRankingList = RankingUtil.fightRankingListSort();
TimingAcquisition.fightRankingList.addAll(fightRankingList);
//世界友情排行榜
TimingAcquisition.friendshipRankingList.clear();
List<PlayerTimesDto> friendshipRankingList = RankingUtil.friendshipRankingListSort();
TimingAcquisition.friendshipRankingList.addAll(friendshipRankingList);
//获取所有地区
String fileName = "region.json";
String s = PersistenceUtil.getConfigFromFile(fileName);
Map<String, List<RegionIPDto>> IPRegionsMap = JSON.parseObject(s, new TypeReference<Map<String, List<RegionIPDto>>>(){});
for (Map.Entry<String, List<RegionIPDto>> entry : IPRegionsMap.entrySet()) {
List<RegionIPDto> regionIPList = entry.getValue();
for (RegionIPDto regionIP : regionIPList) {
if (regionIP.getPopulation() > 0) {
String place = regionIP.getPlace();
//地区财富排行榜
List<PlayerTimesDto> regionMoneyRankingList = RankingUtil.regionMoneyRankingListSort(place);
TimingAcquisition.regionMoneyRankingListMap.put(place, regionMoneyRankingList);
//地区战斗排行榜
List<PlayerTimesDto> regionFightRankingList = RankingUtil.regionFightRankingListSort(place);
TimingAcquisition.regionFightRankingListMap.put(place, regionFightRankingList);
//地区友情排行榜
List<PlayerTimesDto> regionFriendshipRankingList = RankingUtil.regionFriendshipRankingListSort(place);
TimingAcquisition.regionFriendShipRankingListMap.put(place, regionFriendshipRankingList);
}
}
}
//----------------------更新动态词组到bot服务器------------------------ //----------------------更新动态词组到bot服务器------------------------
// log.info("开始更新所有动态词组"); // log.info("开始更新所有动态词组");
// TimingAcquisition.updatePhraseToBotServer(); // TimingAcquisition.updatePhraseToBotServer();
......
...@@ -59,6 +59,32 @@ public class TimingAcquisition { ...@@ -59,6 +59,32 @@ public class TimingAcquisition {
* 给玩家的建议中所有操作和变量保存: Map<uid, 操作列表> * 给玩家的建议中所有操作和变量保存: Map<uid, 操作列表>
*/ */
public volatile static Map<String, List<AdviseOperateDto>> adviseOperateMap = new ConcurrentHashMap<>(); public volatile static Map<String, List<AdviseOperateDto>> adviseOperateMap = new ConcurrentHashMap<>();
/**
* 世界财富榜
*/
public volatile static List<PlayerTimesDto> moneyRankingList = new ArrayList<>();
/**
* 世界战斗榜
*/
public volatile static List<PlayerTimesDto> fightRankingList = new ArrayList<>();
/**
* 世界友情榜
*/
public volatile static List<PlayerTimesDto> friendshipRankingList = new ArrayList<>();
/**
* 地区财富榜
*/
public volatile static Map<String, List<PlayerTimesDto>> regionMoneyRankingListMap = new ConcurrentHashMap<>();
/**
* 地区战斗榜
*/
public volatile static Map<String, List<PlayerTimesDto>> regionFightRankingListMap = new ConcurrentHashMap<>();
/**
* 地区友情榜
*/
public volatile static Map<String, List<PlayerTimesDto>> regionFriendShipRankingListMap = new ConcurrentHashMap<>();
/** /**
* 地区与服务器对应的配置信息 * 地区与服务器对应的配置信息
...@@ -206,6 +232,10 @@ public class TimingAcquisition { ...@@ -206,6 +232,10 @@ public class TimingAcquisition {
* 建议模块话术 * 建议模块话术
*/ */
public volatile static Map<String, Map<String, List<String>>> adviseSpeechMap = new ConcurrentHashMap<>(); public volatile static Map<String, Map<String, List<String>>> adviseSpeechMap = new ConcurrentHashMap<>();
/**
* 排行榜模块话术
*/
public volatile static Map<String, Map<String, List<String>>> rankingSpeechMap = new ConcurrentHashMap<>();
/** /**
...@@ -252,15 +282,17 @@ public class TimingAcquisition { ...@@ -252,15 +282,17 @@ public class TimingAcquisition {
Map<String, Map<String, List<String>>> taskSpeech = new HashMap<>(); Map<String, Map<String, List<String>>> taskSpeech = new HashMap<>();
Map<String, Map<String, List<String>>> helpSpeech = new HashMap<>(); Map<String, Map<String, List<String>>> helpSpeech = new HashMap<>();
Map<String, Map<String, List<String>>> adviseSpeech = new HashMap<>(); Map<String, Map<String, List<String>>> adviseSpeech = new HashMap<>();
Map<String, Map<String, List<String>>> rankingSpeech = new HashMap<>();
try { try {
plantSpeech = YamlUtil.plantSpeechToMap(); plantSpeech = YamlUtil.loadSpeechToMap("plant.yaml");
gardenerSpeech = YamlUtil.gardenerSpeechToMap(); gardenerSpeech = YamlUtil.loadSpeechToMap("gardener.yaml");
petSpeech = YamlUtil.petSpeechToMap(); petSpeech = YamlUtil.loadSpeechToMap("pet.yaml");
marketSpeech = YamlUtil.marketSpeechToMap(); marketSpeech = YamlUtil.loadSpeechToMap("market.yaml");
socialSpeech = YamlUtil.socialSpeechToMap(); socialSpeech = YamlUtil.loadSpeechToMap("social.yaml");
taskSpeech = YamlUtil.taskSpeechToMap(); taskSpeech = YamlUtil.loadSpeechToMap("task.yaml");
helpSpeech = YamlUtil.helpSpeechToMap(); helpSpeech = YamlUtil.loadSpeechToMap("help.yaml");
adviseSpeech = YamlUtil.adviseSpeechToMap(); adviseSpeech = YamlUtil.loadSpeechToMap("advise.yaml");
rankingSpeech = YamlUtil.loadSpeechToMap("ranking.yaml");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -280,6 +312,7 @@ public class TimingAcquisition { ...@@ -280,6 +312,7 @@ public class TimingAcquisition {
taskSpeechMap.putAll(taskSpeech); taskSpeechMap.putAll(taskSpeech);
helpSpeechMap.putAll(helpSpeech); helpSpeechMap.putAll(helpSpeech);
adviseSpeechMap.putAll(adviseSpeech); adviseSpeechMap.putAll(adviseSpeech);
rankingSpeechMap.putAll(rankingSpeech);
// log.info("缓存中玩家的种植话术:" + plantSpeechMap); // log.info("缓存中玩家的种植话术:" + plantSpeechMap);
// log.info("缓存中玩家的园丁话术:" + gardenerSpeechMap); // log.info("缓存中玩家的园丁话术:" + gardenerSpeechMap);
// log.info("缓存中玩家的宠物话术:" + petSpeechMap); // log.info("缓存中玩家的宠物话术:" + petSpeechMap);
......
package com.qiwuai.garden.common.schedule; package com.qiwuai.garden.common.schedule;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.qiwuai.garden.common.Constants; import com.qiwuai.garden.common.Constants;
import com.qiwuai.garden.common.TimingAcquisition; import com.qiwuai.garden.common.TimingAcquisition;
import com.qiwuai.garden.common.utils.PersistenceUtil;
import com.qiwuai.garden.common.utils.RankingUtil;
import com.qiwuai.garden.common.utils.TypeConvertUtil; import com.qiwuai.garden.common.utils.TypeConvertUtil;
import com.qiwuai.garden.dto.BackPackDto; import com.qiwuai.garden.dto.*;
import com.qiwuai.garden.dto.ItemBagDto;
import com.qiwuai.garden.dto.ItemDto;
import com.qiwuai.garden.dto.NurseryInfoDto;
import com.qiwuai.garden.pojo.ItemPojo; import com.qiwuai.garden.pojo.ItemPojo;
import com.qiwuai.garden.pojo.PetPojo; import com.qiwuai.garden.pojo.PetPojo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -101,6 +102,46 @@ public class ScheduleTask { ...@@ -101,6 +102,46 @@ public class ScheduleTask {
} }
} }
@Scheduled(cron = "0 0 3 * * ?")
// @Scheduled(cron = "0 */2 * * * ?")
public void updateRanking() {
log.info("----------------开始更新排行榜----------------");
//世界财富排行榜
TimingAcquisition.moneyRankingList.clear();
List<PlayerTimesDto> moneyRankingList = RankingUtil.moneyRankingListSort();
TimingAcquisition.moneyRankingList.addAll(moneyRankingList);
//世界战斗排行榜
TimingAcquisition.fightRankingList.clear();
List<PlayerTimesDto> fightRankingList = RankingUtil.fightRankingListSort();
TimingAcquisition.fightRankingList.addAll(fightRankingList);
//世界友情排行榜
TimingAcquisition.friendshipRankingList.clear();
List<PlayerTimesDto> friendshipRankingList = RankingUtil.friendshipRankingListSort();
TimingAcquisition.friendshipRankingList.addAll(friendshipRankingList);
//获取所有地区
String fileName = "region.json";
String s = PersistenceUtil.getConfigFromFile(fileName);
Map<String, List<RegionIPDto>> IPRegionsMap = JSON.parseObject(s, new TypeReference<Map<String, List<RegionIPDto>>>(){});
for (Map.Entry<String, List<RegionIPDto>> entry : IPRegionsMap.entrySet()) {
List<RegionIPDto> regionIPList = entry.getValue();
for (RegionIPDto regionIP : regionIPList) {
if (regionIP.getPopulation() > 0) {
String place = regionIP.getPlace();
//地区财富排行榜
List<PlayerTimesDto> regionMoneyRankingList = RankingUtil.regionMoneyRankingListSort(place);
TimingAcquisition.regionMoneyRankingListMap.put(place, regionMoneyRankingList);
//地区战斗排行榜
List<PlayerTimesDto> regionFightRankingList = RankingUtil.regionFightRankingListSort(place);
TimingAcquisition.regionFightRankingListMap.put(place, regionFightRankingList);
//地区友情排行榜
List<PlayerTimesDto> regionFriendshipRankingList = RankingUtil.regionFriendshipRankingListSort(place);
TimingAcquisition.regionFriendShipRankingListMap.put(place, regionFriendshipRankingList);
}
}
}
log.info("----------------排行榜更新完成----------------");
}
/** /**
* 喂养宠物栏中的宠物 * 喂养宠物栏中的宠物
* @param uid * @param uid
......
package com.qiwuai.garden.common.utils;
import com.qiwuai.garden.common.Constants;
import com.qiwuai.garden.common.TimingAcquisition;
import com.qiwuai.garden.dto.ItemDto;
import com.qiwuai.garden.dto.PlayerTimesDto;
import com.qiwuai.garden.dto.RegionDto;
import org.springframework.util.StringUtils;
import java.util.*;
public class RankingUtil {
/**
* 世界财富排行榜
* @return List<PlayerTimesDto>
*/
public static List<PlayerTimesDto> moneyRankingListSort() {
List<PlayerTimesDto> moneyRankingList = new ArrayList<>();
int number;
for (Map.Entry<String, Map<String, RegionDto>> entry : TimingAcquisition.addressMap.entrySet()) {
Map<String, RegionDto> regionMap = entry.getValue();
if (regionMap.size() != 0) {
for (Map.Entry<String, RegionDto> regionEntry : regionMap.entrySet()) {
RegionDto region = regionEntry.getValue();
PlayerTimesDto playerTimes = new PlayerTimesDto();
playerTimes.setUid(region.getUid());
playerTimes.setAddress(regionEntry.getKey());
//货币配置信息
Integer moneyId = Integer.parseInt(TimingAcquisition.systemConfigMap.get("money").getValue());
//货币对应种类
Integer moneyType = TimingAcquisition.itemConfigMap.get(moneyId).getItemTypeId();
//获取背包的钱袋
ItemDto money = TimingAcquisition.gardenerMap.get(region.getUid()).getBackPack().getItemBags().get(moneyType).getItems(moneyId);
number = money.getItemNum();
playerTimes.setNumber(number);
moneyRankingList.add(playerTimes);
}
}
}
if (moneyRankingList.size() != 0) {
minHeapSort(moneyRankingList);
}
return moneyRankingList;
}
/**
* 世界战斗排行榜
* @return List<PlayerTimesDto>
*/
public static List<PlayerTimesDto> fightRankingListSort() {
List<PlayerTimesDto> fightRankingList = new ArrayList<>();
int number;
for (Map.Entry<String, Map<String, RegionDto>> entry : TimingAcquisition.addressMap.entrySet()) {
Map<String, RegionDto> regionMap = entry.getValue();
if (regionMap.size() != 0) {
for (Map.Entry<String, RegionDto> regionEntry : regionMap.entrySet()) {
RegionDto region = regionEntry.getValue();
PlayerTimesDto playerTimes = new PlayerTimesDto();
playerTimes.setUid(region.getUid());
playerTimes.setAddress(regionEntry.getKey());
//玩家偷菜成功次数
number = TimingAcquisition.gardenerMap.get(region.getUid()).getTaskCountMap().get(Constants.STEAL_SUCCESS_EVENT);
playerTimes.setNumber(number);
fightRankingList.add(playerTimes);
}
}
}
if (fightRankingList.size() != 0) {
minHeapSort(fightRankingList);
}
return fightRankingList;
}
/**
* 世界友情排行榜
* @return List<PlayerTimesDto>
*/
public static List<PlayerTimesDto> friendshipRankingListSort() {
List<PlayerTimesDto> fightRankingList = new ArrayList<>();
int number;
for (Map.Entry<String, Map<String, RegionDto>> entry : TimingAcquisition.addressMap.entrySet()) {
Map<String, RegionDto> regionMap = entry.getValue();
if (regionMap.size() != 0) {
for (Map.Entry<String, RegionDto> regionEntry : regionMap.entrySet()) {
RegionDto region = regionEntry.getValue();
PlayerTimesDto playerTimes = new PlayerTimesDto();
playerTimes.setUid(region.getUid());
playerTimes.setAddress(regionEntry.getKey());
//玩家帮助好友次数
number = TimingAcquisition.gardenerMap.get(region.getUid()).getTaskCountMap().get(Constants.HELP_EVENT);
playerTimes.setNumber(number);
fightRankingList.add(playerTimes);
}
}
}
if (fightRankingList.size() != 0) {
minHeapSort(fightRankingList);
}
return fightRankingList;
}
/**
* 地区财富排行榜
* @return List<PlayerTimesDto>
*/
public static List<PlayerTimesDto> regionMoneyRankingListSort(String place) {
List<PlayerTimesDto> moneyRankingList = new ArrayList<>();
int number;
Map<String, RegionDto> regionMap = TimingAcquisition.addressMap.get(place);
if (regionMap.size() != 0) {
for (Map.Entry<String, RegionDto> regionEntry : regionMap.entrySet()) {
RegionDto region = regionEntry.getValue();
PlayerTimesDto playerTimes = new PlayerTimesDto();
playerTimes.setUid(region.getUid());
playerTimes.setAddress(regionEntry.getKey());
//货币配置信息
Integer moneyId = Integer.parseInt(TimingAcquisition.systemConfigMap.get("money").getValue());
//货币对应种类
Integer moneyType = TimingAcquisition.itemConfigMap.get(moneyId).getItemTypeId();
//获取背包的钱袋
ItemDto money = TimingAcquisition.gardenerMap.get(region.getUid()).getBackPack().getItemBags().get(moneyType).getItems(moneyId);
number = money.getItemNum();
playerTimes.setNumber(number);
moneyRankingList.add(playerTimes);
}
}
if (moneyRankingList.size() != 0) {
minHeapSort(moneyRankingList);
}
return moneyRankingList;
}
/**
* 地区战斗排行榜
* @return List<PlayerTimesDto>
*/
public static List<PlayerTimesDto> regionFightRankingListSort(String place) {
List<PlayerTimesDto> fightRankingList = new ArrayList<>();
int number;
Map<String, RegionDto> regionMap = TimingAcquisition.addressMap.get(place);
if (regionMap.size() != 0) {
for (Map.Entry<String, RegionDto> regionEntry : regionMap.entrySet()) {
RegionDto region = regionEntry.getValue();
PlayerTimesDto playerTimes = new PlayerTimesDto();
playerTimes.setUid(region.getUid());
playerTimes.setAddress(regionEntry.getKey());
//玩家偷菜成功次数
number = TimingAcquisition.gardenerMap.get(region.getUid()).getTaskCountMap().get(Constants.STEAL_SUCCESS_EVENT);
playerTimes.setNumber(number);
fightRankingList.add(playerTimes);
}
}
if (fightRankingList.size() != 0) {
minHeapSort(fightRankingList);
}
return fightRankingList;
}
/**
* 地区友情排行榜
* @return List<PlayerTimesDto>
*/
public static List<PlayerTimesDto> regionFriendshipRankingListSort(String place) {
List<PlayerTimesDto> friendshipRankingList = new ArrayList<>();
int number;
Map<String, RegionDto> regionMap = TimingAcquisition.addressMap.get(place);
if (regionMap.size() != 0) {
for (Map.Entry<String, RegionDto> regionEntry : regionMap.entrySet()) {
RegionDto region = regionEntry.getValue();
PlayerTimesDto playerTimes = new PlayerTimesDto();
playerTimes.setUid(region.getUid());
playerTimes.setAddress(regionEntry.getKey());
//玩家帮助好友次数
number = TimingAcquisition.gardenerMap.get(region.getUid()).getTaskCountMap().get(Constants.HELP_EVENT);
playerTimes.setNumber(number);
friendshipRankingList.add(playerTimes);
}
}
if (friendshipRankingList.size() != 0) {
minHeapSort(friendshipRankingList);
}
return friendshipRankingList;
}
/**
* 获取对应排行榜的名次
* @return List<PlayerTimesDto>
*/
public static int getRankingByUid(String rankingName, String place, String uid) {
int result = 0;
//不存在地区,即查看世界排行榜
if (StringUtils.isEmpty(place)) {
//查看财富榜
if (Constants.MONEY_RANKING.equals(rankingName)) {
result = searchRankingByUid(TimingAcquisition.moneyRankingList, uid);
}
//查看战斗榜
if (Constants.FIGHT_RANKING.equals(rankingName)) {
result = searchRankingByUid(TimingAcquisition.fightRankingList, uid);
}
//查看友情榜
if (Constants.FRIENDSHIP_RANKING.equals(rankingName)) {
result = searchRankingByUid(TimingAcquisition.friendshipRankingList, uid);
}
} else {
//查看地区财富榜
if (Constants.MONEY_RANKING.equals(rankingName)) {
result = searchRankingByUid(TimingAcquisition.regionMoneyRankingListMap.get(place), uid);
}
//查看地区战斗榜
if (Constants.FIGHT_RANKING.equals(rankingName)) {
result = searchRankingByUid(TimingAcquisition.regionFightRankingListMap.get(place), uid);
}
//查看地区友情榜
if (Constants.FRIENDSHIP_RANKING.equals(rankingName)) {
result = searchRankingByUid(TimingAcquisition.regionFriendShipRankingListMap.get(place), uid);
}
}
return result;
}
/**
* 按照玩家对应次数降序排列,非递归的快速排序,采用栈实现
* @param playerTimesDtoList
* @return void
*/
public static void rankingQuickSort(List<PlayerTimesDto> playerTimesDtoList) {
Stack<Integer> stack = new Stack<>();
stack.push(playerTimesDtoList.size() - 1);
stack.push(0);
while (!stack.isEmpty()) {
int left = stack.pop();
int right = stack.pop();
//跳过排序
if (left >= right) {
continue;
}
int index = rankingPartition(playerTimesDtoList, left, right);
if (index + 1 < right) {
stack.push(right);
stack.push(index + 1);
}
if (left < index - 1) {
stack.push(index - 1);
stack.push(left);
}
}
}
/**
* 非递归的快速排序
* @param playerTimesDtoList
* @param left
* @param right
* @return int
*/
public static int rankingPartition(List<PlayerTimesDto> playerTimesDtoList, int left, int right) {
//采用快速排序实现排序
int i = left;
int j = right;
PlayerTimesDto playerTimes = playerTimesDtoList.get(j);
//玩家i的次数
Integer timesI = playerTimesDtoList.get(i).getNumber();
//玩家j的次数
Integer timesJ = playerTimesDtoList.get(j).getNumber();
//玩家base的次数
Integer timesBase = playerTimes.getNumber();
while (i < j) {
while (i < j && timesJ <= timesBase) {
j--;
timesJ = playerTimesDtoList.get(j).getNumber();
}
while (i < j && timesI >= timesBase) {
i++;
timesI = playerTimesDtoList.get(i).getNumber();
}
Collections.swap(playerTimesDtoList, i, j);
//玩家i的次数
timesI = playerTimesDtoList.get(i).getNumber();
//玩家j的次数
timesJ = playerTimesDtoList.get(j).getNumber();
}
Collections.swap(playerTimesDtoList, i, right);
return i;
}
/**
* 堆排序,小顶堆
* @param playerTimesList
* @return void
*/
public static void minHeapSort(List<PlayerTimesDto> playerTimesList) {
if (playerTimesList.size() == 0) {
return;
}
int length = playerTimesList.size();
//数量大于1时进行排序
if (length > 1) {
//初始化堆
initHeap(playerTimesList, length - 1);
//堆排序
for (int i = length - 1; i >= 0; i--) {
//交换堆顶和末尾数交换
Collections.swap(playerTimesList, 0, i);
//继续调整堆
adjustMinHeap(playerTimesList, 0, i - 1);
}
}
}
public static void initHeap(List<PlayerTimesDto> playerTimesList, int maxIndex) {
for (int i = (maxIndex - 1) / 2; i >= 0; i--) {
adjustMinHeap(playerTimesList, i, maxIndex);
}
}
public static void adjustMinHeap(List<PlayerTimesDto> playerTimesList, int parentIndex, int maxIndex) {
if (maxIndex > 0) {
int resultIndex = -1;
int leftIndex = 2 * parentIndex + 1;
int rightIndex = 2 * parentIndex + 2;
//没有左右子节点,即最后一个叶子节点
if (leftIndex > maxIndex) {
return;
} else if (rightIndex > maxIndex) {
resultIndex = minResult(playerTimesList, leftIndex, parentIndex);
} else { //左右节点都存在
resultIndex = minResult(playerTimesList, leftIndex, rightIndex);
resultIndex = minResult(playerTimesList, resultIndex, parentIndex);
}
if (resultIndex != parentIndex) {
Collections.swap(playerTimesList, parentIndex, resultIndex);
adjustMinHeap(playerTimesList, resultIndex, maxIndex);
}
}
}
public static int minResult(List<PlayerTimesDto> playerTimesList, int leftIndex, int rightIndex) {
return playerTimesList.get(leftIndex).getNumber() < playerTimesList.get(rightIndex).getNumber() ? leftIndex : rightIndex;
}
/**
* 二分法查找
* @param playerTimesList
* @return void
*/
public static int binarySearch(List<PlayerTimesDto> playerTimesList, Integer number) {
int min = 0;
int max = playerTimesList.size() - 1;
while (min <= max) {
int mid = (min + max) / 2;
if (number.equals(playerTimesList.get(mid).getNumber())) {
return mid + 1;
}
if (number < playerTimesList.get(mid).getNumber()) {
min = mid + 1;
} else {
max = mid - 1;
}
}
return -1;
}
/**
* 根据uid查找玩家名次
* @param playerTimesList
* @return void
*/
public static int searchRankingByUid(List<PlayerTimesDto> playerTimesList, String uid) {
for (int i = 0; i < playerTimesList.size(); i++) {
if (uid.equals(playerTimesList.get(i).getUid())) {
return i + 1;
}
}
return -1;
}
}
...@@ -16,6 +16,7 @@ import org.slf4j.Logger; ...@@ -16,6 +16,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -519,6 +520,38 @@ public class RequestConversionUtil { ...@@ -519,6 +520,38 @@ public class RequestConversionUtil {
if (!StringUtils.isEmpty(time)) { if (!StringUtils.isEmpty(time)) {
operationRequest.setTime(Integer.valueOf(time)); operationRequest.setTime(Integer.valueOf(time));
} }
//--------存在榜单-----------
String ranking = callRequest.get榜单();
if (!StringUtils.isEmpty(ranking)) {
operationRequest.setRankingName(ranking);
}
//-----------存在排行榜序号--------------
String rankingNum = callRequest.get排行榜序号();
if (!StringUtils.isEmpty(rankingNum)) {
//找到中文数字对应的阿拉伯数字
Integer number = TypeConvertUtil.change2Integer(reportNum);
//中文中不包含中文数字时,提取阿拉伯数字
if (number == 0) {
number = TypeConvertUtil.extractNum(reportNum);
}
operationRequest.setRankingNum(number);
}
//--------存在地区-----------
String place = callRequest.get地区();
if (!StringUtils.isEmpty(place)) {
operationRequest.setPlace(place);
}
//--------存在名次-----------
String rankNumber = callRequest.get名次();
if (!StringUtils.isEmpty(rankNumber)) {
//找到中文数字对应的阿拉伯数字
Integer number = TypeConvertUtil.change2Integer(rankNumber);
//中文中不包含中文数字时,提取阿拉伯数字
if (number == 0) {
number = TypeConvertUtil.extractNum(rankNumber);
}
operationRequest.setRankNumber(number);
}
return operationRequest; return operationRequest;
} }
} }
...@@ -119,6 +119,20 @@ public class SpeechUtil { ...@@ -119,6 +119,20 @@ public class SpeechUtil {
} }
/** /**
* 从排行榜模块话术获取话术
* @param someone
* @param feedText
* @return String
*/
public static String getRankingSpeech(String someone, String feedText) {
String result = "";
List<String> speech = TimingAcquisition.rankingSpeechMap.get(someone).get(feedText);
Integer i = RandomDropUtil.getRandomNum(0, speech.size());
result = speech.get(i);
return result;
}
/**
* 替换话术中的一个数字 * 替换话术中的一个数字
* @param one * @param one
* @return String * @return String
......
...@@ -23,14 +23,14 @@ public class YamlUtil { ...@@ -23,14 +23,14 @@ public class YamlUtil {
private static LinkedHashMap<String, Map<String, Map<String, String>>> properties = new LinkedHashMap<>(); private static LinkedHashMap<String, Map<String, Map<String, String>>> properties = new LinkedHashMap<>();
/** /**
* 将种植话术转成map格式 * 将话术转成map格式
* @param * @param
* @return Map<String, Map<String, List<String>>> * @return Map<String, Map<String, List<String>>>
*/ */
public static Map<String, Map<String, List<String>>> plantSpeechToMap() { public static Map<String, Map<String, List<String>>> loadSpeechToMap(String fileName) {
Map<String, Map<String, List<String>>> speechMap = new HashMap<>(); Map<String, Map<String, List<String>>> speechMap = new HashMap<>();
try { try {
InputStream in = new FileInputStream(speechFilePath + "plant.yaml"); InputStream in = new FileInputStream(speechFilePath + fileName);
Yaml yaml = new Yaml(); Yaml yaml = new Yaml();
speechMap = yaml.load(in); speechMap = yaml.load(in);
} catch (Exception e) { } catch (Exception e) {
...@@ -38,123 +38,6 @@ public class YamlUtil { ...@@ -38,123 +38,6 @@ public class YamlUtil {
} }
return speechMap; return speechMap;
} }
/**
* 将园丁话术转成map格式
* @param
* @return Map<String, Map<String, List<String>>>
*/
public static Map<String, Map<String, List<String>>> gardenerSpeechToMap() {
Map<String, Map<String, List<String>>> speechMap = new HashMap<>();
try {
InputStream in = new FileInputStream(speechFilePath + "gardener.yaml");
Yaml yaml = new Yaml();
speechMap = yaml.load(in);
} catch (Exception e) {
e.printStackTrace();
}
return speechMap;
}
/**
* 将宠物话术转成map格式
* @param
* @return Map<String, Map<String, List<String>>>
*/
public static Map<String, Map<String, List<String>>> petSpeechToMap() {
Map<String, Map<String, List<String>>> speechMap = new HashMap<>();
try {
InputStream in = new FileInputStream(speechFilePath + "pet.yaml");
Yaml yaml = new Yaml();
speechMap = yaml.load(in);
} catch (Exception e) {
e.printStackTrace();
}
return speechMap;
}
/**
* 将市场话术转成map格式
* @param
* @return Map<String, Map<String, List<String>>>
*/
public static Map<String, Map<String, List<String>>> marketSpeechToMap() {
Map<String, Map<String, List<String>>> speechMap = new HashMap<>();
try {
InputStream in = new FileInputStream(speechFilePath + "market.yaml");
Yaml yaml = new Yaml();
speechMap = yaml.load(in);
} catch (Exception e) {
e.printStackTrace();
}
return speechMap;
}
/**
* 将社交话术转成map格式
* @param
* @return Map<String, Map<String, List<String>>>
*/
public static Map<String, Map<String, List<String>>> socialSpeechToMap() {
Map<String, Map<String, List<String>>> speechMap = new HashMap<>();
try {
InputStream in = new FileInputStream(speechFilePath + "social.yaml");
Yaml yaml = new Yaml();
speechMap = yaml.load(in);
} catch (Exception e) {
e.printStackTrace();
}
return speechMap;
}
/**
* 将任务话术转成map格式
* @param
* @return Map<String, Map<String, List<String>>>
*/
public static Map<String, Map<String, List<String>>> taskSpeechToMap() {
Map<String, Map<String, List<String>>> speechMap = new HashMap<>();
try {
InputStream in = new FileInputStream(speechFilePath + "task.yaml");
Yaml yaml = new Yaml();
speechMap = yaml.load(in);
} catch (Exception e) {
e.printStackTrace();
}
return speechMap;
}
/**
* 将帮助话术转成map格式
* @param
* @return Map<String, Map<String, List<String>>>
*/
public static Map<String, Map<String, List<String>>> helpSpeechToMap() {
Map<String, Map<String, List<String>>> speechMap = new HashMap<>();
try {
InputStream in = new FileInputStream(speechFilePath + "help.yaml");
Yaml yaml = new Yaml();
speechMap = yaml.load(in);
} catch (Exception e) {
e.printStackTrace();
}
return speechMap;
}
/**
* 将建议话术转成map格式
* @param
* @return Map<String, Map<String, List<String>>>
*/
public static Map<String, Map<String, List<String>>> adviseSpeechToMap() {
Map<String, Map<String, List<String>>> adviseMap = new HashMap<>();
try {
InputStream in = new FileInputStream(speechFilePath + "advise.yaml");
Yaml yaml = new Yaml();
adviseMap = yaml.load(in);
} catch (Exception e) {
e.printStackTrace();
}
return adviseMap;
}
/** /**
* 读取配置文件yml中的某个值,只支持取第一层的值 * 读取配置文件yml中的某个值,只支持取第一层的值
......
...@@ -23,6 +23,8 @@ import com.qiwuai.garden.service.petService.PetService; ...@@ -23,6 +23,8 @@ import com.qiwuai.garden.service.petService.PetService;
import com.qiwuai.garden.service.petService.impl.PetServiceImpl; import com.qiwuai.garden.service.petService.impl.PetServiceImpl;
import com.qiwuai.garden.service.plantService.PlantService; import com.qiwuai.garden.service.plantService.PlantService;
import com.qiwuai.garden.service.plantService.impl.PlantServiceImpl; import com.qiwuai.garden.service.plantService.impl.PlantServiceImpl;
import com.qiwuai.garden.service.rankingService.RankingService;
import com.qiwuai.garden.service.rankingService.impl.RankingServiceImpl;
import com.qiwuai.garden.service.socialService.SocialService; import com.qiwuai.garden.service.socialService.SocialService;
import com.qiwuai.garden.service.socialService.impl.SocialServiceImpl; import com.qiwuai.garden.service.socialService.impl.SocialServiceImpl;
import com.qiwuai.garden.service.taskService.TaskService; import com.qiwuai.garden.service.taskService.TaskService;
...@@ -65,6 +67,9 @@ public class CommonController { ...@@ -65,6 +67,9 @@ public class CommonController {
//任务模块动态代理 //任务模块动态代理
TaskService taskService = new TaskServiceImpl(); TaskService taskService = new TaskServiceImpl();
TaskService taskServiceProxy = (TaskService) new ProxyFactory(taskService).getProxyInstance(); TaskService taskServiceProxy = (TaskService) new ProxyFactory(taskService).getProxyInstance();
//排行榜模块动态代理
RankingService rankingService = new RankingServiceImpl();
RankingService rankingServiceProxy = (RankingService) new ProxyFactory(rankingService).getProxyInstance();
//帮助模块动态代理 //帮助模块动态代理
HelpService helpService = new HelpServiceImpl(); HelpService helpService = new HelpServiceImpl();
HelpService helpServiceProxy = (HelpService) new ProxyFactory(helpService).getProxyInstance(); HelpService helpServiceProxy = (HelpService) new ProxyFactory(helpService).getProxyInstance();
...@@ -533,6 +538,18 @@ public class CommonController { ...@@ -533,6 +538,18 @@ public class CommonController {
case "查询任务": case "查询任务":
result = taskServiceProxy.checkTask(operationReq); result = taskServiceProxy.checkTask(operationReq);
break; break;
case "查看排行榜":
result = rankingServiceProxy.checkRankingList(operationReq);
break;
case "查看本人榜单名次":
result = rankingServiceProxy.checkSelfRankingList(operationReq);
break;
case "查看玩家榜单名次":
result = rankingServiceProxy.checkPlayerRankingList(operationReq);
break;
case "拜访榜单玩家":
result = rankingServiceProxy.visitRankingPlayer(operationReq);
break;
case "打开帮助菜单": case "打开帮助菜单":
result = helpServiceProxy.openHelpMenu(operationReq); result = helpServiceProxy.openHelpMenu(operationReq);
break; break;
......
...@@ -32,4 +32,8 @@ public class FriendDto { ...@@ -32,4 +32,8 @@ public class FriendDto {
* 帮助时间 * 帮助时间
*/ */
private String helpTime; private String helpTime;
/**
* 已帮助次数
*/
private Integer helpNumber = 0;
} }
package com.qiwuai.garden.dto;
import lombok.Data;
@Data
public class PlayerTimesDto {
/**
* 玩家id
*/
private String uid;
/**
* 玩家地址
*/
private String address;
/**
* 玩家对应货币数量、偷菜成功次数、帮助好友次数
*/
private Integer number;
}
...@@ -186,4 +186,20 @@ public class CallRequest { ...@@ -186,4 +186,20 @@ public class CallRequest {
*/ */
@JsonProperty(value = "GB_园丁姓名") @JsonProperty(value = "GB_园丁姓名")
private String GB_园丁姓名; private String GB_园丁姓名;
/**
* 榜单
*/
private String 榜单;
/**
* 排行榜序号
*/
private String 排行榜序号;
/**
* 地区
*/
private String 地区;
/**
* 名次
*/
private String 名次;
} }
...@@ -193,6 +193,22 @@ public class OperationRequest { ...@@ -193,6 +193,22 @@ public class OperationRequest {
*/ */
private String gardenerName; private String gardenerName;
/** /**
* 榜单
*/
private String rankingName;
/**
* 排行榜序号
*/
private Integer rankingNum;
/**
* 地区
*/
private String place;
/**
* 名次
*/
private Integer rankNumber;
/**
* 本轮操作标识 * 本轮操作标识
*/ */
private Integer operationLabel; private Integer operationLabel;
......
package com.qiwuai.garden.service.rankingService;
import com.qiwuai.garden.dto.base.CommonResponse;
import com.qiwuai.garden.dto.request.OperationRequest;
public interface RankingService {
/**
* 查看排行榜
* @param operationReq
* @return CommonResponse
*/
CommonResponse checkRankingList(OperationRequest operationReq);
/**
* 查看本人榜单名次
* @param operationReq
* @return CommonResponse
*/
CommonResponse checkSelfRankingList(OperationRequest operationReq);
/**
* 查看玩家榜单名次
* @param operationReq
* @return CommonResponse
*/
CommonResponse checkPlayerRankingList(OperationRequest operationReq);
/**
* 拜访榜单玩家
* @param operationReq
* @return CommonResponse
*/
CommonResponse visitRankingPlayer(OperationRequest operationReq);
}
package com.qiwuai.garden.service.rankingService.impl;
import com.qiwuai.garden.common.Constants;
import com.qiwuai.garden.common.TimingAcquisition;
import com.qiwuai.garden.common.cache.CacheUtil;
import com.qiwuai.garden.common.utils.*;
import com.qiwuai.garden.dto.FriendDto;
import com.qiwuai.garden.dto.ItemDto;
import com.qiwuai.garden.dto.PlayerTimesDto;
import com.qiwuai.garden.dto.RegionDto;
import com.qiwuai.garden.dto.base.CommonResponse;
import com.qiwuai.garden.dto.base.ResultResponse;
import com.qiwuai.garden.dto.base.ResultVarsResponse;
import com.qiwuai.garden.dto.request.OperationRequest;
import com.qiwuai.garden.pojo.CallNamePojo;
import com.qiwuai.garden.pojo.ItemPojo;
import com.qiwuai.garden.service.rankingService.RankingService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class RankingServiceImpl implements RankingService {
Logger log = LoggerFactory.getLogger(RankingServiceImpl.class);
//从yml配置文件中取出对话过期时间
String expireTime = YamlUtil.getValueByKey("expireTime");
@Override
public CommonResponse checkRankingList(OperationRequest operationReq) {
CommonResponse commonResponse = new CommonResponse();
ResultVarsResponse resultVarsResponse = new ResultVarsResponse();
ResultResponse resultResponse = new ResultResponse();
String uid = operationReq.getUid();
String rankingName = operationReq.getRankingName(); //榜单
Integer rankingNum = operationReq.getRankingNum(); //排行榜序号
String place = operationReq.getPlace(); //地区
//园丁性别
String gender = TimingAcquisition.getGardenerGender(uid);
//玩家称呼
CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid);
//玩家未提供榜单名或榜单序号
if (StringUtils.isEmpty(rankingName) && StringUtils.isEmpty(rankingNum)) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_world_ranking_no_name");
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700104);
resultResponse.set反馈文本(text);
resultResponse.set后台附加返回("查看榜单回复1");
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//玩家提供了榜单序号
if (!StringUtils.isEmpty(rankingNum)) {
String[] rankingNameList = {Constants.MONEY_RANKING, Constants.FIGHT_RANKING, Constants.FRIENDSHIP_RANKING};
int random = RandomDropUtil.getRandomNum(0, rankingNameList.length);
rankingName = rankingNameList[random];
}
//是否包含玩家本人
boolean containSign = false;
//提供了地区
if (!StringUtils.isEmpty(place)) {
if (place.equals("本地") || place.equals("本地区")) {
place = TimingAcquisition.gardenerMap.get(uid).getGarden().getZone();
}
List<String> regionList = new ArrayList<>(TimingAcquisition.regionIPMap.keySet());
//玩家提供的地址不存在
if (!regionList.contains(place)) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_ranking_wrong_place");
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700110);
resultResponse.set反馈文本(text);
resultResponse.set后台附加返回("查看榜单回复1");
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//该地区还没有人进行排名
if (StringUtils.isEmpty(TimingAcquisition.regionMoneyRankingListMap.get(place))) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_ranking_place_no_player");
text = SpeechUtil.speechReplaceNum(text, place);
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700111);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//该地区还没有人进行排名
if (TimingAcquisition.regionMoneyRankingListMap.get(place).size() == 0) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_ranking_place_no_player");
text = SpeechUtil.speechReplaceNum(text, place);
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700112);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//查看地区财富榜
if (Constants.MONEY_RANKING.equals(rankingName)) {
//货币配置信息
Integer moneyId = Integer.parseInt(TimingAcquisition.systemConfigMap.get("money").getValue());
int size = TimingAcquisition.regionMoneyRankingListMap.get(place).size();
if (size >= 10) {
size = 10;
}
List<PlayerTimesDto> playerTimesList = TimingAcquisition.regionMoneyRankingListMap.get(place).subList(0, size);
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_region_rich_ranking_pre");
text = SpeechUtil.speechReplaceNum(text, place);
for (int i = 0; i < playerTimesList.size(); i++) {
if (playerTimesList.get(i).getUid().equals(uid)) {
containSign = true;
}
String addText = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_region_rich_ranking");
addText = SpeechUtil.speechReplaceNum(addText, String.valueOf(i + 1), playerTimesList.get(i).getAddress(),
playerTimesList.get(i).getNumber().toString(), TimingAcquisition.itemConfigMap.get(moneyId).getName());
text = SpeechUtil.mergeSpeech(text, addText);
if (i < playerTimesList.size() - 1) {
text = text + ";";
} else {
text = text + "。";
}
}
if (containSign) {
text += SpeechUtil.getRankingSpeech(gender, "check_rich_ranking_self_exist");
} else {
text += SpeechUtil.getRankingSpeech(gender, "check_region_rich_ranking");
}
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700107);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//查看地区战斗榜
if (Constants.FIGHT_RANKING.equals(rankingName)) {
int size = TimingAcquisition.regionFightRankingListMap.get(place).size();
if (size >= 10) {
size = 10;
}
List<PlayerTimesDto> playerTimesList = TimingAcquisition.regionFightRankingListMap.get(place).subList(0, size);
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_region_fight_ranking_pre");
text = SpeechUtil.speechReplaceNum(text, place);
for (int i = 0; i < playerTimesList.size(); i++) {
if (playerTimesList.get(i).getUid().equals(uid)) {
containSign = true;
}
String addText = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_region_fight_ranking");
addText = SpeechUtil.speechReplaceNum(addText, String.valueOf(i + 1), playerTimesList.get(i).getAddress(),
playerTimesList.get(i).getNumber().toString());
text = SpeechUtil.mergeSpeech(text, addText);
if (i < playerTimesList.size() - 1) {
text = text + ";";
} else {
text = text + "。";
}
}
if (containSign) {
text += SpeechUtil.getRankingSpeech(gender, "check_fight_ranking_self_exist");
} else {
text += SpeechUtil.getRankingSpeech(gender, "check_region_fight_ranking");
}
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700108);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//查看地区友情榜
if (Constants.FRIENDSHIP_RANKING.equals(rankingName)) {
int size = TimingAcquisition.regionFriendShipRankingListMap.get(place).size();
if (size >= 10) {
size = 10;
}
List<PlayerTimesDto> playerTimesList = TimingAcquisition.regionFriendShipRankingListMap.get(place).subList(0, size);
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_region_friendship_ranking_pre");
text = SpeechUtil.speechReplaceNum(text, place);
for (int i = 0; i < playerTimesList.size(); i++) {
if (playerTimesList.get(i).getUid().equals(uid)) {
containSign = true;
}
String addText = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_region_friendship_ranking");
addText = SpeechUtil.speechReplaceNum(addText, String.valueOf(i + 1), playerTimesList.get(i).getAddress(),
playerTimesList.get(i).getNumber().toString());
text = SpeechUtil.mergeSpeech(text, addText);
if (i < playerTimesList.size() - 1) {
text = text + ";";
} else {
text = text + "。";
}
}
if (containSign) {
text += SpeechUtil.getRankingSpeech(gender, "check_friendship_ranking_self_exist");
} else {
text += SpeechUtil.getRankingSpeech(gender, "check_region_friendship_ranking");
}
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700109);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
}
//查看世界财富榜
if (Constants.MONEY_RANKING.equals(rankingName)) {
//货币配置信息
Integer moneyId = Integer.parseInt(TimingAcquisition.systemConfigMap.get("money").getValue());
int size = TimingAcquisition.moneyRankingList.size();
if (size >= 10) {
size = 10;
}
List<PlayerTimesDto> playerTimesList = TimingAcquisition.moneyRankingList.subList(0, size);
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_world_rich_ranking_pre");
for (int i = 0; i < playerTimesList.size(); i++) {
if (playerTimesList.get(i).getUid().equals(uid)) {
containSign = true;
}
String addText = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_world_rich_ranking");
addText = SpeechUtil.speechReplaceNum(addText, String.valueOf(i + 1), playerTimesList.get(i).getAddress(),
playerTimesList.get(i).getNumber().toString(), TimingAcquisition.itemConfigMap.get(moneyId).getName());
text = SpeechUtil.mergeSpeech(text, addText);
if (i < playerTimesList.size() - 1) {
text = text + ";";
} else {
text = text + "。";
}
}
if (containSign) {
text += SpeechUtil.getRankingSpeech(gender, "check_rich_ranking_self_exist");
} else {
text += SpeechUtil.getRankingSpeech(gender, "check_world_rich_ranking");
}
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700101);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//查看世界战斗榜
if (Constants.FIGHT_RANKING.equals(rankingName)) {
int size = TimingAcquisition.fightRankingList.size();
if (size >= 10) {
size = 10;
}
List<PlayerTimesDto> playerTimesList = TimingAcquisition.fightRankingList.subList(0, size);
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_world_fight_ranking_pre");
for (int i = 0; i < playerTimesList.size(); i++) {
if (playerTimesList.get(i).getUid().equals(uid)) {
containSign = true;
}
String addText = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_world_fight_ranking");
addText = SpeechUtil.speechReplaceNum(addText, String.valueOf(i + 1), playerTimesList.get(i).getAddress(),
playerTimesList.get(i).getNumber().toString());
text = SpeechUtil.mergeSpeech(text, addText);
if (i < playerTimesList.size() - 1) {
text = text + ";";
} else {
text = text + "。";
}
}
if (containSign) {
text += SpeechUtil.getRankingSpeech(gender, "check_fight_ranking_self_exist");
} else {
text += SpeechUtil.getRankingSpeech(gender, "check_world_fight_ranking");
}
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700102);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//查看世界友情榜
if (Constants.FRIENDSHIP_RANKING.equals(rankingName)) {
int size = TimingAcquisition.friendshipRankingList.size();
if (size >= 10) {
size = 10;
}
List<PlayerTimesDto> playerTimesList = TimingAcquisition.friendshipRankingList.subList(0, size);
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_world_friendship_ranking_pre");
for (int i = 0; i < playerTimesList.size(); i++) {
if (playerTimesList.get(i).getUid().equals(uid)) {
containSign = true;
}
String addText = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_world_friendship_ranking");
addText = SpeechUtil.speechReplaceNum(addText, String.valueOf(i + 1), playerTimesList.get(i).getAddress(),
playerTimesList.get(i).getNumber().toString());
text = SpeechUtil.mergeSpeech(text, addText);
if (i < playerTimesList.size() - 1) {
text = text + ";";
} else {
text = text + "。";
}
}
if (containSign) {
text += SpeechUtil.getRankingSpeech(gender, "check_friendship_ranking_self_exist");
} else {
text += SpeechUtil.getRankingSpeech(gender, "check_world_friendship_ranking");
}
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700103);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_ranking_not_exist");
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700106);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
@Override
public CommonResponse checkSelfRankingList(OperationRequest operationReq) {
CommonResponse commonResponse = new CommonResponse();
ResultVarsResponse resultVarsResponse = new ResultVarsResponse();
ResultResponse resultResponse = new ResultResponse();
String uid = operationReq.getUid();
String rankingName = operationReq.getRankingName(); //榜单
String place = operationReq.getPlace(); //地区
//园丁性别
String gender = TimingAcquisition.getGardenerGender(uid);
//玩家称呼
CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid);
if (!StringUtils.isEmpty(place)) {
place = TimingAcquisition.gardenerMap.get(uid).getGarden().getZone();
}
//财富榜名次
int moneyRanking = RankingUtil.getRankingByUid(Constants.MONEY_RANKING, place, uid);
//战斗榜名次
int fightRanking = RankingUtil.getRankingByUid(Constants.FIGHT_RANKING, place, uid);
//友情榜名次
int friendshipRanking = RankingUtil.getRankingByUid(Constants.FRIENDSHIP_RANKING, place, uid);
//玩家未提供了榜单和地区,即查看世界排名
if (StringUtils.isEmpty(rankingName) && StringUtils.isEmpty(place)) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_self_ranking");
text = SpeechUtil.speechReplaceNum(text, String.valueOf(moneyRanking), String.valueOf(fightRanking), String.valueOf(friendshipRanking));
text += SpeechUtil.getRankingSpeech(gender, "check_self_ranking");
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700205);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//玩家提供了地区和榜单名
if (!StringUtils.isEmpty(rankingName) && !StringUtils.isEmpty(place)) {
String text = "";
//查看本地财富榜
if (Constants.MONEY_RANKING.equals(rankingName)) {
//获取对应话术
text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_self_local_rich_ranking");
text = SpeechUtil.speechReplaceNum(text, String.valueOf(moneyRanking));
text += SpeechUtil.getRankingSpeech(gender, "check_self_rich_ranking");
resultResponse.set反馈ID(700206);
}
//查看本地战斗榜
if (Constants.FIGHT_RANKING.equals(rankingName)) {
//获取对应话术
text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_self_local_fight_ranking");
text = SpeechUtil.speechReplaceNum(text, String.valueOf(fightRanking));
text += SpeechUtil.getRankingSpeech(gender, "check_self_fight_ranking");
resultResponse.set反馈ID(700207);
}
//查看本地友情榜
if (Constants.FRIENDSHIP_RANKING.equals(rankingName)) {
//获取对应话术
text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_self_local_friendship_ranking");
text = SpeechUtil.speechReplaceNum(text, String.valueOf(friendshipRanking));
text += SpeechUtil.getRankingSpeech(gender, "check_self_friendship_ranking");
resultResponse.set反馈ID(700208);
}
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//玩家提供了地区,但是未提供榜单名
if (StringUtils.isEmpty(rankingName) && !StringUtils.isEmpty(place)) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_self_local_ranking");
text = SpeechUtil.speechReplaceNum(text, String.valueOf(moneyRanking), String.valueOf(fightRanking), String.valueOf(friendshipRanking));
text += SpeechUtil.getRankingSpeech(gender, "check_self_ranking");
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700204);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
String text = "";
//查看世界财富榜
if (Constants.MONEY_RANKING.equals(rankingName)) {
//获取对应话术
text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_self_rich_ranking");
text = SpeechUtil.speechReplaceNum(text, String.valueOf(moneyRanking));
text += SpeechUtil.getRankingSpeech(gender, "check_self_rich_ranking");
resultResponse.set反馈ID(700201);
}
//查看世界战斗榜
if (Constants.FIGHT_RANKING.equals(rankingName)) {
//获取对应话术
text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_self_fight_ranking");
text = SpeechUtil.speechReplaceNum(text, String.valueOf(fightRanking));
text += SpeechUtil.getRankingSpeech(gender, "check_self_fight_ranking");
resultResponse.set反馈ID(700202);
}
//查看世界友情榜
if (Constants.FRIENDSHIP_RANKING.equals(rankingName)) {
//获取对应话术
text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_self_friendship_ranking");
text = SpeechUtil.speechReplaceNum(text, String.valueOf(friendshipRanking));
text += SpeechUtil.getRankingSpeech(gender, "check_self_friendship_ranking");
resultResponse.set反馈ID(700203);
}
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
@Override
public CommonResponse checkPlayerRankingList(OperationRequest operationReq) {
CommonResponse commonResponse = new CommonResponse();
ResultVarsResponse resultVarsResponse = new ResultVarsResponse();
ResultResponse resultResponse = new ResultResponse();
String uid = operationReq.getUid();
String rankingName = operationReq.getRankingName(); //榜单
String place = operationReq.getPlace(); //地区
String address = operationReq.getAddress(); //玩家地址
//园丁性别
String gender = TimingAcquisition.getGardenerGender(uid);
//玩家称呼
CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid);
boolean find = false;
//1.通过玩家地址拜访时
if (!StringUtils.isEmpty(address)) {
//查看各地区是否存在该玩家地址
String placeTmp = TypeConvertUtil.extractChinese(address);
Map<String, RegionDto> regionMap = TimingAcquisition.addressMap.get(placeTmp);
//对方地区存在
if (!StringUtils.isEmpty(regionMap)) {
RegionDto region = regionMap.get(address);
//对方玩家地址存在
if (!StringUtils.isEmpty(region)) {
find = true;
}
}
}
//玩家地址不存在
if (!find) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_player_ranking_not_exist");
text += SpeechUtil.getRankingSpeech(gender, "check_player_ranking_not_exist");
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700301);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
if (!StringUtils.isEmpty(place)) {
place = TimingAcquisition.gardenerMap.get(uid).getGarden().getZone();
}
if (place.equals("本地") || place.equals("本地区")) {
place = TimingAcquisition.gardenerMap.get(uid).getGarden().getZone();
}
List<String> regionList = new ArrayList<>(TimingAcquisition.regionIPMap.keySet());
//玩家提供的地址不存在
if (!regionList.contains(place)) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_ranking_wrong_place");
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700310);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//货币配置信息
Integer moneyId = Integer.parseInt(TimingAcquisition.systemConfigMap.get("money").getValue());
ItemPojo moneyConfig = TimingAcquisition.itemConfigMap.get(moneyId);
String placeTmp = TypeConvertUtil.extractChinese(address);
String uidSide = TimingAcquisition.addressMap.get(placeTmp).get(address).getUid(); //指定玩家的uid
//财富榜名次
int moneyRanking = RankingUtil.getRankingByUid(Constants.MONEY_RANKING, place, uidSide);
//战斗榜名次
int fightRanking = RankingUtil.getRankingByUid(Constants.FIGHT_RANKING, place, uidSide);
//友情榜名次
int friendshipRanking = RankingUtil.getRankingByUid(Constants.FRIENDSHIP_RANKING, place, uidSide);
//玩家未提供了榜单和地区,即查看世界排名
if (StringUtils.isEmpty(rankingName) && StringUtils.isEmpty(place)) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_player_ranking");
text = SpeechUtil.speechReplaceNum(text, address, String.valueOf(moneyRanking), String.valueOf(fightRanking), String.valueOf(friendshipRanking));
text += SpeechUtil.getRankingSpeech(gender, "check_player_ranking");
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700306);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//玩家提供了地区和榜单名
if (!StringUtils.isEmpty(rankingName) && !StringUtils.isEmpty(place)) {
String text = "";
//查看本地财富榜
if (Constants.MONEY_RANKING.equals(rankingName)) {
//获取对应话术
text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_player_local_rich_ranking");
text = SpeechUtil.speechReplaceNum(text, address, place, String.valueOf(moneyRanking));
//本地人数
int population = TimingAcquisition.regionMoneyRankingListMap.get(place).size();
if (moneyRanking <= population * 0.4) {
text += SpeechUtil.getRankingSpeech(gender, "check_player_local_rich_ranking_more");
} else {
text += SpeechUtil.getRankingSpeech(gender, "check_player_local_rich_ranking");
}
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
resultResponse.set反馈ID(700307);
}
//查看本地战斗榜
if (Constants.FIGHT_RANKING.equals(rankingName)) {
//获取对应话术
text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_player_local_fight_ranking");
text = SpeechUtil.speechReplaceNum(text, address, place, String.valueOf(fightRanking));
text += SpeechUtil.getRankingSpeech(gender, "check_player_local_rich_ranking");
resultResponse.set反馈ID(700308);
}
//查看本地友情榜
if (Constants.FRIENDSHIP_RANKING.equals(rankingName)) {
//获取对应话术
text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_player_local_friendship_ranking");
text = SpeechUtil.speechReplaceNum(text, address, place, String.valueOf(friendshipRanking));
text += SpeechUtil.getRankingSpeech(gender, "check_player_local_rich_ranking");
resultResponse.set反馈ID(700309);
}
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//玩家提供了地区,但是未提供榜单名
if (StringUtils.isEmpty(rankingName) && !StringUtils.isEmpty(place)) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_player_local_ranking");
text = SpeechUtil.speechReplaceNum(text, address, place, String.valueOf(moneyRanking), String.valueOf(fightRanking), String.valueOf(friendshipRanking));
text += SpeechUtil.getRankingSpeech(gender, "check_player_local_ranking");
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700305);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
String text = "";
//查看世界财富榜
if (Constants.MONEY_RANKING.equals(rankingName)) {
//获取对应话术
text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_player_rich_ranking");
text = SpeechUtil.speechReplaceNum(text, address, String.valueOf(moneyRanking));
//所有人数
int population = TimingAcquisition.moneyRankingList.size();
if (moneyRanking < population * 0.4) {
text += SpeechUtil.getRankingSpeech(gender, "check_player_rich_ranking_more");
} else {
text += SpeechUtil.getRankingSpeech(gender, "check_player_rich_ranking");
}
resultResponse.set反馈ID(700302);
}
//查看世界战斗榜
if (Constants.FIGHT_RANKING.equals(rankingName)) {
//获取对应话术
text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_player_fight_ranking");
text = SpeechUtil.speechReplaceNum(text, address, String.valueOf(fightRanking));
text += SpeechUtil.getRankingSpeech(gender, "check_player_fight_ranking");
resultResponse.set反馈ID(700303);
}
//查看世界友情榜
if (Constants.FRIENDSHIP_RANKING.equals(rankingName)) {
//获取对应话术
text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_player_friendship_ranking");
text = SpeechUtil.speechReplaceNum(text, address, String.valueOf(friendshipRanking));
text += SpeechUtil.getRankingSpeech(gender, "check_player_friendship_ranking");
resultResponse.set反馈ID(700304);
}
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName(), moneyConfig.getName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
@Override
public CommonResponse visitRankingPlayer(OperationRequest operationReq) {
CommonResponse commonResponse = new CommonResponse();
ResultVarsResponse resultVarsResponse = new ResultVarsResponse();
ResultResponse resultResponse = new ResultResponse();
String uid = operationReq.getUid();
String rankingName = operationReq.getRankingName(); //榜单
String place = operationReq.getPlace(); //地区
Integer rankNumber = operationReq.getRankNumber(); //名次
log.info(uid + "开始拜访榜单上的玩家,对应名次为:" + rankNumber + ",地区:" + place + ",榜单:" + rankingName);
//园丁性别
String gender = TimingAcquisition.getGardenerGender(uid);
//玩家称呼
CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid);
String address = "";
//玩家指定了地区
if (!StringUtils.isEmpty(place)) {
if (place.equals("本地") || place.equals("本地区")) {
place = TimingAcquisition.gardenerMap.get(uid).getGarden().getZone();
}
List<String> regionList = new ArrayList<>(TimingAcquisition.regionIPMap.keySet());
//玩家提供的地址不存在
if (!regionList.contains(place)) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_ranking_wrong_place");
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700408);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//该地区还没有人进行排名
if (StringUtils.isEmpty(TimingAcquisition.regionMoneyRankingListMap.get(place))) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_ranking_place_no_player");
text = SpeechUtil.speechReplaceNum(text, place);
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700409);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//该地区还没有人进行排名
if (TimingAcquisition.regionMoneyRankingListMap.get(place).size() == 0) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_ranking_place_no_player");
text = SpeechUtil.speechReplaceNum(text, place);
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700410);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//名次越界
if (rankNumber > TimingAcquisition.regionMoneyRankingListMap.get(place).size()) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "visit_ranking_player_not_exist");
text += SpeechUtil.getRankingSpeech(gender, "visit_ranking_player_not_exist");
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700401);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//查看地区财富榜
if (Constants.MONEY_RANKING.equals(rankingName)) {
//根据名次获取玩家地址
address = TimingAcquisition.regionMoneyRankingListMap.get(place).get(rankNumber - 1).getAddress();
}
//查看地区战斗榜
if (Constants.FIGHT_RANKING.equals(rankingName)) {
//根据名次获取玩家地址
address = TimingAcquisition.regionFightRankingListMap.get(place).get(rankNumber - 1).getAddress();
}
//查看地区友情榜
if (Constants.FRIENDSHIP_RANKING.equals(rankingName)) {
//根据名次获取玩家地址
address = TimingAcquisition.regionFriendShipRankingListMap.get(place).get(rankNumber - 1).getAddress();
}
} else { //未指定地区
//名次越界
if (rankNumber > TimingAcquisition.moneyRankingList.size()) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "visit_ranking_player_not_exist");
text += SpeechUtil.getRankingSpeech(gender, "visit_ranking_player_not_exist");
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700402);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//查看世界财富榜
if (Constants.MONEY_RANKING.equals(rankingName)) {
//根据名次获取玩家地址
address = TimingAcquisition.moneyRankingList.get(rankNumber - 1).getAddress();
}
//查看世界战斗榜
if (Constants.FIGHT_RANKING.equals(rankingName)) {
//根据名次获取玩家地址
address = TimingAcquisition.fightRankingList.get(rankNumber - 1).getAddress();
}
//查看世界友情榜
if (Constants.FRIENDSHIP_RANKING.equals(rankingName)) {
//根据名次获取玩家地址
address = TimingAcquisition.friendshipRankingList.get(rankNumber - 1).getAddress();
}
}
//访问对象为玩家本人
if (TimingAcquisition.gardenerMap.get(uid).getLocation().equals(address)) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(gender, "visit_stranger_check_fail_self");
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700403);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//对方玩家地址对应的地区
String strangerPlace = TypeConvertUtil.extractChinese(address);
String placeTmp = TimingAcquisition.gardenerMap.get(uid).getGarden().getZone();
//跨域访问
if (!strangerPlace.equals(placeTmp)) {
//跨域访问的费用
int crossRegionCost = Integer.parseInt(TimingAcquisition.systemConfigMap.get("cross_region_cost").getValue());
//货币配置信息
Integer moneyId = Integer.parseInt(TimingAcquisition.systemConfigMap.get("money").getValue());
//货币的配置信息
ItemPojo moneyConfig = TimingAcquisition.itemConfigMap.get(moneyId);
//根据种类id取出背包里的钱
ItemDto moneyBag = TimingAcquisition.gardenerMap.get(uid).getBackPack().getItemBags().get(moneyConfig.getItemTypeId()).getItems(moneyId);
Integer money = moneyBag.getItemNum();
//玩家货币数量不够跨地区
if (money < crossRegionCost) {
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "visit_stranger_check_cross_fail");
text = SpeechUtil.speechReplaceNum(text, money.toString(), moneyConfig.getName(), String.valueOf(crossRegionCost));
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700404);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//bot端需要该标识来识别当前位置非本地
resultResponse.set玩家当前位置("非本人");
//保存玩家这轮的请求信息,用于下一步的确认操作
operationReq.setAddress(address);
operationReq.setOperationLabel(Constants.VISIT_STRANGER);
CacheUtil.put(uid, operationReq, Long.parseLong(expireTime));
//获取好友列表
List<FriendDto> friendList = TimingAcquisition.gardenerMap.get(uid).getFriendList(); //玩家好友列表
if (StringUtils.isEmpty(friendList)) {
resultResponse.set后台附加返回("拜访不同地区陌生人");
} else {
if (friendList.size() == 0) {
resultResponse.set后台附加返回("拜访不同地区陌生人");
} else {
//对方已经是好友
List<String> addressList = friendList.stream().map(FriendDto::getAddress).collect(Collectors.toList());
if (addressList.contains(address)) {
resultResponse.set后台附加返回("拜访不同地区好友");
} else {
resultResponse.set后台附加返回("拜访不同地区陌生人");
}
}
}
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "visit_ranking_player_cross_check");
text = SpeechUtil.speechReplaceNum(text, strangerPlace, Integer.toString(crossRegionCost), moneyConfig.getName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700405);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//------------------同地区访问-------------------
//bot端需要该标识来识别当前位置非本地
resultResponse.set玩家当前位置("非本人");
//对方为好友
List<FriendDto> friendList = TimingAcquisition.gardenerMap.get(uid).getFriendList(); //玩家好友列表
if (!StringUtils.isEmpty(friendList)) {
//对方已经是好友
List<String> addressList = friendList.stream().map(FriendDto::getAddress).collect(Collectors.toList());
if (addressList.contains(address)) {
//保存玩家这轮的请求信息,用于下一步的操作
operationReq.setAddress(address);
CacheUtil.put(uid, operationReq, Long.parseLong(expireTime));
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "visit_ranking_player_is_friend");
text = SpeechUtil.speechReplaceNum(text, rankingName, rankNumber.toString(), address);
text += SpeechUtil.getRankingSpeech(gender, "visit_ranking_player_is_friend");
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700406);
resultResponse.set反馈文本(text);
resultResponse.set后台附加返回("访问榜单3");
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
}
//保存玩家这轮的请求信息,用于下一步的操作
operationReq.setAddress(address);
operationReq.setOperationLabel(Constants.VISIT_STRANGER);
CacheUtil.put(uid, operationReq, Long.parseLong(expireTime));
//获取对应话术
String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "visit_ranking_player_success");
text = SpeechUtil.speechReplaceNum(text, rankingName, rankNumber.toString(), address);
text += SpeechUtil.getRankingSpeech(gender, "visit_ranking_player_success");
text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(700407);
resultResponse.set反馈文本(text);
resultResponse.set后台附加返回("是否添加好友");
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
}
...@@ -1063,6 +1063,7 @@ public class SocialServiceImpl implements SocialService { ...@@ -1063,6 +1063,7 @@ public class SocialServiceImpl implements SocialService {
friend.setName(nameTmp); friend.setName(nameTmp);
friend.setStatus(Constants.OFFLINE); friend.setStatus(Constants.OFFLINE);
friend.setHelpTag(Constants.HELP_NO_SIGN); friend.setHelpTag(Constants.HELP_NO_SIGN);
friend.setHelpNumber(0);
//玩家的好友列表 //玩家的好友列表
List<FriendDto> friendList = gardener.getFriendList(); List<FriendDto> friendList = gardener.getFriendList();
if (StringUtils.isEmpty(friendList)) { if (StringUtils.isEmpty(friendList)) {
...@@ -3604,6 +3605,7 @@ public class SocialServiceImpl implements SocialService { ...@@ -3604,6 +3605,7 @@ public class SocialServiceImpl implements SocialService {
//该好友标记为已帮助 //该好友标记为已帮助
friend.setHelpTag(Constants.HELP_HAVE_SIGN); friend.setHelpTag(Constants.HELP_HAVE_SIGN);
friend.setHelpTime(nowTime); friend.setHelpTime(nowTime);
friend.setHelpNumber(friend.getHelpNumber() + 1); //该好友已帮助次数
//--------------持久化该园丁信息--------------- //--------------持久化该园丁信息---------------
Map<String, GardenerDto> gardenerMap = new ConcurrentHashMap<>(); Map<String, GardenerDto> gardenerMap = new ConcurrentHashMap<>();
gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid));
......
#存放路径已改为:/home/secretGarden/secretGardenSpeech/
aside:
check_ranking_wrong_place:
- 【旁白@正常】没有你说的地区,看看其他的吧。
check_ranking_place_no_player:
- 【旁白@正常】【1】还是一片荒芜之地,暂无人居住。
#查看富豪榜
check_world_ranking_no_name:
- 【旁白@正常】排行榜分为富豪榜、战斗榜、友情榜,榜单每天刷新一次,更新榜上玩家财富、战斗成功次数、帮助好友收菜次数的排名。
check_ranking_not_exist:
- 【旁白@正常】目前还没有这个排行榜。现有富豪榜、战斗榜、友情榜,榜单每天刷新一次,更新榜上玩家财富、战斗成功次数、帮助好友收菜次数的排名。
check_world_rich_ranking_pre:
- 【旁白@正常】花园世界
check_world_rich_ranking:
- 【旁白@正常】第【1】富翁是【2】,拥有【3】个【4】
#查看战斗榜
check_world_fight_ranking_pre:
- 【旁白@正常】战斗榜
check_world_fight_ranking:
- 【旁白@正常】第【1】名是【2】,一共击败过【3】个对手
#查看友情榜
check_world_friendship_ranking_pre:
- 【旁白@正常】花园世界人缘
check_world_friendship_ranking:
- 【旁白@正常】第【1】的【2】,一共帮助好友收菜【3】次
#查看地区富豪榜
check_region_rich_ranking_pre:
- 【旁白@正常】【1】区域富豪榜
check_region_rich_ranking:
- 【旁白@正常】第【1】名是【2】,拥有【3】个【4】
#查看地区战斗榜
check_region_fight_ranking_pre:
- 【旁白@正常】【1】区域战斗榜
check_region_fight_ranking:
- 【旁白@正常】第【1】名是【2】,战斗胜利【3】次
#查看地区友情榜
check_region_friendship_ranking_pre:
- 【旁白@正常】【1】区域人缘
check_region_friendship_ranking:
- 【旁白@正常】第【1】名是【2】,共帮助好友收获植物【3】次
#查看本人排名
check_self_rich_ranking:
- 【旁白@正常】你在富豪榜上排名为第【1】名。
check_self_fight_ranking:
- 【旁白@正常】你在战斗榜上排名为第【1】名。
check_self_friendship_ranking:
- 【旁白@正常】你在友情榜上排名为第【1】名。
check_self_ranking:
- 【旁白@正常】你在富豪榜上排名为第【1】名。你在战斗榜上排名为第【2】名。你在友情榜上排名为第【3】名。
check_self_local_rich_ranking:
- 【旁白@正常】你在本地区的富豪榜上排名为第【1】名。
check_self_local_fight_ranking:
- 【旁白@正常】你在本地区的战斗榜上排名为第【1】名。
check_self_local_friendship_ranking:
- 【旁白@正常】你在本地区的友情榜上排名为第【1】名。
check_self_local_ranking:
- 【旁白@正常】你在本地区的富豪榜上排名为第【1】名。你在战斗榜上排名为第【2】名。你在友情榜上排名为第【3】名。
#查看玩家排名
check_player_rich_ranking:
- 【旁白@正常】玩家【1】在富豪榜上排名为第【2】名。
check_player_fight_ranking:
- 【旁白@正常】玩家【1】在战斗榜上排名为第【2】名。
check_player_friendship_ranking:
- 【旁白@正常】玩家【1】在友情榜上排名为第【2】名。
check_player_ranking:
- 【旁白@正常】玩家【1】在富豪榜上排名为第【2】名。在战斗榜上排名为第【3】名。在友情榜上排名为第【4】名。
check_player_local_rich_ranking:
- 【旁白@正常】玩家【1】在【2】地区的富豪榜上排名为第【3】名。
check_player_local_fight_ranking:
- 【旁白@正常】玩家【1】在【2】地区的战斗榜上排名为第【3】名。
check_player_local_friendship_ranking:
- 【旁白@正常】玩家【1】在【2】地区的友情榜上排名为第【3】名。
check_player_local_ranking:
- 【旁白@正常】玩家【1】在【2】地区的富豪榜上排名为第【3】名。在战斗榜上排名为第【4】名。在友情榜上排名为第【5】名。
check_player_ranking_not_exist:
- 【旁白@正常】找不到这个玩家,换一个人试试看吧。
#访问榜单上的玩家
visit_ranking_player_not_exist:
- 【旁白@正常】找不到这个名次的玩家。再试试其他人的吧。
visit_ranking_player_success:
- 【旁白@正常】已成功进入【1】第【2】名【3】的花园。
visit_ranking_player_cross_check:
- 【旁白@正常】拜访对方需要前往【1】地区,并消耗【1】个【2】,确定拜访?
visit_ranking_player_cross_success:
- 【旁白@正常】拜访成功,已进入榜单第【1】名【2】的花园。
visit_ranking_player_is_friend:
- 【旁白@正常】成功进入【1】排名第【2】名【3】的花园。
man:
check_rich_ranking_self_exist:
- 【男园丁@正常】【1】【2】也在榜上,恭喜!
check_fight_ranking_self_exist:
- 【男园丁@正常】【1】【2】也在这个榜上啊……怎么说呢,还是恭喜吧!
check_friendship_ranking_self_exist:
- 【男园丁@正常】我真欣慰啊,看来【1】热心帮助朋友们收菜的事情得到了认可!
check_world_ranking_no_name:
- 【男园丁@正常】【1】想先看哪一个榜单?
- 【男园丁@正常】每一个榜单都汇集了不同领域的拔尖者。
- 【男园丁@正常】说不定榜单上面就有【1】认识的朋友。
#查看富豪榜
check_world_rich_ranking:
- 【男园丁@正常】真有钱啊,我相信总有一天【1】也能登上这个榜单。
#查看战斗榜
check_world_fight_ranking:
- 【男园丁@正常】还好还好,【1】的实力不容小觑。
#查看友情榜
check_world_friendship_ranking:
- 【男园丁@正常】下一次,【1】的名字一定会在榜上对吧?
#查看地区富豪榜
check_region_rich_ranking:
- 【男园丁@正常】真有钱啊,我相信总有一天【1】也能登上这个榜单。
#查看地区战斗榜
check_region_fight_ranking:
- 【男园丁@正常】还好还好,【1】的实力不容小觑。
#查看地区友情榜
check_region_friendship_ranking:
- 【男园丁@正常】下一次,【1】一定会在榜上对吧?
#查看本人排名
check_self_rich_ranking:
- 【男园丁@正常】越攒越多,【1】真棒,已经算是个富翁了。
check_self_fight_ranking:
- 【男园丁@正常】我需要继续努力。
check_self_friendship_ranking:
- 【男园丁@正常】这个榜单的排名越高,就证明在其他好友的心中对【1】的认可度越高哦。
check_self_ranking:
- 【男园丁@正常】越努力才会越幸运,【1】加油。
- 【男园丁@正常】就是为了开心才玩的,【1】不必在意这些东西。
- 【男园丁@正常】排名都是身外之物,只有【2】的开心才是最重要的。
#查看玩家排名
check_player_rich_ranking_more:
- 【男园丁@正常】相信有一天我们也能攒到这么多的。
check_player_rich_ranking:
- 【男园丁@正常】也有不少了,我们也继续努力吧。
check_player_fight_ranking:
- 【男园丁@正常】我们也继续努力。
check_player_friendship_ranking:
- 【男园丁@正常】有空也帮帮朋友。
check_player_ranking:
- 【男园丁@正常】越努力才会越幸运,【1】加油。
check_player_local_rich_ranking_more:
- 【男园丁@正常】我们也朝着这个目标前进吧。
check_player_local_rich_ranking:
- 【男园丁@正常】看起来还行,我们也可以更进一步的。
check_player_local_fight_ranking:
- 【男园丁@正常】我们也继续努力。
check_player_local_friendship_ranking:
- 【男园丁@正常】有空也帮帮朋友。
check_player_local_ranking:
- 【男园丁@正常】越努力才会越幸运,主人加油。
check_player_ranking_not_exist:
- 【男园丁@正常】看看其他人的吧。
#访问榜单上的玩家
visit_ranking_player_not_exist:
- 【男园丁@正常】那我们再找找看吧。
visit_ranking_player_success:
- 【男园丁@正常】不如加个好友认识?你们以后也好相互有个照料。
- 【男园丁@正常】你和他还不是好友,要不要加一个,下次也方便再来。
- 【男园丁@正常】他的花圃看起来还不错,看来平时没少用心打理,需不需要加个好友?以后你们也好一起交流花园的心得。
visit_ranking_player_cross_success:
- 【男园丁@正常】【1】,可以和对方加个好友,方便以后再来拜访。
visit_ranking_player_is_friend:
- 【男园丁@正常】这个人是【1】的好友,要不要去对方的花圃看看?
- 【男园丁@正常】没想到在排行榜上都能遇到好友,【1】【2】的社交圈不容小觑。走吧,我们去对方的花圃逛逛。
- 【男园丁@正常】这花园打理的还不错,要去四周看看吗?
woman:
check_rich_ranking_self_exist:
- 【女园丁@正常】我看到【1】了,真是太好了!
check_fight_ranking_self_exist:
- 【女园丁@正常】【1】【2】竟然上了这个榜……不知道是该为你高兴还是……
check_friendship_ranking_self_exist:
- 【女园丁@正常】能登上这个榜,一定是【1】的朋友们对【2】的肯定!
check_world_ranking_no_name:
- 【女园丁@正常】能在这些榜单上有名字的玩家都超级厉害啊!【1】要不要去看看?
- 【女园丁@正常】不知道【1】会不会出现在上面,我们快去看看吧!
- 【女园丁@正常】好羡慕这些榜上有名的人,他们都值得我好好学习呢!
#查看富豪榜
check_world_rich_ranking:
- 【女园丁@正常】原来这就是富豪榜……不知道什么时候能在上面看到【1】的名字。
#查看战斗榜
check_world_fight_ranking:
- 【女园丁@正常】要是上了这个榜单,形象一定会大打折扣……还好【1】的名字没在上面!
#查看友情榜
check_world_friendship_ranking:
- 【女园丁@正常】没关系,下一次我相信【1】一定会在上面!
#查看地区富豪榜
check_region_rich_ranking:
- 【女园丁@正常】真有钱啊,我相信总有一天【1】也能登上这个榜单。
#查看地区战斗榜
check_region_fight_ranking:
- 【女园丁@正常】还好还好,【1】的实力不容小觑。
#查看地区友情榜
check_region_friendship_ranking:
- 【女园丁@正常】下一次,【1】一定会在榜上对吧?
#查看本人排名
check_self_rich_ranking:
- 【女园丁@正常】【1】积攒的努力没有白费,排名足以说明一切!
check_self_fight_ranking:
- 【女园丁@正常】嗯……怎么说呢……我不希望【1】的名字出现在这个榜单上。
check_self_friendship_ranking:
- 【女园丁@正常】热心帮助好友收菜,次数越多,排名也会随之上升的。
check_self_ranking:
- 【女园丁@正常】排名多少都没有关系,最重要的是【1】要天天开心!
- 【女园丁@正常】【1】也想名列前茅吗?哈哈,那我就要陪【2】一起努力了!
- 【女园丁@正常】排名只是一个数字啦……就算不靠前也没关系的,你还有我陪着【2】啊【1】!
#查看玩家排名
check_player_rich_ranking_more:
- 【女园丁@正常】好多【3】,【1】积攒的也不少,如果你在意的话,我努力和你一起攒【3】。
check_player_rich_ranking:
- 【女园丁@正常】看着还行,不过我相信【1】一定能攒更多的。
check_player_fight_ranking:
- 【女园丁@正常】我们也继续努力。
check_player_friendship_ranking:
- 【女园丁@正常】有空也帮帮朋友。
check_player_ranking:
- 【女园丁@正常】越努力才会越幸运,【1】加油。
check_player_local_rich_ranking_more:
- 【女园丁@正常】我陪【1】一起攒【3】,争取早日到榜首。
check_player_local_rich_ranking:
- 【女园丁@正常】【1】,【2】肯定有办法攒更多,嘻嘻。
check_player_local_fight_ranking:
- 【女园丁@正常】我们也继续努力。
check_player_local_friendship_ranking:
- 【女园丁@正常】有空也帮帮朋友。
check_player_local_ranking:
- 【女园丁@正常】越努力才会越幸运,【1】加油。
check_player_ranking_not_exist:
- 【女园丁@正常】可以去看看其他人的哦。
#访问榜单上的玩家
visit_ranking_player_not_exist:
- 【女园丁@正常】那我们再找找看吧。
visit_ranking_player_success:
- 【女园丁@正常】【1】可以加一下对方的好友,方便以后再来拜访!
- 【女园丁@正常】加了这个花园主人的好友,以后我们就可以随时来逛他的花园了!
- 【女园丁@正常】他的花圃真漂亮,能打理出这么漂亮花圃的人一定是个很不错的人,【1】可以试试添加对方为好友,说不定你们会很聊得来!
visit_ranking_player_cross_success:
- 【女园丁@正常】申请成为好友,以后再来拜访对方的花园更方便哦【1】!
visit_ranking_player_is_friend:
- 【女园丁@正常】这也能拜访到好友的花园,【1】【2】的社交圈子可真广!我们快去看看他的花圃吧。
- 【女园丁@正常】我已经迫不及待的想去看这家的花圃是什么样子了,我们走吧?
- 【女园丁@正常】他的花园弄得可真棒啊,我要拿笔记本一点点记录下来……【1】【2】再陪我去逛逛花圃吧?
\ No newline at end of file
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