Commit af15c40b by 周君强

1.bug修复、代码调整,系统优化;

2.社交模块实现。
parent a8855b17
......@@ -2,5 +2,6 @@
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
......@@ -7,6 +7,26 @@
<groupId>org.example</groupId>
<artifactId>SecretGradeGame</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>secretGradeGame</name>
<build>
<finalName>secretGardenGame</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<parent>
<groupId>org.springframework.boot</groupId>
......@@ -22,6 +42,12 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
......@@ -44,6 +70,10 @@
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
......@@ -61,19 +91,9 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>RELEASE</version>
<version>1.18.24</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.12</version>
</dependency>
</dependencies>
<properties>
......
......@@ -3,31 +3,62 @@ package com.qiwuai.garden.common;
public class Constants {
/**
* 玩家离线-0
*/
public static final int OFFLINE = 0;
/**
* 玩家在线-1
*/
public static final int ONLINE = 1;
/**
* 玩家初始等级
*/
public static final int INITIAL_LV = 1;
/**
* 背包
* 货币-1
*/
public static final int ITEM_TYPE_MONEY = 1;
/**
* 果实-3
* 果实-2
*/
public static final int ITEM_TYPE_FRUIT = 2;
/**
* 材料-4
* 材料-3
*/
public static final int ITEM_TYPE_MATERIAL = 3;
/**
* 其他-5
* 其他-4
*/
public static final int ITEM_TYPE_OTHER = 4;
/**
* 货币
*/
public static final int MONEY = 1;
public static final int TYPE_MONEY = 1;
/**
* 其他
* 物品
*/
public static final int OTHER = 5;
public static final int TYPE_ITEM = 2;
/**
* 宠物
*/
public static final int TYPE_PET = 3;
/**
* 很少
*/
public static final String FEW = "few";
/**
* 很多
*/
public static final String LOT = "lot";
/**
......@@ -89,6 +120,22 @@ public class Constants {
* 请求的名称随机
*/
public static final int REQ_RANDOM = -2;
/**
* 请求的数量为"都", "统统", "全数", "所有", "全", "全部", "全都", "一起"之类
*/
public static final int REQ_ALL = -3;
/**
* 请求的名称为首个、首位之类
*/
public static final int REQ_FIRST = -4;
/**
* 请求的名称为中间
*/
public static final int REQ_MIDDLE = -5;
/**
* 请求的名称为最后
*/
public static final int REQ_LAST = -6;
......@@ -116,5 +163,114 @@ public class Constants {
* 帮助好友
*/
public static final int HELP_EVENT = 4;
/**
* 日常任务
*/
public static final int DAILY_TASK_EVENT = 5;
/**
* 获得宠物
*/
public static final int GET_PET_EVENT = 6;
/**
* 开启花圃
*/
public static final int RECLAIM_NURSERY_EVENT = 7;
/**
* 偷菜
*/
public static final int STEAL_EVENT = 8;
/**
* 帮助标记:0-未帮助
*/
public static final int HELP_NO_SIGN = 0;
/**
* 帮助标记:1-已帮助
*/
public static final int HELP_HAVE_SIGN = 1;
/**
* 话术-旁白
*/
public static final String SPEECH_ASIDE = "aside";
/**
* 话术-男园丁
*/
public static final String SPEECH_MAN = "man";
/**
* 话术-女园丁
*/
public static final String SPEECH_WOMAN = "woman";
/**
* 好友申请消息提醒
*/
public static final String ADD_FRIEND_NOTICE = "addFriend";
/**
* 帮助简报消息提醒
*/
public static final String HELP_REPORT_NOTICE = "helpReport";
/**
* 偷菜简报消息提醒
*/
public static final String STEAL_REPORT_NOTICE = "stealReport";
/**
* 任务消息提醒
*/
public static final String TASK_NOTICE = "task";
/**
* 未成熟-0
*/
public static final Integer MATURE_NO = 0;
/**
* 成熟-1
*/
public static final Integer MATURE_YES = 1;
/**
* 花圃空闲-0
*/
public static final Integer NURSERY_FREE = 0;
/**
* 花圃忙碌-1
*/
public static final Integer NURSERY_BUSY = 1;
/**
* 不存在-0
*/
public static final Integer NON = 0;
/**
* 防守失败-0
*/
public static final Integer DEFEND_FAIL = 0;
/**
* 防守成功-1
*/
public static final Integer DEFEND_SUCCESS = 1;
/**
* 简报未读-0
*/
public static final Integer READ_NO = 0;
/**
* 简报已读-1
*/
public static final Integer READ_YES = 1;
/**
* 数据存放地址
*/
public static final String userFilePath = "/home/qwyf14/dataBackup/";
}
package com.qiwuai.garden.common;
import com.qiwuai.garden.common.utils.TypeConvertUtil;
import com.qiwuai.garden.dao.*;
import com.qiwuai.garden.dto.AddItemDto;
import com.qiwuai.garden.dto.AddItemSetDto;
import com.qiwuai.garden.dto.GardenerDto;
import com.qiwuai.garden.dto.GardenerSkillDto;
import com.qiwuai.garden.dto.PlantPeriodDto;
import com.qiwuai.garden.dto.RegionDto;
import com.qiwuai.garden.pojo.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@Component
public class InitSysServlet implements InitializingBean {
......@@ -23,7 +28,7 @@ public class InitSysServlet implements InitializingBean {
private NurseryMapper nurseryMapper;
private PlantPeriodMapper plantPeriodMapper;
private PlantMapper plantMapper;
private PlantAttributeMapper plantAttributeMapper;
private AttributeMapper attributeMapper;
private AddItemSetMapper addItemSetMapper;
private AddItemMapper addItemMapper;
private ItemMapper itemMapper;
......@@ -37,6 +42,9 @@ public class InitSysServlet implements InitializingBean {
private SkillResetCostMapper skillResetCostMapper;
private ItemTypeMapper itemTypeMapper;
private GoodsMapper goodsMapper;
private QuantityRangeMapper quantityRangeMapper;
private RegionMapper regionMapper;
private RarityMapper rarityMapper;
@Autowired
public void setNurseryMapper(NurseryMapper nurseryMapper) {
......@@ -54,8 +62,8 @@ public class InitSysServlet implements InitializingBean {
}
@Autowired
public void setPlantAttributeMapper(PlantAttributeMapper plantAttributeMapper) {
this.plantAttributeMapper = plantAttributeMapper;
public void setAttributeMapper(AttributeMapper attributeMapper) {
this.attributeMapper = attributeMapper;
}
@Autowired
......@@ -123,6 +131,21 @@ public class InitSysServlet implements InitializingBean {
this.goodsMapper = goodsMapper;
}
@Autowired
public void setQuantityRangeMapper(QuantityRangeMapper quantityRangeMapper) {
this.quantityRangeMapper = quantityRangeMapper;
}
@Autowired
public void setRegionMapper(RegionMapper regionMapper) {
this.regionMapper = regionMapper;
}
@Autowired
public void setRarityMapper(RarityMapper rarityMapper) {
this.rarityMapper = rarityMapper;
}
/**
* 保存配置信息到缓存
*/
......@@ -161,14 +184,14 @@ public class InitSysServlet implements InitializingBean {
log.info("缓存中植物配置信息:" + TimingAcquisition.plantMap);
log.info("植物配置缓存完成");
//缓存植物属性配置信息
Map<Integer, PlantAttributePojo> plantAttributePojoMap = new ConcurrentHashMap<>();
List<PlantAttributePojo> plantAttributeList = plantAttributeMapper.searchAll();
for (PlantAttributePojo plantAttribute : plantAttributeList) {
plantAttributePojoMap.put(plantAttribute.getId(), plantAttribute);
//缓存属性配置信息
Map<Integer, AttributePojo> attributePojoMap = new ConcurrentHashMap<>();
List<AttributePojo> attributeList = attributeMapper.searchAll();
for (AttributePojo attribute : attributeList) {
attributePojoMap.put(attribute.getId(), attribute);
}
TimingAcquisition.plantAttributeMap.putAll(plantAttributePojoMap);
log.info("缓存中植物属性配置信息:" + TimingAcquisition.plantAttributeMap);
TimingAcquisition.attributeMap.putAll(attributePojoMap);
log.info("缓存中植物属性配置信息:" + TimingAcquisition.attributeMap);
log.info("植物属性配置缓存完成");
//缓存植物生长周期信息
......@@ -327,5 +350,76 @@ public class InitSysServlet implements InitializingBean {
TimingAcquisition.goodsConfigMap.putAll(goodsConfigMap);
log.info("缓存中商品配置信息" + TimingAcquisition.goodsConfigMap);
log.info("商品配置信息缓存完成");
//缓存稀有度配置信息
Map<Integer, RarityPojo> rarityMap = new ConcurrentHashMap<>();
List<RarityPojo> rarityList = rarityMapper.findAll();
for (RarityPojo rarity : rarityList) {
rarityMap.put(rarity.getId(), rarity);
}
TimingAcquisition.rarityMap.putAll(rarityMap);
log.info("缓存中稀有度配置信息" + TimingAcquisition.rarityMap);
log.info("稀有度配置信息缓存完成");
//缓存数量范围配置信息
Map<Integer, QuantityRangePojo> quantityRangeMap = new ConcurrentHashMap<>();
List<QuantityRangePojo> quantityRangeList = quantityRangeMapper.findAll();
for (QuantityRangePojo quantityRange : quantityRangeList) {
quantityRangeMap.put(quantityRange.getId(), quantityRange);
}
TimingAcquisition.quantityRangeMap.putAll(quantityRangeMap);
log.info("缓存中数量范围配置信息" + TimingAcquisition.quantityRangeMap);
log.info("数量范围配置信息缓存完成");
//缓存地区与服务器对应信息
Map<String, RegionPojo> regionIPMap = new ConcurrentHashMap<>();
List<RegionPojo> regionList = regionMapper.findAll();
for (RegionPojo region : regionList) {
regionIPMap.put(region.getPlace(), region);
}
TimingAcquisition.regionIPMap.putAll(regionIPMap);
log.info("缓存中地区与服务器对应信息" + TimingAcquisition.regionIPMap);
log.info("地区与服务器对应信息缓存完成");
//缓存玩家地址对应的地区信息
Map<String, Map<String, RegionDto>> addressMap = new ConcurrentHashMap<>();
Map<String, RegionPojo> regionPojoMap = TimingAcquisition.regionIPMap;
//所有地区
List<String> placeList = regionPojoMap.values().stream().map(RegionPojo::getPlace).collect(Collectors.toList());
for (String p : placeList) {
Map<String, RegionDto> regionDtoMap = new HashMap<>();
addressMap.put(p, regionDtoMap);
}
for (Map.Entry<String, GardenerDto> entry : TimingAcquisition.gardenerMap.entrySet()) {
GardenerDto gardener = entry.getValue();
//玩家地址
String location = gardener.getLocation();
//存在玩家地址
if (!StringUtils.isEmpty(location)) {
//分地区存放玩家地址
for (String p : placeList) {
RegionDto region = new RegionDto();
String place = TypeConvertUtil.extractChinese(location);
//找到了玩家地址对应地区
if (p.equals(place)) {
if (!StringUtils.isEmpty(regionPojoMap.get(place))) {
String serverIP = regionPojoMap.get(place).getServerIP();
region.setServerIP(serverIP);
}
String number = TypeConvertUtil.extractNo(location);
region.setUid(gardener.getUid());
region.setName(gardener.getGardenerInfo().getName());
region.setPlace(place);
region.setNumber(number);
addressMap.get(p).put(location, region);
break;
}
}
}
}
TimingAcquisition.addressMap.putAll(addressMap);
log.info("缓存中玩家地址对应的地区信息" + TimingAcquisition.addressMap);
log.info("玩家地址对应的地区信息缓存完成");
}
}
package com.qiwuai.garden.common;
import com.qiwuai.garden.dto.request.OperationRequest;
import org.springframework.util.StringUtils;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
public class ProxyFactory {
private Object target;
public ProxyFactory(Object target) {
this.target = target;
}
public Object getProxyInstance() {
return Proxy.newProxyInstance(
target.getClass().getClassLoader(),
target.getClass().getInterfaces(),
new InvocationHandler() {
@Override
public Object invoke(Object o, Method method, Object[] args) throws Throwable {
OperationRequest request = (OperationRequest) args[0];
//更新玩家在线状态
statusUpdate(request.getUid());
Object var = method.invoke(target, args);
//玩家有新消息提示
System.out.println("增加参数返回,var:" + var);
return var;
}
}
);
}
/**
* 玩家状态更新为在线
*/
public void statusUpdate(String uid) {
if (!StringUtils.isEmpty(TimingAcquisition.gardenerMap.get(uid))) {
TimingAcquisition.gardenerMap.get(uid).setStatus(Constants.ONLINE);
}
}
/**
* 检查玩家是否有新消息,有则添加后台返回值给bot端
*/
public void addMessage() {
}
}
......@@ -19,7 +19,9 @@ public class ExpireThread implements Runnable{
}
}
}
/**
* 清除全局缓存对象中过期缓存
*/
public void expireCache() {
for (String key : CacheGlobal.concurrentMap.keySet()) {
MyCache myCache = CacheGlobal.concurrentMap.get(key);
......
package com.qiwuai.garden.common.cache;
public class UserThread {
}
......@@ -38,11 +38,12 @@ public class DateUtil {
}
/**
* 当前时间加上毫秒
* @param time
* @param sub
* @return String
*/
public static String addTime(String time, int sub) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
Date dt = sdf.parse(time);
Calendar newTime = Calendar.getInstance();
newTime.setTime(dt);
......@@ -51,6 +52,50 @@ public class DateUtil {
return sdf.format(newDt);
}
/**
* 计算时间差,返回单位为秒
* @param time1
* @param time2
* @return long
*/
public static long subTime(String time1, String time2) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
Date dt1 = sdf.parse(time1);
Date dt2 = sdf.parse(time2);
return (dt1.getTime() - dt2.getTime())/1000;
}
/**
* 日期比较
* @param time1
* @param time2
* @return int
*/
public static int compare(String time1, String time2) throws ParseException {
time1 = time1.substring(0, 8);
time2 = time2.substring(0, 8);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");//设置日期格式
Date dt1 = sdf.parse(time1);
Date dt2 = sdf.parse(time2);
return dt1.compareTo(dt2);
}
/**
* "yyyyMMddHHmmss"转成“yyyy-MM-dd HH:mm:ss“
* @param time
* @return String
*/
public static String changeForm(String time) throws ParseException {
Date date = new Date();
try {
date = new SimpleDateFormat("yyyyMMddHHmmss").parse(time);//先按照原格式转换为时间
} catch (ParseException e) {
e.printStackTrace();
}
String str = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);//再将时间转换为对应格式字符串
return str;
}
/**
* 获取今天的时间范围
......@@ -346,7 +391,9 @@ public class DateUtil {
public static void main(String[] args) throws ParseException {
String time = addTime("20220525165212", 76);
System.out.println(time);
String t1 = "20220706170722";
String t2 = getCurrentTime();
System.out.println("时间比较结果:" + changeForm(t1));
}
}
......@@ -4,14 +4,23 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.qiwuai.garden.common.TimingAcquisition;
import com.qiwuai.garden.dto.BackPackDto;
import java.io.*;
import java.util.Map;
public class PersistenceUtil {
//玩家数据的存放路径
public static String userFilePath = YamlUtil.getValueByKey("userFilePath");
//各地区编号的存放路径
public static String configFilePath = YamlUtil.getValueByKey("configFilePath");
/**
* 保存玩家数据到json文件
* @param fileName
* @param data
* @return void
*/
public static void saveDataToFile(String fileName, String data) {
BufferedWriter writer = null;
File file = new File("/home/qwyf14/dataBackup/" + fileName + ".json");
File file = new File(userFilePath + fileName + ".json");
if (!file.exists()) {
try {
file.createNewFile();
......@@ -34,13 +43,77 @@ public class PersistenceUtil {
}
}
}
/**
* 从json文件中读取玩家数据
* @param filePath
* @return String
*/
public static String getDataFromFile(String filePath) {
BufferedReader reader = null;
String lastStr = "";
try {
FileInputStream fileInputStream = new FileInputStream(filePath);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
reader = new BufferedReader(inputStreamReader);
String stringTmp = null;
while ((stringTmp = reader.readLine()) != null) {
lastStr += stringTmp;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return lastStr;
}
public static String getDataFromFile(String fileName) {
String path = "/home/qwyf14/dataBackup/" + fileName + ".json";
/**
* 保存各配置信息到json文件
* @param fileName
* @param data
* @return void
*/
public static void saveConfigToFile(String fileName, String data) {
BufferedWriter writer = null;
File file = new File(configFilePath + fileName);
if (!file.exists()) {
try {
file.createNewFile();
} catch (Exception e) {
e.printStackTrace();
}
}
try {
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, false), "UTF-8"));
writer.write(data);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (writer != null) {
writer.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 从json文件中读取各配置文件的信息
* @param fileName
* @return String
*/
public static String getConfigFromFile(String fileName) {
BufferedReader reader = null;
String lastStr = "";
try {
FileInputStream fileInputStream = new FileInputStream(path);
FileInputStream fileInputStream = new FileInputStream(configFilePath + fileName);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
reader = new BufferedReader(inputStreamReader);
String stringTmp = null;
......@@ -62,13 +135,10 @@ public class PersistenceUtil {
}
public static void main(String[] args) {
String s = PersistenceUtil.getDataFromFile("test-backPack-20220428111643");
String s = PersistenceUtil.getDataFromFile("Test222");
//JSON转map对象
System.out.println("取出的数据:" + s);
Map<String, BackPackDto> backPack = JSON.parseObject(s, new TypeReference<Map<String, BackPackDto>>(){});
TimingAcquisition.backpackMap = backPack;
System.out.println("从文件中取出背包的缓存数据:" + backPack);
System.out.println("内存中背包的缓存数据:" + TimingAcquisition.backpackMap );
}
}
......@@ -97,7 +97,7 @@ public class RandomDropUtil {
for (int i = 0; i < dropItemList.length; i++) {
Random random = new Random();
double randomProb = random.nextDouble();
log.info("随机概率为:" + randomProb);
// log.info("随机概率为:" + randomProb);
if (randomProb <= Double.parseDouble(dropProbList[i])) {
Integer itemId = Integer.valueOf(dropItemList[i]);
Integer randomNum = getRandomNum(dropItemNumList.get(i).getDropMin(), dropItemNumList.get(i).getDropMax());
......@@ -107,7 +107,41 @@ public class RandomDropUtil {
harvestItems.add(item);
}
}
log.info("植物掉落包的物品有:" + harvestItems);
// log.info("植物掉落包的物品有:" + harvestItems);
return harvestItems;
}
/**
* 帮助好友时,给帮助方的植物物品掉落,在0~1取随机数即概率。
* @param plant
* @return List<ItemDto>
*/
public static List<ItemDto> plantDropItemHelp(PlantPojo plant, double earnRate) {
//掉落物品包
List<ItemDto> harvestItems = new ArrayList<>();
//掉落物品id集合
String[] dropItemList = plant.getDropItems().split("\\|");
//掉落物品对应数量范围
List<DropItemNumDto> dropItemNumList = TypeConvertUtil.dropItemNum2List(plant.getDropNums());
//掉落物品对应概率
String[] dropProbList = plant.getDropProbs().split("\\|");
//遍历所有掉落物品id,判断是否掉落
for (int i = 0; i < dropItemList.length; i++) {
//过滤掉会掉落的果实id
if (dropItemList[i].equals(plant.getFruitId().toString())) {
continue;
}
Random random = new Random();
double randomProb = random.nextDouble();
if (randomProb <= Double.parseDouble(dropProbList[i]) * earnRate * 0.01) {
Integer itemId = Integer.valueOf(dropItemList[i]);
Integer randomNum = getRandomNum(dropItemNumList.get(i).getDropMin(), dropItemNumList.get(i).getDropMax());
ItemDto item = new ItemDto();
item.setItemId(itemId);
item.setItemNum(randomNum);
harvestItems.add(item);
}
}
return harvestItems;
}
......@@ -119,7 +153,13 @@ public class RandomDropUtil {
public static List<ItemDto> petDropItem(PetPojo pet) {
//掉落物品包
List<ItemDto> harvestItems = new ArrayList<>();
if (StringUtils.isEmpty(pet.getDropItems())) {
return harvestItems;
}
//掉落物品id集合
if (pet.getDropItems().equals(String.valueOf(Constants.NON))) {
return harvestItems;
}
String[] dropItemList = pet.getDropItems().split("\\|");
//掉落物品对应数量范围
List<DropItemNumDto> dropItemNumList = TypeConvertUtil.dropItemNum2List(pet.getDropNums());
......@@ -129,7 +169,7 @@ public class RandomDropUtil {
for (int i = 0; i < dropItemList.length; i++) {
Random random = new Random();
double randomProb = random.nextDouble();
log.info("随机概率为:" + randomProb);
// log.info("随机概率为:" + randomProb);
if (randomProb <= Double.parseDouble(dropProbList[i])) {
Integer itemId = Integer.valueOf(dropItemList[i]);
Integer randomNum = getRandomNum(dropItemNumList.get(i).getDropMin(), dropItemNumList.get(i).getDropMax());
......@@ -139,7 +179,43 @@ public class RandomDropUtil {
harvestItems.add(item);
}
}
log.info("宠物掉落包的物品有:" + harvestItems);
// log.info("宠物掉落包的物品有:" + harvestItems);
return harvestItems;
}
/**
* 帮助好友时,给帮助方的宠物物品掉落,在0~1取随机数即概率
* @param pet
* @return List<ItemDto>
*/
public static List<ItemDto> petDropItemHelp(PetPojo pet, double earnRate) {
//掉落物品包
List<ItemDto> harvestItems = new ArrayList<>();
if (StringUtils.isEmpty(pet.getDropItems())) {
return harvestItems;
}
//掉落物品id集合
if (pet.getDropItems().equals(String.valueOf(Constants.NON))) {
return harvestItems;
}
String[] dropItemList = pet.getDropItems().split("\\|");
//掉落物品对应数量范围
List<DropItemNumDto> dropItemNumList = TypeConvertUtil.dropItemNum2List(pet.getDropNums());
//掉落物品对应概率
String[] dropProbList = pet.getDropProbs().split("\\|");
//遍历所有掉落物品id,判断是否掉落
for (int i = 0; i < dropItemList.length; i++) {
Random random = new Random();
double randomProb = random.nextDouble();
if (randomProb <= Double.parseDouble(dropProbList[i]) * earnRate * 0.01) {
Integer itemId = Integer.valueOf(dropItemList[i]);
Integer randomNum = getRandomNum(dropItemNumList.get(i).getDropMin(), dropItemNumList.get(i).getDropMax());
ItemDto item = new ItemDto();
item.setItemId(itemId);
item.setItemNum(randomNum);
harvestItems.add(item);
}
}
return harvestItems;
}
......@@ -160,14 +236,13 @@ public class RandomDropUtil {
int fruitNum = TimingAcquisition.plantMap.get(nurseryInfo.getPlantId()).getFruitNum();
fruit.setItemId(TimingAcquisition.plantMap.get(nurseryInfo.getPlantId()).getFruitId());
fruit.setItemNum(0);
PlantPojo plant = TimingAcquisition.plantMap.get(nurseryInfo.getPlantId());
//遍历当前花圃中的所有植物
for (int i = 0; i < nurseryInfo.getNumber(); i++) {
//花圃收获加成
Integer totalNum = nurseryConfig.getAddHarvest().add(new BigDecimal(1)).multiply(new BigDecimal(fruitNum)).intValue();
//果实数量累加
fruit.setItemNum(fruit.getItemNum() + totalNum);
log.info("收获的果实:" + fruit);
PlantPojo plant = TimingAcquisition.plantMap.get(nurseryInfo.getPlantId());
List<ItemDto> plantDropItems = plantDropItem(plant);
//将植物掉落的果实合并到fruit中
for (int j = 0; j < plantDropItems.size(); j++) {
......@@ -179,6 +254,7 @@ public class RandomDropUtil {
}
dropItemsTotal = TypeConvertUtil.listMerge(dropItemsTotal, plantDropItems);
}
// log.info("收获的果实:" + fruit);
//花圃里已有宠物,则有一定几率产生遗留/掉落物品
Integer nurseryPetId = nurseryInfo.getPetField();
if (!StringUtils.isEmpty(nurseryPetId)) {
......@@ -199,13 +275,17 @@ public class RandomDropUtil {
for (Map.Entry<Integer, PetPojo> entry : petConfigMap.entrySet()) {
PetPojo petPojo = entry.getValue();
//宠物喜欢的植物
List<String> favorPlantIdList = Arrays.asList(petPojo.getFavoritePlantId().split("\\|"));
if (favorPlantIdList.contains(nurseryInfo.getPlantId().toString())) {
//统计有概率出现的宠物
Random random = new Random();
double randomProb = random.nextDouble();
if (randomProb < petPojo.getAppearProb().doubleValue()) {
petList.add(petPojo.getId());
if (!StringUtils.isEmpty(petPojo.getFavoritePlantId())) {
if (Constants.NON.toString().equals(petPojo.getFavoritePlantId())) {
List<String> favorPlantIdList = Arrays.asList(petPojo.getFavoritePlantId().split("\\|"));
if (favorPlantIdList.contains(nurseryInfo.getPlantId().toString())) {
//统计有概率出现的宠物
Random random = new Random();
double randomProb = random.nextDouble();
if (randomProb < petPojo.getAppearProb().doubleValue()) {
petList.add(petPojo.getId());
}
}
}
}
}
......@@ -213,13 +293,13 @@ public class RandomDropUtil {
if (petList.size() != 0) {
Integer petId = petList.get(getRandomNum(0, petList.size()));
nurseryInfo.setPetField(petId);
nurseryInfo.setPetCheck(Constants.PET_UNCHECK);
}
}
nurseryInfo.setPetCheck(Constants.PET_UNCHECK);
// log.info("掉落物品:" + dropItemsTotal);
nurseryInfo.setHarvestFruit(fruit);
nurseryInfo.setDropItems(dropItemsTotal);
log.info("所有掉落物品:" + dropItemsTotal);
// log.info("所有掉落物品:" + dropItemsTotal);
}
public static void main(String[] args) {
......
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 Map<String, Map<String, List<String>>>
*/
public static String getPlantSpeech(String someone, String feedText) {
String result = "";
List<String> 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 Map<String, Map<String, List<String>>>
*/
public static String getGardenerSpeech(String someone, String feedText) {
String result = "";
List<String> 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 Map<String, Map<String, List<String>>>
*/
public static String getPetSpeech(String someone, String feedText) {
String result = "";
List<String> 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 Map<String, Map<String, List<String>>>
*/
public static String getMarketSpeech(String someone, String feedText) {
String result = "";
List<String> 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 Map<String, Map<String, List<String>>>
*/
public static String getSocialSpeech(String someone, String feedText) {
String result = "";
List<String> speech = TimingAcquisition.socialSpeechMap.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"));
}
}
......@@ -4,8 +4,10 @@ import com.qiwuai.garden.common.Constants;
import com.qiwuai.garden.dto.DropItemNumDto;
import com.qiwuai.garden.dto.ItemDto;
import com.qiwuai.garden.dto.PlantDto;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -71,9 +73,31 @@ public class TypeConvertUtil {
* @return Integer
*/
public static Integer change2Integer(String param) {
if (param.equals("随机")) {
String[] all = new String[]{"都", "统统", "全数", "所有", "全", "全部", "全都", "一起"};
String[] first = new String[]{"首个", "首位"};
String[] middle = new String[]{"中间"};
String[] last = new String[]{"最后", "末位", "末尾"};
String[] random = new String[]{"随机", "随便", "推荐"};
List<String> allCh = Arrays.asList(all);
List<String> firstCh = Arrays.asList(first);
List<String> middleCh = Arrays.asList(middle);
List<String> lastCh = Arrays.asList(last);
List<String> randomCh = Arrays.asList(random);
if (randomCh.contains(param)) {
return Constants.REQ_RANDOM;
}
if (allCh.contains(param)) {
return Constants.REQ_ALL;
}
if (firstCh.contains(param)) {
return Constants.REQ_FIRST;
}
if (middleCh.contains(param)) {
return Constants.REQ_MIDDLE;
}
if (lastCh.contains(param)) {
return Constants.REQ_LAST;
}
int i = 0;
char[] chNum = new char[]{'一','二','三','四','五','六','七','八','九','十'};
char[] chars = param.toCharArray();
......@@ -110,6 +134,59 @@ public class TypeConvertUtil {
}
/**
* 提取字符串的中文
* @param param
* @return Integer
*/
public static String extractChinese(String param) {
String regEx="[^(\\\\u4e00-\\\\u9fa5)]";
String result = "";
Matcher matcher = Pattern.compile(regEx).matcher(param);
while (matcher.find()) {
result += matcher.group(0);
}
return result;
}
/**
* 提取字符串的数字字符串
* @param param
* @return Integer
*/
public static String extractNo(String param) {
String regEx="[^(\\\\u4e00-\\\\u9fa5)]";
return param.replaceAll(regEx, "");
}
/**
* {"未读", "已读"}中文转成数字
* @param param
* @return Integer
*/
public static Integer readChineseToInteger(String param) {
String[] chs = {"未读", "已读"};
if (param.equals(chs[0])) {
return 0;
} else {
return 1;
}
}
/**
* {"未成熟", "成熟"}中文转成数字
* @param param
* @return Integer
*/
public static Integer matureChineseToInteger(String param) {
String[] chs = {"未成熟", "成熟"};
if (param.equals(chs[0])) {
return Constants.MATURE_NO;
} else {
return Constants.MATURE_YES;
}
}
/**
* 合并两个list数组,元素为对象
* @param list1
* @param list2
......
......@@ -2,11 +2,138 @@ package com.qiwuai.garden.common.utils;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component;
import org.yaml.snakeyaml.Yaml;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@Component
@Data
public class YamlUtil {
@Value("${expire.time}")
public String expireTime;
//获取话术存放的路径
public static String speechFilePath = YamlUtil.getValueByKey("speechFilePath");
private static LinkedHashMap<String, Map<String, Map<String, String>>> properties = new LinkedHashMap<>();
/**
* 将种植话术转成map格式
* @param
* @return Map<String, Map<String, List<String>>>
*/
public static Map<String, Map<String, List<String>>> plantSpeechToMap() {
Map<String, Map<String, List<String>>> speechMap = new HashMap<>();
try {
InputStream in = new FileInputStream(speechFilePath + "plant.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>>> 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;
}
/**
* 读取配置文件yml中的某个值,只支持取第一层的值
* @param
* @return Map<String, Map<String, List<String>>>
*/
public static String getValueByKey(String key) {
String value = "";
try {
Yaml yaml = new Yaml();
ClassPathResource resource = new ClassPathResource("\\application.yml");
properties = yaml.load(resource.getInputStream());
String val = properties.get("spring").get("profiles").get("active");
ClassPathResource resourceNext = new ClassPathResource("\\application-" + val + ".yml");
Map map = yaml.load(resourceNext.getInputStream());
value = String.valueOf(map.get(key));
} catch (Exception e) {
e.printStackTrace();
}
return value;
}
public static void main(String[] args) throws FileNotFoundException {
// Map<String, Map<String, List<String>>> speech = plantSpeechToMap();
// System.out.println("yaml文件读取结果:" + plantSpeechToMap());
// Integer i = RandomDropUtil.getRandomNum(0, speech.get("man").get("plant_fail_near_plant").size());
// System.out.println("随机数i:" + i);
// System.out.println("植物因没有伴生宠物种植失败的回复:" + speech.get("man").get("plant_fail_near_plant").get(i));
System.out.println("从yml文件取出的值" + getValueByKey("userFilePath"));
}
}
package com.qiwuai.garden.controller;
import com.netflix.discovery.converters.Auto;
import com.qiwuai.garden.dto.GardenerDto;
import com.qiwuai.garden.dto.base.CommonResponse;
import com.qiwuai.garden.dto.request.OperationRequest;
import com.qiwuai.garden.dto.request.GardenerRequest;
import com.qiwuai.garden.dto.request.HarvestRequest;
import com.qiwuai.garden.dto.response.ApiResponse;
import com.qiwuai.garden.service.backPackService.BackPackService;
import com.qiwuai.garden.service.gardenerService.GardenerService;
import com.qiwuai.garden.service.nurseryService.NurseryService;
......@@ -32,8 +27,8 @@ public class GardenerController {
private PetService petService;
@PostMapping(value = "/create", produces = "application/json;charset=UTF-8")
public ApiResponse<GardenerDto> createGardener(@RequestBody GardenerRequest gardenerRequest) {
ApiResponse<GardenerDto> gardener = gardenerService.create(gardenerRequest);
public CommonResponse createGardener(@RequestBody OperationRequest operationReq) {
CommonResponse gardener = gardenerService.create(operationReq);
return gardener;
}
......@@ -97,12 +92,6 @@ public class GardenerController {
return goods;
}
@PostMapping(value = "/buy", produces = "application/json;charset=UTF-8")
public CommonResponse buy(@RequestBody OperationRequest operationReq) {
CommonResponse goods = gardenerService.buy(operationReq);
return goods;
}
@PostMapping(value = "/seed", produces = "application/json;charset=UTF-8")
public CommonResponse seed(@RequestBody OperationRequest operationReq) {
CommonResponse result = plantService.seedCheck(operationReq);
......@@ -183,7 +172,7 @@ public class GardenerController {
@PostMapping(value = "/NurseryResetCheck", produces = "application/json;charset=UTF-8")
public CommonResponse NurseryResetCheck(@RequestBody OperationRequest operationReq) {
CommonResponse result = nurseryService.NurseryResetCheck(operationReq);
CommonResponse result = nurseryService.nurseryResetCheck(operationReq);
return result;
}
......
......@@ -34,7 +34,6 @@ public class PlayerController {
@GetMapping("/notice")
public String notice() {
Map<String, BackPackDto> map = TimingAcquisition.getBackpack();
//map转JSON
// String s = JSON.toJSONString(map);
// PersistenceUtil.saveDataToFile("plantA", s);
......@@ -56,7 +55,6 @@ public class PlayerController {
Map<String, BackPackDto> backPack = JSON.parseObject(s, new TypeReference<Map<String, BackPackDto>>(){});
System.out.println("从文件中取出背包的缓存数据:" + backPack);
System.out.println("内存中背包的缓存数据:" + TimingAcquisition.backpackMap );
return "获取成功";
}
......
package com.qiwuai.garden.dao;
import com.qiwuai.garden.dto.request.PlantAttributeConfigReq;
import com.qiwuai.garden.pojo.PlantAttributePojo;
import com.qiwuai.garden.pojo.AttributePojo;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
......@@ -9,8 +9,8 @@ import java.util.List;
@Mapper
@Repository
public interface PlantAttributeMapper {
List<PlantAttributePojo> searchAll();
public interface AttributeMapper {
List<AttributePojo> searchAll();
int add(PlantAttributeConfigReq plantAttributeConfigReq);
}
package com.qiwuai.garden.dao;
import com.qiwuai.garden.pojo.QuantityRangePojo;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface QuantityRangeMapper {
List<QuantityRangePojo> findAll();
}
package com.qiwuai.garden.dao;
import com.qiwuai.garden.pojo.RarityPojo;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface RarityMapper {
List<RarityPojo> findAll();
}
package com.qiwuai.garden.dao;
import com.qiwuai.garden.pojo.RegionPojo;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface RegionMapper {
List<RegionPojo> findAll();
}
package com.qiwuai.garden.dto;
import lombok.Data;
@Data
public class AddFriendAskDto {
/**
* 玩家id
*/
private String uid;
/**
* 玩家地址
*/
private String address;
/**
* 园丁名称
*/
private String name;
/**
* 申请时间
*/
private String askTime;
}
package com.qiwuai.garden.dto;
import com.qiwuai.garden.common.TimingAcquisition;
import com.qiwuai.garden.common.utils.DateUtil;
import lombok.Data;
import java.text.ParseException;
@Data
public class FriendDto {
/**
* 玩家地址
*/
private String address;
/**
* 园丁名称
*/
private String name;
/**
* 好友状态
*/
private Integer status;
/**
* 帮助标记:0-未帮助,1-已帮助
*/
private Integer helpTag;
/**
* 帮助时间
*/
private String helpTime;
}
......@@ -6,12 +6,24 @@ import java.util.List;
import java.util.Map;
@Data
public class GardenerDto {
public class GardenerDto implements Cloneable{
/**
* 玩家id
*/
private String uid;
/**
* 玩家状态:0-离线,1-在线
*/
private Integer status;
/**
* 玩家数据保存标识:玩家离线后保存玩家数据后则置为1,在线时为0;
*/
private Integer saveSign;
/**
* 玩家地址
* */
private String location;
/**
* 园丁信息
*/
private GardenerInfoDto gardenerInfo;
......@@ -28,15 +40,66 @@ public class GardenerDto {
*/
private List<Integer> petFields;
/**
* 宠物栏位中宠物免投喂次数,创建用户时需要初始化为默认值,即系统配置的“pet_no_feed_times”
* 与宠物栏位一一对应
*/
private List<Integer> petNoFeedTimesList;
/**
* 累计任务,key为eventId,value为次数
*/
private Map<Integer, Integer> taskCountMap;
/**
* 创建时间taskList
* 好友列表
*/
private List<FriendDto> friendList;
/**
* 帮助简报
*/
private List<HelpReportDto> helpReportList;
/**
* 今日已偷取的陌生人, Map<陌生人玩家地址,StrangerDto>
*/
private Map<String, StrangerDto> strangerMap;
/**
* 偷菜简报
*/
private List<StealReportDto> stealReportList;
/**
* 好友申请
*/
private Map<String, AddFriendAskDto> addFriendAskMap;
/**
* 消息提醒,分别保存好友申请、帮助简报、偷菜简报、任务等提醒
*/
private Map<String, Integer> notice;
/**
* 今日帮助次数
*/
private Integer helpTimes = 0;
/**
* 今日偷菜次数
*/
private Integer stealTimes = 0;
/**
* 创建时间
*/
private String createTime;
/**
* 修改时间
*/
private String updateTime;
/**
* 深拷贝宠物栏
*/
@Override
public GardenerDto clone() {
try {
GardenerDto clone = (GardenerDto) super.clone();
clone.petFields = this.petFields;
return clone;
} catch (CloneNotSupportedException e) {
throw new AssertionError();
}
}
}
......@@ -19,9 +19,9 @@ public class GardenerInfoDto implements Serializable {
* */
private String name;
/**
* 性别
* 性别:1-男,2-女
* */
private String gender;
private Integer gender;
/**
* 生日
* */
......@@ -59,10 +59,6 @@ public class GardenerInfoDto implements Serializable {
* */
private String state;
/**
* 位置信息
* */
private String location;
/**
* 好感度
* */
private Integer friendliness;
......@@ -83,7 +79,7 @@ public class GardenerInfoDto implements Serializable {
* */
private String updateTime;
public GardenerInfoDto(String uid, String name, String gender) {
public GardenerInfoDto(String uid, String name, Integer gender) {
this.uid = uid;
this.name = name;
this.gender = gender;
......
package com.qiwuai.garden.dto;
import lombok.Data;
import java.util.List;
@Data
public class HelpReportDto {
/**
* 简报名称
*/
private String name;
/**
* 帮助者的玩家地址
*/
private String friendAddress;
/**
* 收取时间
*/
private String harvestTime;
/**
* 花圃编号
*/
private Integer nurseryNum;
/**
* 植物id
*/
private Integer plantId;
/**
* 获得的物品名称、数量
*/
private List<ItemDto> itemList;
/**
* 好友获得的物品名称、数量
*/
private List<ItemDto> friendItemList;
/**
* 未读-0,已读-1
*/
private Integer read;
}
......@@ -46,12 +46,16 @@ public class NurseryInfoDto {
/**
* 宠物查看状态:0-未查看,1-已查看。吸引宠物来到之后,需要更新为0
*/
private Integer petCheck;
private Integer petCheck = 1;
/**
* 花圃宠物栏位
*/
private Integer petField;
/**
* 宠物免投喂次数,创建用户时需要初始化为默认值,即系统配置的“pet_no_feed_times”
*/
private Integer petNoFeedTimes;
/**
* 花圃开启状况:0-未开启,1-已开启
*/
private Integer usable;
......@@ -60,6 +64,14 @@ public class NurseryInfoDto {
*/
private Map<Integer, PlantDto> plantIdTimes;
/**
* 好友帮助时的花圃收益比例,保存的是整数如15,计算时要转换成0.15
*/
private Integer earnRate;
/**
* 乐观锁,用于保证该花圃只有一个人操作,操作完必释放: 0-空闲, 1-忙碌
*/
private Integer lock = 0;
/**
* 创建时间
*/
private String createTime;
......
package com.qiwuai.garden.dto;
import lombok.Data;
@Data
public class RegionDto {
/**
* 玩家id
*/
private String uid;
/**
* 园丁名称
*/
private String name;
/**
* 地区
*/
private String place;
/**
* 编号
*/
private String number;
/**
* 地区所在服务器ip
*/
private String serverIP;
}
package com.qiwuai.garden.dto;
import lombok.Data;
import java.util.List;
@Data
public class StealReportDto {
/**
* 简报名称
*/
private String name;
/**
* 偷菜者的玩家地址
*/
private String strangeAddress;
/**
* 偷菜时间
*/
private String stealTime;
/**
* 花圃编号
*/
private Integer nurseryNum;
/**
* 植物id
*/
private Integer plantId;
/**
* 宠物战斗结果
*/
private Integer fightResult;
/**
* 宠物战斗详情
*/
private String fightDetail;
/**
* 获得的物品名称、数量
*/
private List<ItemDto> itemList;
/**
* 未读-0,已读-1
*/
private Integer read;
}
package com.qiwuai.garden.dto;
import com.qiwuai.garden.common.TimingAcquisition;
import com.qiwuai.garden.common.utils.DateUtil;
import lombok.Data;
import org.springframework.util.StringUtils;
@Data
public class StrangerDto {
/**
* 玩家地址
*/
private String address;
/**
* 园丁名称
*/
private String name;
/**
* 偷菜冷却开始时间
*/
private String stealColdStartTime;
/**
* 战斗详情,暂存,玩家阅读之后或者不查看即可删除
*/
private String fightDetail;
/**
* 偷菜判断,可偷菜则返回true,否则返回false
*/
public boolean stealAble(){
//获取系统配置的偷菜冷却时间
long stealColdTime = Long.parseLong(TimingAcquisition.systemConfigMap.get("steal_cold_time").getValue());
String nowTime = DateUtil.getCurrentTime();
long subTime = 0;
try {
//第一次偷菜
if (StringUtils.isEmpty(stealColdTime)) {
return true;
}
//距离上次偷菜的时间,单位为秒
subTime = DateUtil.subTime(nowTime, stealColdStartTime);
} catch (Exception e) {
e.printStackTrace();
}
return subTime >= stealColdTime;
}
}
......@@ -16,4 +16,114 @@ public class ResultResponse {
* 后台附加返回,bot二次确认需要的参数
*/
private String 后台附加返回;
/**
* 玩家当前位置,bot用于判断玩家是否访问他人,仅在访问他人时返回“非本人”
*/
private String 玩家当前位置;
/**
* 消息提醒,玩家有新信息时返回该值
*/
private String 消息提醒;
/***************************用于清空bot端保留的变量***********************************/
/**
* 操作指令:查看,种植,收取,取消,选择,重置,升级,更名,移动,删除,排序,购买,出售等
*/
private String 操作名;
/**
* 植物名称
*/
private String 植物名称;
/**
* 花圃编号
*/
private String 花圃编号;
/**
* 宠物当前位置
*/
private String 宠物位置;
/**
* 宠物花圃位置,移动目的地
*/
private String 宠物花圃位置;
/**
* 花圃升级等级
*/
private String 升级等级;
/**
* 花圃类型
*/
private String 花圃类型;
/**
* 技能名称
*/
private String 技能名称;
/**
* 园丁名称
*/
private String 园丁名称;
/**
* 园丁性别
*/
private String 园丁性别;
/**
* 所属地区
*/
private String 所属地区;
/**
* 宠物名称
*/
private String 宠物名称;
/**
* 物品名称
*/
private String 物品名称;
/**
* 物品种类
*/
private String 物品种类;
/**
* 物品数量
*/
private String 数量;
/**
* 位置信息,宠物栏中宠物的位置
*/
private String 位置信息;
/**
* 位置信息1,宠物栏中宠物的位置1
*/
private String 位置信息1;
/**
* 位置信息2,宠物栏中宠物的位置2
*/
private String 位置信息2;
/**
* 玩家地址
*/
private String 玩家地址;
/**
* 植物状态
*/
private String 植物状态;
/**
* 收益比例
*/
private String 收益比例;
/**
* 留言内容
*/
private String 留言内容;
/**
* 简报名称
*/
private String 简报名称;
/**
* 简报序号
*/
private String 简报序号;
/**
* 简报状态
*/
private String 简报状态;
}
......@@ -21,6 +21,10 @@ public class CallRequest {
*/
private String 宠物位置;
/**
* 宠物花圃位置,移动目的地
*/
private String 宠物花圃位置;
/**
* 花圃升级等级
*/
private String 升级等级;
......@@ -37,6 +41,14 @@ public class CallRequest {
*/
private String 园丁名称;
/**
* 园丁性别
*/
private String 园丁性别;
/**
* 所属地区
*/
private String 所属地区;
/**
* 宠物名称
*/
private String 宠物名称;
......@@ -45,6 +57,10 @@ public class CallRequest {
*/
private String 物品名称;
/**
* 物品种类
*/
private String 物品种类;
/**
* 物品数量
*/
private String 数量;
......@@ -60,4 +76,32 @@ public class CallRequest {
* 位置信息2,宠物栏中宠物的位置2
*/
private String 位置信息2;
/**
* 玩家地址
*/
private String 玩家地址;
/**
* 植物状态
*/
private String 植物状态;
/**
* 收益比例
*/
private String 收益比例;
/**
* 留言内容
*/
private String 留言内容;
/**
* 简报名称
*/
private String 简报名称;
/**
* 简报序号
*/
private String 简报序号;
/**
* 简报状态
*/
private String 简报状态;
}
......@@ -2,16 +2,32 @@ package com.qiwuai.garden.dto.request;
import lombok.Data;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;
@Data
public class OperationRequest {
/**
* 操作名
*/
private String operate;
/**
* 用户唯一ID
*/
private String uid;
/**
* 园丁名称,用于更名
* 园丁名称
*/
private String name;
/**
* 园丁性别
*/
private Integer gender;
/**
* 所属地区
*/
private String rename;
private String region;
/**
* 园丁等级,用于学习技能
*/
......@@ -37,6 +53,10 @@ public class OperationRequest {
*/
private Integer nurseryPos;
/**
* 宠物花圃位置,移动目的地
*/
private Integer nurseryNumPos;
/**
* 花圃类型id
*/
private Integer nurseryId;
......@@ -65,6 +85,46 @@ public class OperationRequest {
*/
private Integer petPos2;
/**
* 玩家地址
*/
private String address;
/**
* 植物状态
*/
private Integer plantStatus;
/**
* 收益比例
*/
private Integer earnRate;
/**
* 留言内容
*/
private String message;
/**
* 简报名称
*/
private String reportName;
/**
* 简报序号
*/
private Integer reportNum;
/**
* 简报状态:0-未读,1-已读
*/
private Integer reportStatus;
/**
* 上轮对话保存的list
*/
private List<Integer> list;
/**
* 上轮对话保存的strList
*/
private List<String> strList;
/**
* 顺序的第XX位
*/
private Integer rank;
/**
* 本轮操作标识
*/
private Integer operationLabel;
......
......@@ -13,6 +13,10 @@ public class PlantAttributeConfigReq {
*/
private String description;
/**
* 克制的属性:水、火
*/
private String restrainIds;
/**
* 创建时间
*/
private String createTime;
......
......@@ -49,7 +49,7 @@ public class PlantConfigReq {
/**
* 所需临近植物id,可以不用配置
*/
private Integer nearPlantId;
private Integer nearPlantIds;
/**
* 所需宠物id,可以不用配置
*/
......
package com.qiwuai.garden.dto.response;
import lombok.Data;
import java.io.Serializable;
@Data
public class ApiResponse<T> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 返回码
*/
private int code;
/**
* 返回说明
*/
private String msg;
/**
* 返回数据
* */
private T data;
}
......@@ -3,15 +3,19 @@ package com.qiwuai.garden.pojo;
import lombok.Data;
@Data
public class PlantAttributePojo {
public class AttributePojo {
/**
* 植物属性id
* 属性id
*/
private Integer id;
/**
* 植物属性:水、火等
* 属性:水、火等
*/
private String description;
private String attribute;
/**
* 克制的属性:水、火
*/
private String restrainIds;
/**
* 创建时间
*/
......
......@@ -29,13 +29,9 @@ public class GardenerLevelPojo {
*/
private Integer petNumMax;
/**
* 宠物栏位上限
*/
private Integer petFieldMax;
/**
* 可偷菜次数上限
*/
private Integer steelTimesMax;
private Integer stealTimesMax;
/**
* 物品出售价格加成
*/
......
......@@ -21,7 +21,7 @@ public class GardenerSkillPojo {
/**
* 技能类型
*/
private String type;
private String skillTypeId;
/**
* 技能参数a
*/
......
......@@ -2,6 +2,8 @@ package com.qiwuai.garden.pojo;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class GoodsPojo {
/**
......@@ -27,7 +29,7 @@ public class GoodsPojo {
/**
* 折扣
*/
private Integer discount;
private BigDecimal discount;
/**
* 折扣
*/
......
......@@ -31,10 +31,6 @@ public class NurseryPojo {
*/
private String plantIdTimes;
/**
* 升级所需花费的货币数量
*/
private Integer cost;
/**
* 所需物品id和数量
*/
private String itemIdNums;
......
......@@ -35,9 +35,9 @@ public class PetPojo {
*/
private BigDecimal appearProb;
/**
* 属性id:1-风,2-水,3-火,4-雷等
* 属性id:1|3
*/
private Integer petAttributeId;
private String attributeIds;
/**
* 生命值
*/
......@@ -63,6 +63,10 @@ public class PetPojo {
*/
private String addItemSetId;
/**
* 宠物投喂物品id和数量:1|10
*/
private String feedCost;
/**
* 等级
*/
private Integer level;
......
......@@ -25,7 +25,7 @@ public class PlantPojo {
/**
* 植物属性id
*/
private Integer plantAttributeId;
private Integer attributeId;
/**
* 植物占用面积
*/
......@@ -47,9 +47,9 @@ public class PlantPojo {
*/
private Integer gardenerSkillId;
/**
* 所需临近植物id,可以不用配置
* 所需临近植物id:1001|1003,可以不用配置
*/
private Integer nearPlantId;
private String nearPlantIds;
/**
* 所需宠物id,可以不用配置
*/
......
package com.qiwuai.garden.pojo;
import lombok.Data;
@Data
public class QuantityRangePojo {
/**
* id
*/
private Integer id;
/**
* 量词:few,some,many,lot
*/
private String name;
/**
* 物品类型:1-货币,2-物品,3-宠物
*/
private Integer type;
/**
* 数量最小值,配置数量不影响功能
*/
private Integer min;
/**
* 数量最大值,最大范围区间的最大值不影响功能,可配任意值
*/
private Integer max;
/**
* 货币/物品很多或很少
*/
private String description;
}
package com.qiwuai.garden.pojo;
import lombok.Data;
@Data
public class RegionPojo {
/**
* id
*/
private Integer id;
/**
* 地区
*/
private String place;
/**
* 地区所在服务器ip
*/
private String serverIP;
/**
* 创建时间
*/
private String createTime;
/**
* 修改时间
*/
private String updateTime;
}
......@@ -17,6 +17,10 @@ public class SystemConfigPojo {
*/
private String description;
/**
* 参数状态:0-不可用,1-可用
*/
private Integer status;
/**
* 创建时间
*/
private String createTime;
......
package com.qiwuai.garden.service.gardenerService;
import com.qiwuai.garden.dto.GardenerDto;
import com.qiwuai.garden.dto.base.CommonResponse;
import com.qiwuai.garden.dto.request.OperationRequest;
import com.qiwuai.garden.dto.request.GardenerRequest;
import com.qiwuai.garden.dto.request.HarvestRequest;
import com.qiwuai.garden.dto.response.ApiResponse;
public interface GardenerService {
/**
......@@ -13,7 +9,13 @@ public interface GardenerService {
* @param
* @param
*/
ApiResponse<GardenerDto> create(GardenerRequest gardenerRequest);
CommonResponse create(OperationRequest operationReq);
/**
* 查看园丁等级
* @param operationReq
* @return CommonResponse
*/
CommonResponse gardenerLevelCheck(OperationRequest operationReq);
/**
* 园丁升级,查询园丁升级条件
* @param operationReq
......@@ -33,7 +35,7 @@ public interface GardenerService {
*/
CommonResponse gardenerUpgradeCancel(OperationRequest operationReq);
/**
* 查看技能信息,查看当前等级可选择的所有技能信息
* 查看技能信息,查看当前等级可选择的所有技能信息,暂不使用
* @param operationReq
* @return CommonResponse
*/
......@@ -92,12 +94,6 @@ public interface GardenerService {
* @return CommonResponse
*/
CommonResponse renameCancel(OperationRequest operationReq);
/**
* 园丁采购
* @param operationReq
* @return CommonResponse
*/
CommonResponse buy(OperationRequest operationReq);
/**
* 园丁浇水
......
......@@ -40,4 +40,34 @@ public interface MarketService {
* @return CommonResponse
*/
CommonResponse sellCancel(OperationRequest operationReq);
/**
* 统一出售指令
* @param operationReq
* @return CommonResponse
*/
CommonResponse sellAllCheck(OperationRequest operationReq);
/**
* 确认统一出售指令
* @param operationReq
* @return CommonResponse
*/
CommonResponse sellAll(OperationRequest operationReq);
/**
* 取消统一出售指令
* @param operationReq
* @return CommonResponse
*/
CommonResponse sellAllCancel(OperationRequest operationReq);
/**
* 确认取消指令
* @param operationReq
* @return CommonResponse
*/
CommonResponse cancel(OperationRequest operationReq);
/**
* 查询商品指令
* @param operationReq
* @return CommonResponse
*/
CommonResponse goodsCheck(OperationRequest operationReq);
}
......@@ -10,7 +10,7 @@ public interface NurseryService {
List<NurseryPojo> findAll();
/**
* 根据花圃编号查询当前花圃状态
* 查看花圃,根据花圃编号查询当前花圃状态
* @param operationReq
* @return CommonResponse
*/
......@@ -52,7 +52,7 @@ public interface NurseryService {
*/
CommonResponse nurseryUpgradeCancel(OperationRequest operationReq);
/**
* 开垦/开启花圃
* 开启新花圃, 开垦/开启花圃
* @param operationReq
* @return CommonResponse
*/
......@@ -68,7 +68,7 @@ public interface NurseryService {
* @param operationReq
* @return CommonResponse
*/
CommonResponse NurseryResetCheck(OperationRequest operationReq);
CommonResponse nurseryResetCheck(OperationRequest operationReq);
/**
* 确认重置花圃
* @param operationReq
......
......@@ -11,11 +11,23 @@ public interface PetService {
*/
CommonResponse petView(OperationRequest operationReq);
/**
* 宠物移动指令
* 宠物移动指令,将宠物栏中的宠物移动至花圃
* @param operationReq
* @return CommonResponse
*/
CommonResponse petMove(OperationRequest operationReq);
CommonResponse petMoveToNursery(OperationRequest operationReq);
/**
* 宠物移至宠物栏指令,将宠物从花圃中移动至宠物栏
* @param operationReq
* @return CommonResponse
*/
CommonResponse petMoveToField(OperationRequest operationReq);
/**
* 花圃宠物移动指令,将宠物从花圃中移动至另一花圃
* @param operationReq
* @return CommonResponse
*/
CommonResponse nurseryPetMove(OperationRequest operationReq);
/**
* 宠物删除指令,查找宠物并询问玩家是否继续删除
* @param operationReq
......
......@@ -2,7 +2,7 @@ package com.qiwuai.garden.service.plantService;
import com.qiwuai.garden.dto.base.CommonResponse;
import com.qiwuai.garden.dto.request.*;
import com.qiwuai.garden.pojo.PlantAttributePojo;
import com.qiwuai.garden.pojo.AttributePojo;
import com.qiwuai.garden.pojo.PlantPeriodPojo;
import com.qiwuai.garden.pojo.PlantPojo;
......@@ -18,7 +18,7 @@ public interface PlantService {
int plantPeriodAdd(PlantPeriodConfigReq plantPeriodConfigReq);
List<PlantAttributePojo> plantAttributeSearch();
List<AttributePojo> plantAttributeSearch();
int plantAttributeAdd(PlantAttributeConfigReq plantAttributeConfigReq);
......@@ -42,7 +42,7 @@ public interface PlantService {
CommonResponse seedCancel(OperationRequest operationReq);
/**
* 收取,园丁收获
* @param harvestRequest
* @param operationReq
* @return CommonResponse
*/
CommonResponse harvest(OperationRequest operationReq) throws ParseException;
......
package com.qiwuai.garden.service.socialService;
import com.qiwuai.garden.dto.base.CommonResponse;
import com.qiwuai.garden.dto.request.OperationRequest;
public interface SocialService {
/**
* 拜访陌生人/好友
* @param operationReq
* @return CommonResponse
*/
CommonResponse visitStrangerCheck(OperationRequest operationReq);
/**
* 确定拜访,跨地区访问
* @param operationReq
* @return CommonResponse
*/
CommonResponse visitStranger(OperationRequest operationReq);
/**
* 取消拜访,取消跨地区访问
* @param operationReq
* @return CommonResponse
*/
CommonResponse visitStrangerCancel(OperationRequest operationReq);
/**
* 随机拜访陌生人
* @param operationReq
* @return CommonResponse
*/
CommonResponse visitStrangerRandom(OperationRequest operationReq);
/**
* 添加好友
* @param operationReq
* @return CommonResponse
*/
CommonResponse addFriendAsk(OperationRequest operationReq);
/**
* 查看好友申请
* @param operationReq
* @return CommonResponse
*/
CommonResponse addFriendCheck(OperationRequest operationReq);
/**
* 查看指定好友申请
* @param operationReq
* @return CommonResponse
*/
CommonResponse addFriendCheckByName(OperationRequest operationReq);
/**
* 接受好友申请
* @param operationReq
* @return CommonResponse
*/
CommonResponse addFriendRequestAgree(OperationRequest operationReq);
/**
* 拒绝好友申请
* @param operationReq
* @return CommonResponse
*/
CommonResponse addFriendRequestReject(OperationRequest operationReq);
/**
* 拜访特殊好友,通过指定情况拜访好友,比如拜访成熟果实的好友
* @param operationReq
* @return CommonResponse
*/
CommonResponse visitFriendSpecialCheck(OperationRequest operationReq);
/**
* 拒绝好友申请
* @param operationReq
* @return CommonResponse
*/
CommonResponse visitFriendRandomCheck(OperationRequest operationReq);
/**
* 删除好友
* @param operationReq
* @return CommonResponse
*/
CommonResponse deleteFriendCheck(OperationRequest operationReq);
/**
* 确定删除
* @param operationReq
* @return CommonResponse
*/
CommonResponse deleteFriend(OperationRequest operationReq);
/**
* 取消删除
* @param operationReq
* @return CommonResponse
*/
CommonResponse deleteFriendCancel(OperationRequest operationReq);
/**
* 查看园地
* @param operationReq
* @return CommonResponse
*/
CommonResponse checkGarden(OperationRequest operationReq);
/**
* 设置收益比例
* @param operationReq
* @return CommonResponse
*/
CommonResponse setEarnRateCheck(OperationRequest operationReq);
/**
* 确定设置收益比例
* @param operationReq
* @return CommonResponse
*/
CommonResponse setEarnRate(OperationRequest operationReq);
/**
* 取消设置收益比例
* @param operationReq
* @return CommonResponse
*/
CommonResponse setEarnRateCancel(OperationRequest operationReq);
/**
* 偷菜
* @param operationReq
* @return CommonResponse
*/
CommonResponse stealOther(OperationRequest operationReq);
/**
* 随机偷菜
* @param operationReq
* @return CommonResponse
*/
CommonResponse stealOtherRandom(OperationRequest operationReq);
/**
* 帮助好友
* @param operationReq
* @return CommonResponse
*/
CommonResponse helpFriend(OperationRequest operationReq);
/**
* 查询本人地址
* @param operationReq
* @return CommonResponse
*/
CommonResponse checkLocationSelf(OperationRequest operationReq);
/**
* 查看简报
* @param operationReq
* @return CommonResponse
*/
CommonResponse checkReport(OperationRequest operationReq);
/**
* 查看帮助简报
* @param operationReq
* @return CommonResponse
*/
CommonResponse checkHelpReport(OperationRequest operationReq);
/**
* 查看偷菜简报
* @param operationReq
* @return CommonResponse
*/
CommonResponse checkStealReport(OperationRequest operationReq);
/**
* 查看战斗详情
* @param operationReq
* @return CommonResponse
*/
CommonResponse checkFightDetail(OperationRequest operationReq);
/**
* 查看战斗详情
* @param operationReq
* @return CommonResponse
*/
CommonResponse getFightDetail(OperationRequest operationReq);
/**
* 删除简报
* @param operationReq
* @return CommonResponse
*/
CommonResponse deleteReport(OperationRequest operationReq);
}
This source diff could not be displayed because it is too large. You can view the blob instead.
server:
port: 8082
serlvet:
context-path:/secretGarden
#设置当前服务名
spring:
......@@ -45,6 +47,10 @@ eureka:
#是否检索注册中心信息
fetch-registry: false
expireTime: 180000
expire:
time: 180000
\ No newline at end of file
userFilePath: /home/secretGarden/secretGardenUser/
speechFilePath: /home/secretGarden/secretGardenSpeech/
configFilePath: /home/secretGarden/config/
\ No newline at end of file
server:
port: 60016
serlvet:
context-path:/secretGarden
#设置当前服务名
spring:
application:
#注册到注册中心的服务名
name: secret-garden
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/secret_garden?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
username: root
password: 38A0O1jEPOE
type: com.alibaba.druid.pool.DruidDataSource
druid:
initial-size: 5
min-idle: 5
max-active: 20
max-wait: 60000
#配置间隔多久才进行一次检测,检测需要关闭的空闲连接
time-between-eviction-runs-millis: 20000
#配置一个连接在池中最小生存的时间
min-evictable-idle-time-millis: 300000
cloud:
inetutils:
#设置主机ip超时时间,默认1秒
timeout-seconds: 10
mybatis:
type-aliases-package: com.qiwuai.garden.pojo
mapper-locations: classpath:com/qiwuai/garden/dao/*.xml
configuration:
map-underscore-to-camel-case: true
eureka:
instance:
hostname: 127.0.0.1
client:
serviceUrl:
#设置添加服务中心的地址
defaultZone: http://${eureka.instance.hostname}:8081/eureka/
#将当前服务注册到到注册中心(true)
register-with-eureka: false
#是否检索注册中心信息
fetch-registry: false
expireTime: 180000
userFilePath: /home/secretGarden/secretGardenUser/
speechFilePath: /home/secretGarden/secretGardenSpeech/
configFilePath: /home/secretGarden/config/
\ No newline at end of file
......@@ -2,18 +2,18 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwuai.garden.dao.PlantAttributeMapper">
<select id="searchAll" resultType="com.qiwuai.garden.pojo.PlantAttributePojo">
<mapper namespace="com.qiwuai.garden.dao.AttributeMapper">
<select id="searchAll" resultType="com.qiwuai.garden.pojo.AttributePojo">
select
id, attribute, create_time, update_time
id, attribute, restrain_ids, create_time, update_time
from
plant_attribute
attribute
</select>
<insert id="add">
insert into plant_attribute
(attribute, create_time, update_time)
insert into attribute
(attribute, restrainIds, create_time, update_time)
values
(#{attribute}, #{createTime}, #{updateTime})
(#{attribute}, #{restrainIds}, #{createTime}, #{updateTime})
</insert>
</mapper>
\ No newline at end of file
......@@ -7,7 +7,7 @@
<select id="findAll" resultType="com.qiwuai.garden.pojo.GardenerLevelPojo">
select
id, task_ids, gardener_skill_ids, cost_item_nums,
nursery_num_max, pet_num_max, pet_field_max, steel_times_max, price_add_prob,
nursery_num_max, pet_num_max, steal_times_max, price_add_prob,
create_time, update_time
from
gardener_level
......
......@@ -6,7 +6,7 @@
<select id="findAll" resultType="com.qiwuai.garden.pojo.GardenerSkillPojo">
select
id, name, description, type, type_a, type_b, type_c, create_time, update_time
id, name, description, skill_type_id, type_a, type_b, type_c, create_time, update_time
from
gardener_skill
</select>
......
......@@ -6,7 +6,7 @@
<select id="findAll" resultType="com.qiwuai.garden.pojo.NurseryPojo">
select
id, name, description, level, pre_id,
plant_id_times, cost, item_id_nums, add_harvest, capacity, pet_field,
plant_id_times, item_id_nums, add_harvest, capacity, pet_field,
create_time, update_time
from
nursery
......
......@@ -6,7 +6,7 @@
<select id="findAll" resultType="com.qiwuai.garden.pojo.PetPojo">
select
id, name, type_id, description, rarity_id, favorite_plant_id, appear_prob, pet_attribute_id,
id, name, type_id, description, rarity_id, favorite_plant_id, appear_prob, attribute_ids,
hp, fc, drop_items, drop_nums, drop_probs, add_item_set_id, feed_cost, level, price, create_time, update_time
from
pet
......
......@@ -4,9 +4,9 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwuai.garden.dao.PlantMapper">
<sql id="plant">
id, name, description, plant_type_id, plant_attribute_id,
id, name, description, plant_type_id, attribute_id,
occupy_area, nursery_level, nursery_id, gardener_level, gardener_skill_id,
near_plant_id, pet_id, cost_item_nums, fruit_id, fruit_num, fruit_seed_num,
near_plant_ids, pet_id, cost_item_nums, fruit_id, fruit_num, fruit_seed_num,
fruit_times, fruit_mature_time, drop_items, drop_nums, drop_probs, add_item_set_id, rarity_id, price,
spout_condition, fruit_condition, mature_condition, create_time, update_time
</sql>
......@@ -19,15 +19,15 @@
<insert id="add">
insert into plant (
name, description, plant_type_id, plant_attribute_id,
name, description, plant_type_id, attribute_id,
occupy_area, nursery_level, nursery_id, gardener_level, gardener_skill_id,
near_plant_id, pet_id, cost_item_nums, fruit_id, fruit_num, fruit_seed_num,
near_plant_ids, pet_id, cost_item_nums, fruit_id, fruit_num, fruit_seed_num,
fruit_times, fruit_mature_time, drop_items, drop_nums, drop_probs, add_item_set_id, rarity_id, price,
spout_condition, fruit_condition, mature_condition, create_time, update_time
) values (
#{name},#{description},#{plantTypeId},#{plantAttributeId},
#{name},#{description},#{plantTypeId},#{attributeId},
#{occupyArea},#{nurseryLevel},#{nurseryId}, #{gardenerLevel}, #{gardenerSkillId},
#{nearPlantId},#{petId},#{costItemNums},#{fruitId},#{fruitNum}, {fruitSeedNum},
#{nearPlantIds},#{petId},#{costItemNums},#{fruitId},#{fruitNum}, {fruitSeedNum},
#{fruitTimes},#{fruitMatureTime},#{dropItems},#{dropNums},#{dropProbs},#{addItemSetId},#{rarityId},#{price},
#{spoutCondition},#{fruitCondition},#{matureCondition},#{createTime},#{updateTime}
)
......
......@@ -2,18 +2,12 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwuai.garden.dao.PlantAttributeMapper">
<select id="searchAll" resultType="com.qiwuai.garden.pojo.PlantAttributePojo">
<mapper namespace="com.qiwuai.garden.dao.QuantityRangeMapper">
<select id="findAll" resultType="com.qiwuai.garden.pojo.QuantityRangePojo">
select
id, attribute, create_time, update_time
id, name, type, min, max, description
from
plant_attribute
quantity_range
</select>
<insert id="add">
insert into plant_attribute
(attribute, create_time, update_time)
values
(#{attribute}, #{createTime}, #{updateTime})
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwuai.garden.dao.RarityMapper">
<select id="findAll" resultType="com.qiwuai.garden.pojo.RarityPojo">
select
id, description, create_time, update_time
from
rarity
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwuai.garden.dao.RegionMapper">
<select id="findAll" resultType="com.qiwuai.garden.pojo.RegionPojo">
select
id, place, server_ip, create_time, update_time
from
region
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="fatal">
<!--打印在本地,根据具体存储地址填写-->
<Properties>
<Property name="baseDir" value="/home/secretGarden/logs"/>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch) -->
<ThresholdFilter level="info" onMatch="ACCEPT"
onMismatch="DENY"/>
<PatternLayout
pattern="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%level] [%logger{36}] - %msg%n"/>
</Console>
<!--debug级别日志文件输出-->
<RollingFile name="debug_appender" fileName="${baseDir}/debug.log"
filePattern="${baseDir}/debug_%i.log.%d{yyyy-MM-dd}">
<!-- 过滤器 -->
<Filters>
<!-- 限制日志级别在debug及以上在info以下 -->
<ThresholdFilter level="debug"/>
<ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
</Filters>
<!-- 日志格式 -->
<PatternLayout pattern="[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
<!-- 策略 -->
<Policies>
<!-- 每隔一天转存 -->
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<!-- 文件大小 -->
<SizeBasedTriggeringPolicy size="100 MB"/>
</Policies>
</RollingFile>
<!-- info级别日志文件输出 -->
<RollingFile name="info_appender" fileName="${baseDir}/info.log"
filePattern="${baseDir}/info_%i.log.%d{yyyy-MM-dd}">
<!-- 过滤器 -->
<Filters>
<!-- 限制日志级别在info及以上在error以下 -->
<ThresholdFilter level="info"/>
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
</Filters>
<!-- 日志格式 -->
<PatternLayout pattern="[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
<!-- 策略 -->
<Policies>
<!-- 每隔一天转存 -->
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<!-- 文件大小 -->
<SizeBasedTriggeringPolicy size="100 MB"/>
</Policies>
</RollingFile>
<!-- error级别日志文件输出 -->
<RollingFile name="error_appender" fileName="${baseDir}/error.log"
filePattern="${baseDir}/error_%i.log.%d{yyyy-MM-dd}">
<!-- 过滤器 -->
<Filters>
<!-- 限制日志级别在error及以上 -->
<ThresholdFilter level="error"/>
</Filters>
<!-- 日志格式 -->
<PatternLayout pattern="[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
<Policies>
<!-- 每隔一天转存 -->
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<!-- 文件大小 -->
<SizeBasedTriggeringPolicy size="100 MB"/>
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="Console"/>
<AppenderRef ref="debug_appender"/>
<AppenderRef ref="info_appender"/>
<AppenderRef ref="error_appender"/>
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
server:
port: 8082
serlvet:
context-path:/secretGarden
#设置当前服务名
spring:
......@@ -45,6 +47,10 @@ eureka:
#是否检索注册中心信息
fetch-registry: false
expireTime: 180000
expire:
time: 180000
\ No newline at end of file
userFilePath: /home/secretGarden/secretGardenUser/
speechFilePath: /home/secretGarden/secretGardenSpeech/
configFilePath: /home/secretGarden/config/
\ No newline at end of file
......@@ -7,7 +7,7 @@
<select id="findAll" resultType="com.qiwuai.garden.pojo.GardenerLevelPojo">
select
id, task_ids, gardener_skill_ids, cost_item_nums,
nursery_num_max, pet_num_max, pet_field_max, steel_times_max, price_add_prob,
nursery_num_max, pet_num_max, steal_times_max, price_add_prob,
create_time, update_time
from
gardener_level
......
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