Merge branch 'master' into develop

back_recharge
lvxinran 2020-06-01 21:10:48 +08:00
commit 173458590b
31 changed files with 1104 additions and 354 deletions

View File

@ -1,14 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<Ldb >
<Jbean name="ActivityProgressInfo">
<Variable name="state" type="int"/>
<Variable name="progrss" type="int"/>
</Jbean>
<Jbean name="ActivityMission">
<Variable name="activityMissionMap" type="map" key="int" value="ActivityProgressInfo" />
<Variable name="activityMissionMap" type="map" key="int" value="ActivityProgressInfo" />
<Variable name="activityState" type="int"/>
<Variable name="openType" type="int"/>
<Variable name="v" type="int"/>
@ -25,8 +23,8 @@
</Jbean>
<Jbean name="ActivityManager">
<Variable name="activityMissionMap" type="map" key="int" value="ActivityMission" />
<Variable name="senvenTime" type="long"/> 七日狂欢结束时间
<Variable name="activityMissionMap" type="map" key="int" value="ActivityMission" />
<Variable name="senvenStartTime" type="long"/> 七日狂欢开始时间
<Variable name="luckWheel" type="LuckWheelMission"/>幸运探宝奖池
<Variable name="luckWheelAdvance" type="LuckWheelMission"/>高级幸运探宝奖池
</Jbean>

View File

@ -23,7 +23,7 @@ public class WorldBossTreasureStaticConfig extends AbstractClassStaticConfig {
Map<Integer,Set<SWorldBossTreasureConfig>> idsByPeriodsTmp = new HashMap<>();
config.forEach((id,item)->{
int[] activityIds = item.getActivityId();
idsByPeriodsTmp.putIfAbsent(activityIds[0], new HashSet<>());
idsByPeriodsTmp.putIfAbsent(activityIds[0], new LinkedHashSet<>());
Set<SWorldBossTreasureConfig> ids = idsByPeriodsTmp.get(activityIds[0]);
for(int i=1;i<activityIds.length;i++){
idsByPeriodsTmp.putIfAbsent(activityIds[i],ids);

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.globals.GlobalItemType;
import com.ljsd.jieling.logic.dao.Equip;
import com.ljsd.jieling.logic.dao.Jewel;
import com.ljsd.jieling.logic.dao.PropertyItem;
import com.mongodb.BasicDBObject;
@ -22,6 +23,8 @@ public class MongoPropertyConverter implements Converter<BasicDBObject, Property
Class<? extends PropertyItem> target = PropertyItem.class;
if(equipId.getItemType() == GlobalItemType.JEWEL){
target = Jewel.class;
}else {
target = Equip.class;
}
String realJson = source.toJson(jsonWriterSettings);
PropertyItem propertyItem = JSON.parseObject(realJson,target);

View File

@ -1,9 +1,17 @@
package com.ljsd.jieling.db.mongo;
import com.google.gson.Gson;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import com.ljsd.common.mogodb.LjsdMongoTemplate;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.util.ConfigurableApplicationContextManager;
import com.ljsd.jieling.util.InnerMessageUtil;
import com.ljsd.jieling.util.SysUtil;
import io.netty.util.internal.MathUtil;
import org.springframework.data.annotation.Transient;
import util.MathUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -11,9 +19,14 @@ import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.lang.reflect.Type;
import java.net.UnknownHostException;
import java.util.List;
import java.util.Random;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
public class MongoUtil {
@ -40,8 +53,8 @@ public class MongoUtil {
private MongoTemplate coreMongoTemplate;
public void init(){
myMongoTemplate = ConfigurableApplicationContextManager.getBean(LjsdMongoTemplate.class);
public void init() {
myMongoTemplate = ConfigurableApplicationContextManager.getBean(LjsdMongoTemplate.class);
coreMongoTemplate = (MongoTemplate) ConfigurableApplicationContextManager.getBean("coreMongoTemplate");
}
@ -53,11 +66,12 @@ public class MongoUtil {
this.myMongoTemplate.lastUpdate();
}
public static LjsdMongoTemplate getLjsdMongoTemplate() throws UnknownHostException {
return MongoUtil.getInstence().getMyMongoTemplate();
public static LjsdMongoTemplate getLjsdMongoTemplate() throws UnknownHostException {
return MongoUtil.getInstence().getMyMongoTemplate();
}
public List<User> getRandomUsers(int size, int uid, int level) throws Exception {
if(size <= 0){
public List<User> getRandomUsers(int size, int uid, int level) throws Exception {
if (size <= 0) {
return null;
}
int randomLevel = MathUtils.random(5, 20);
@ -70,15 +84,16 @@ public class MongoUtil {
criatira.andOperator(Criteria.where("id").nin(uid),
Criteria.where("playerManager.level").gte(minLevel), Criteria.where("playerManager.level").lte(maxLevel),
Criteria.where("playerManager.loginTime").gte(befor3Day));//不包含自己
Query query = new Query(criatira).limit(size*2+1);
Query query = new Query(criatira).limit(size * 2 + 1);
query.fields().include("playerManager");
return this.myMongoTemplate.findAllByCondition(query, User.class) ;
return this.myMongoTemplate.findAllByCondition(query, User.class);
}
public static MongoTemplate getCoreMongoTemplate() throws UnknownHostException {
return MongoUtil.getInstence().coreMongoTemplate;
}
public static void main(String[] args) {
try {
LjsdMongoTemplate ljsdMongoTemplate = getLjsdMongoTemplate();
@ -105,6 +120,113 @@ public class MongoUtil {
}
public static void checkDb() {
Set<Integer> set = OnlineUserManager.sessionMap.keySet();
Integer[] integers = set.toArray(new Integer[0]);
Set<Integer> ids = new HashSet<>();
if (set.size() == 0) {
return;
}
Random random = new Random();
for (int i = 0; i < 3; i++) {
int i1 = random.nextInt(set.size());
if (i1 >= integers.length) {
continue;
}
ids.add(integers[i1]);
}
InnerMessageUtil.broadcastWithRandom(user -> {
int id = user.getId();
User byId = MongoUtil.getInstence().getMyMongoTemplate().findById(User.getCollectionName(), user.getId(), User.class);
Gson gson = new GsonBuilder()
.addSerializationExclusionStrategy(new ExclusionStrategy() {
@Override
public boolean shouldSkipClass(Class<?> arg0) {
return false;
}
@Override
public boolean shouldSkipField(FieldAttributes arg0) {
Transient annotation = arg0.getAnnotation(Transient.class);
if (annotation != null) {
return true;
}
return false;
}
}).registerTypeAdapter(HashMap.class, new JsonSerializer<AbstractMap>() {
@Override
public JsonElement serialize(AbstractMap abstractMap, Type type, JsonSerializationContext jsonSerializationContext) {
TreeMap<Object, Object> treeMap = new TreeMap<>(abstractMap);
JsonParser jp = new JsonParser();
JsonElement je = jp.parse(String.valueOf(JSON.toJSON(treeMap)));
return je;
}
}
).create();
String s = gson.toJson(byId);
String s1 = gson.toJson(user);//内存
char v1[] = s.toCharArray();
char v2[] = s1.toCharArray();
int n = v2.length;
int m2 = v2.length;
int j = 0;
while (n-- != 0) {
if (v1[j] != v2[j]) {
System.out.println("args = [" + v1[j] + "][" + v2[j] + "]\r\n");
break;
}
j++;
}
int start = Math.max(0, j - 50);
int end = Math.min(j + 1, m2);
if (j != m2) {
File file1 = new File(SysUtil.getPath("conf/checkout_db" + id + ".txt"));
try (PrintWriter printWriter = new PrintWriter(new FileOutputStream(file1));) {
printWriter.print(s);
printWriter.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
File file2 = new File(SysUtil.getPath("conf/checkout_mem" + id + ".txt"));
try (PrintWriter printWriter = new PrintWriter(new FileOutputStream(file2));) {
printWriter.print(s1);
printWriter.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
File file3 = new File("conf/checkout_diff_start" + id + ".txt");
String substring = s1.substring(start, end);
String dbstring = s.substring(start, end);
try (PrintWriter printWriter = new PrintWriter(new FileOutputStream(file3));) {
printWriter.print("mem\r\n" + substring);
printWriter.print("\r\n");
printWriter.print("db\r\n" + dbstring);
printWriter.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
LOGGER.error("定期检查数据库对象数据一致性 err" + byId.getId() + " \r\nmem_string \r\n" + substring + " \r\ndb_string \r\n" + dbstring);
} else {
LOGGER.info("定期检查数据库对象数据一致性 匹配" + byId.getId());
}
JsonParser parser = new JsonParser();
JsonObject obj = (JsonObject) parser.parse(s1);
JsonParser parser1 = new JsonParser();
JsonObject obj1 = (JsonObject) parser1.parse(s); //也可以 不好排查
if(obj.equals(obj1)){
LOGGER.info(" 匹配");
}else {
LOGGER.info(" not 匹配");
}
}, new LinkedList<>(ids), 2);
}
}

View File

@ -264,7 +264,7 @@ public class EndExpeditionBattleRequest extends BaseHandler<Expedition.EndExpedi
if(hero==null){
throw new ErrorCodeException("试炼节点英雄掉落失败");
}
Hero hero1 = ExpeditionLogic.createHero(i, uid, hero,false);
Hero hero1 = ExpeditionLogic.createHero(i, uid, hero,-1);
drop.addHero(CBean2Proto.getHero(hero1));
}

View File

@ -49,11 +49,11 @@ public class HeroNodeGetInfoRequestHandler extends BaseHandler<Expedition.HeroNo
if (nodeInfo.getType() != ExpeditionLogic.NODETYPE_HERO_GET) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点类型不符"+nodeInfo.getType()));
}
//check node
List<Integer> nextNodeId = ExpeditionLogic.getNextNodeId(user.getExpeditionManager().getSortid(),user.getExpeditionManager().getExpeditionNodeInfos().size());
if(!nextNodeId.contains(nodeId)){
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点状态不正确"));
}
// //check node
// List<Integer> nextNodeId = ExpeditionLogic.getNextNodeId(user.getExpeditionManager().getSortid(),user.getExpeditionManager().getExpeditionNodeInfos().size());
// if(!nextNodeId.contains(nodeId)){
// throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点状态不正确"));
// }
SExpeditionNodeConfig sExpeditionNodeConfig = STableManager.getConfig(SExpeditionNodeConfig.class).get(nodeInfo.getType());
if (sExpeditionNodeConfig == null) {
@ -69,7 +69,7 @@ public class HeroNodeGetInfoRequestHandler extends BaseHandler<Expedition.HeroNo
int recruitTime = sExpeditionSetting.getRecruitTime();
Map<String, Hero> heroMapTemp = user.getExpeditionManager().getHeroMapTemp();
Map<String, Hero> heroMapTemp = user.getExpeditionManager().getHeroMapTemp(nodeId);
if(heroMapTemp.size()==0){
SExpeditionRecruitConfig sExpeditionRecruitConfig = STableManager.getConfig(SExpeditionRecruitConfig.class).get(sExpeditionNodeConfig.getPoolId());
if(sExpeditionRecruitConfig!=null) {
@ -86,12 +86,12 @@ public class HeroNodeGetInfoRequestHandler extends BaseHandler<Expedition.HeroNo
}
for (int j = 0; j < recruitTime; j++) {
ExpeditionLogic.createHero(i, uid, hero, true);
ExpeditionLogic.createHero(i, uid, hero, nodeId);
}
}
}
heroMapTemp = user.getExpeditionManager().getHeroMapTemp(nodeId);
heroMapTemp.forEach((s, hero) -> {
CommonProto.ViewHeroInfo.Builder inner = CommonProto.ViewHeroInfo.newBuilder();
Map<Integer, Integer> heroNotBufferAttribute = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, true, 0);

View File

@ -65,12 +65,12 @@ public class HeroNodeRequestHandler extends BaseHandler<Expedition.HeroNodeReque
}
ExpeditionManager expeditionManager = user.getExpeditionManager();
if(!expeditionManager.getHeroMapTemp().containsKey(heroId)){
if(!expeditionManager.getHeroMapTemp(nodeId).containsKey(heroId)){
throw new ErrorCodeException("参数错误");
}
//move temp to
Hero hero = expeditionManager.getHeroMapTemp().get(heroId);
Hero hero = expeditionManager.getHeroMapTemp(nodeId).get(heroId);
expeditionManager.addHero(hero);
Map<String, PropertyItem> equipMapTemp = expeditionManager.getEquipMapTemp();
@ -98,8 +98,8 @@ public class HeroNodeRequestHandler extends BaseHandler<Expedition.HeroNodeReque
drop.addHero(CBean2Proto.getHero(hero));
//clear temp
user.getExpeditionManager().clearEquipToTemp();
user.getExpeditionManager().clearHeroToTemp();
// user.getExpeditionManager().clearEquipToTemp();
// user.getExpeditionManager().clearHeroToTemp();
SExpeditionNodeConfig sExpeditionNodeConfig = STableManager.getConfig(SExpeditionNodeConfig.class).get(nodeInfo.getType());

View File

@ -116,6 +116,10 @@ public class TakeLayRewardHandler extends BaseHandler<Expedition.TakeExpeditionB
ExpeditionManager manager = user.getExpeditionManager();
manager.clearExpeditionNodeInfos();
}
if(expeditionManager.getExpeditionLeve()==3){
expeditionManager.setPassTimes(expeditionManager.getPassTimes()+1);
}
user.getExpeditionManager().addRewardBox(laycfg);
Expedition.TakeExpeditionBoxRewardResponse builder = Expedition.TakeExpeditionBoxRewardResponse.newBuilder().setDrop(drop).addAllLeve(objects).build();
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.EXPEDITION_TAKE_BOXREWARD_RESONSE_VALUE, builder, true);

View File

@ -25,6 +25,7 @@ public final class ActivityManager extends MongoBase {
public ActivityManager(ActivityManager _o_ ) {
this.activityMissionMap = new HashMap<Integer, com.ljsd.jieling.jbean.ActivityMission>();
_o_.activityMissionMap.forEach((_k_, _v_) -> this.activityMissionMap.put(_k_, new ActivityMission(_v_)));
this.senvenStartTime = _o_.senvenStartTime;
this.luckWheel = new LuckWheelMission(_o_.luckWheel);
this.luckWheelAdvance = new LuckWheelMission(_o_.luckWheelAdvance);
}
@ -35,6 +36,9 @@ public final class ActivityManager extends MongoBase {
return this.activityMissionMapLog;
}
public long getSenvenStartTime() { // 七日狂欢开始时间
return this.senvenStartTime;
}
public com.ljsd.jieling.jbean.LuckWheelMission getLuckWheel() { // 幸运探宝奖池
return this.luckWheel;
@ -44,17 +48,11 @@ public final class ActivityManager extends MongoBase {
return this.luckWheelAdvance;
}
public void setSenvenStartTime(long senvenStartTime) {
updateString("senvenStartTime",senvenStartTime);
this.senvenStartTime = senvenStartTime;
public void setSenvenStartTime(long senvenstarttime) { // 七日狂欢开始时间
updateString("senvenStartTime",senvenstarttime);
this.senvenStartTime = senvenstarttime;
}
public long getSenvenStartTime() {
return senvenStartTime;
}
public void setLuckWheel(LuckWheelMission luckwheel) { // 幸运探宝奖池
updateString("luckWheel",luckwheel);
luckwheel.init(getRootId(),getMongoKey()+ ".luckWheel");
@ -73,6 +71,7 @@ public final class ActivityManager extends MongoBase {
StringBuilder _sb_ = new StringBuilder(super.toString());
_sb_.append("=(");
_sb_.append(this.activityMissionMap).append(",");
_sb_.append(this.senvenStartTime).append(",");
_sb_.append(this.luckWheel).append(",");
_sb_.append(this.luckWheelAdvance).append(",");
_sb_.append(")");

View File

@ -0,0 +1,36 @@
package com.ljsd.jieling.kefu;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.thread.task.MinuteTask;
import com.ljsd.jieling.util.InnerMessageUtil;
import com.ljsd.jieling.util.SysUtil;
import org.springframework.data.annotation.Transient;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.Random;
import java.util.Set;
//checkdb
public class Cmd_checkdb extends GmAbstract {
@Override
public boolean exec(String[] args) throws Exception {
// for (int i = 0; i <150 ; i++) {
// String key = RedisKey.getKey(RedisKey.FORCE_RANK, "", false);
// RedisUtil.getInstence().zsetAddOne(key, String.valueOf(10000+i), 10000+i);
// }
MongoUtil.checkDb();
return true;
}
}

View File

@ -0,0 +1,24 @@
package com.ljsd.jieling.kefu;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.logic.dao.ExpeditionManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
/**
* Description: 线
*
* //role_fix 10043343
* CreateDate: 2019/9/26 11:48
*/
public class Cmd_role_fix extends GmRoleAbstract {
@Override
public boolean exec(String[] args) throws Exception {
User user = UserManager.getUser(10043385);
user.getExpeditionManager().setPassTimes(-1);
//mongo
MongoUtil.getInstence().lastUpdate();
return true;
}
}

View File

@ -1,51 +1,478 @@
package com.ljsd.jieling.kefu;
import com.google.gson.Gson;
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
import com.ljsd.jieling.config.clazzStaticCfg.SArenaRobotStaticConfig;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.core.VipPrivilegeType;
import com.ljsd.jieling.logic.dao.ExpeditionManager;
import com.ljsd.jieling.logic.dao.SnapFightInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.logic.blood.BloodLogic;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.expedition.ExpeditionLogic;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.protocols.Expedition;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.MessageUtil;
import com.ljsd.jieling.util.MonsterUtil;
import config.*;
import manager.STableManager;
import org.springframework.data.redis.core.ZSetOperations;
import util.MathUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* Description: 线
* Author: zsx .//role_gm 10041063
*
* //role_gm 10040936
* //role_gm 10043387
* CreateDate: 2019/9/26 11:48
*/
public class Cmd_role_gm extends GmRoleAbstract {
boolean isfirst =false;
@Override
public boolean exec(String[] args) throws Exception {
// ExpeditionLogic.getInstance().flushUserdataEveryDay(getUser());
boolean check = PlayerLogic.getInstance().check(getUser(), VipPrivilegeType.EXPEDITION_RELIVE, 1);
// boolean check = PlayerLogic.getInstance().check(getUser(), VipPrivilegeType.EXPEDITION_RELIVE, 1);
//
// System.out.println("c"+check);
int NODESTATE_CLOSE = 0;//0未开启
int NODESTATE_NOT_PASS = 1;//1未通过
int NODESTATE_NOT_GET = 2;//2未领取圣物
int NODESTATE_PASS = 3;//已完成
int NODESTATE_OVER_PASS = 4;//已完成
int NODESTATE_HERO = 5;//招募节点
int NODETYPE_ADVANCE = 1;//精英节点
int NODETYPE_BOSS = 2;//首领节点
int NODETYPE_RELIVE = 3;//复活节点
int NODETYPE_RECOVER = 4;//回复节点
int NODETYPE_NORMAL = 5;//普通节点
int NODETYPE_HERO_GET = 7;//招募节点
int NODETYPE_SHOP = 8;//商店节点
int NODETYPE_TRY = 9;//试炼节点
int NODETYPE_GREED= 10;//贪婪节点
int NODETYPE_REWARD= 11;//奖励节点
User user = getUser();
ExpeditionManager expeditionManager = user.getExpeditionManager();
expeditionManager.setPassTimes(-1);
expeditionManager.setExpeditionLeve(2);
ExpeditionManager manager = user.getExpeditionManager();
manager.setLay(1);
manager.setSortid(0);
manager.setExpeditionLeve(2);
manager.clearRewardBox();
manager.clearPropertyItems();
manager.getHeroHPWithChange().clear();
manager.clearExpeditionNodeInfos();
manager.setLay(1);
manager.setSortid(0);
manager.clearRewardBox();
manager.clearPropertyItems();
manager.getHeroHPWithChange().clear();
manager.clearHeroToTemp();
manager.clearEquipToTemp();
manager.clearExpeditionNodeInfos();
//创建节点束河
Set<ExpeditionNodeInfo> nodeSets = createNodeSet(2);
nodeSets.forEach(nodeInfo -> {
int sortId = nodeInfo.getSortId();
if(nodeInfo.getState()==NODESTATE_PASS){
expeditionManager.setSortid(Math.max(expeditionManager.getSortid(),sortId));
}
SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1);
try {
if(nodeInfo.getType() == NODETYPE_ADVANCE || nodeInfo.getType() == NODETYPE_BOSS || nodeInfo.getType() == NODETYPE_NORMAL){
//生成节点boss信息
float size = STableManager.getFigureConfig(CommonStaticConfig.class).leve2num.get(2);
//战力基准值=maxforce*0.8+1/15(max-min)*lay
int minFoce = sExpeditionSetting.getMatchForce()[2][0];
int manFoce = sExpeditionSetting.getMatchForce()[2][1];
int standerFoce = (int) (user.getPlayerInfoManager().getMaxForce() * ((minFoce / 10000f) + ((float) nodeInfo.getLay()) / size * ((float) (manFoce - minFoce)/10000f)));
float randomForce = (standerFoce * ((sExpeditionSetting.getMatchForceRange()[0] + (int) (Math.random() * (sExpeditionSetting.getMatchForceRange()[1] - sExpeditionSetting.getMatchForceRange()[0]))) / 10000f));
if(nodeInfo.getType()==NODETYPE_ADVANCE){
randomForce*=(sExpeditionSetting.getPowerfulForce()[1][1]/10000f+1);
}else if(nodeInfo.getType()==NODETYPE_BOSS){
randomForce*=(sExpeditionSetting.getPowerfulForce()[2][1]/10000f+1);
}
Set<ZSetOperations.TypedTuple<String>> typedTuples = RedisUtil.getInstence().rangeByScoreWithScores(RedisKey.AREDEF_TEAM_FORCE_RANK, "", 0, randomForce);
if (typedTuples.size() == 0) {
//战力没有获取到 从机器人中选
// Set<Integer> set = ArenaLogic.randomRobot(SArenaSetting.getSArenaSetting().getScore(), 1);
//// if (set.size() == 0) {
//// throw new ErrorCodeException(ErrorCode.CFG_NULL);
//// }
// int robotId = set.iterator().next();
//提前战力排序 支持战力查找机器人
int robotId= SArenaRobotStaticConfig.getFloorForce2robotId((int)randomForce);
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(robotId);
snapOneFightInfo(nodeInfo, sArenaRobotConfig);
} else {
String serarchIdFromRank = typedTuples.iterator().next().getValue();
snapOneFightInfo(user, nodeInfo, Integer.valueOf(serarchIdFromRank));
}
}
if(nodeInfo.getType()==ExpeditionLogic.NODETYPE_GREED||nodeInfo.getType() ==ExpeditionLogic.NODETYPE_TRY){
snapOneFightInfo(nodeInfo);
}
} catch (Exception e) {
e.printStackTrace();
}
user.getExpeditionManager().putExpeditionNodeInfos(sortId, nodeInfo);
});
System.out.println("c"+check);
// User user = getUser();
// ExpeditionManager manager = user.getExpeditionManager();
// Expedition.GetExpeditionResponse.Builder builder = Expedition.GetExpeditionResponse.newBuilder();
// builder.addAllLay(manager.getRewardBox());
// // builder.addAllHeroInfo(ExpeditionLogic.getInstance().getAllHeroInfo(user));
// // builder.addAllEquipIds(ExpeditionLogic.getInstance().getEquipnfo(user));
// ExpeditionLogic.getInstance().getNodeInfo(user).forEach(expeditionNodeInfo -> {
// if(expeditionNodeInfo.getType()!=1&&expeditionNodeInfo.getType()!=5&&expeditionNodeInfo.getType()!=2){
// return;
// }
//// builder.addNodeInfo(expeditionNodeInfo);
//
// SnapFightInfo snapFightInfo = user.getExpeditionManager().getExpeditionNodeInfos().get(expeditionNodeInfo.getSortId()).getSnapFightInfo();
// System.out.println(expeditionNodeInfo.getSortId()+"::"+snapFightInfo.getHeroAttribute().keySet().toString()+"::"+snapFightInfo.getForce()+"\r\n");
// });
//
// // System.out.println(new Gson().toJson(snapFightInfo));
//// builder.addAllNodeInfo(ExpeditionLogic.getInstance().getNodeInfo(user));
// System.out.println(builder.build().toString());
return true;
}
public static boolean isBattleNode(int type) {
int NODETYPE_ADVANCE = 1;//精英节点
int NODETYPE_BOSS = 2;//首领节点
int NODETYPE_RELIVE = 3;//复活节点
int NODETYPE_RECOVER = 4;//回复节点
int NODETYPE_NORMAL = 5;//普通节点
int NODETYPE_HERO_GET = 7;//招募节点
int NODETYPE_SHOP = 8;//商店节点
int NODETYPE_TRY = 9;//试炼节点
int NODETYPE_GREED= 10;//贪婪节点
int NODETYPE_REWARD= 11;//奖励节点
return type == NODETYPE_ADVANCE || type == NODETYPE_BOSS || type == NODETYPE_NORMAL;
}
/**
*
*/
private void snapOneFightInfo(ExpeditionNodeInfo nodeInfo, SArenaRobotConfig sArenaRobotConfig) {
if (!isBattleNode(nodeInfo.getType())) {
return;
}
SnapFightInfo fightInfo = new SnapFightInfo();
int force = sArenaRobotConfig.getTotalForce();
Map<String, FamilyHeroInfo> heroAllAttribute = new HashMap<>();
Map<Integer, Integer> heroStarsMap = sArenaRobotConfig.getStarOfHeroMap();
Map<String, Double> bossHP = new HashMap<>();
for (Map.Entry<Integer, Integer> item : heroStarsMap.entrySet()) {
StringBuilder skillSb = new StringBuilder();
Integer heroTid = item.getKey();
Integer heroStar = item.getValue();
SCHero scHero = SCHero.getsCHero().get(heroTid);
List<Integer> skillIds = scHero.getSkillListByStar(heroStar);
String heroSkill = HeroLogic.getInstance().getRobotHeroSkills(skillIds, skillSb).toString();
fightInfo.updateHeroSkill(heroTid.toString(), heroSkill.substring(0, heroSkill.length() - 1));
bossHP.put(heroTid.toString(), 1d);
int[] differDemonsId = sArenaRobotConfig.getDifferDemonsId();
int differDemonsLv = sArenaRobotConfig.getDifferDemonsLv();
int robotLevel = sArenaRobotConfig.getRoleLv();
Map<Integer, Integer> robotHeroAttribute = HeroLogic.getInstance().calRobotHeroAttribute(scHero, robotLevel, sArenaRobotConfig.getBreakId(), differDemonsId, differDemonsLv, false);
heroAllAttribute.put(heroTid.toString(), new FamilyHeroInfo(heroTid, robotLevel, heroStar, robotHeroAttribute));
// String property = HeroLogic.getInstance().getRobotHeroProperty(sArenaRobotConfig,scHero,propertySb,robotHeroAttribute).toString();
}
fightInfo.setHeroAttribute(heroAllAttribute);
fightInfo.setForce(force);
fightInfo.setUid(sArenaRobotConfig.getId());
nodeInfo.setBossHP(bossHP);
fightInfo.setPokenmonSkills("");
fightInfo.setPassiveSkills("");
nodeInfo.setSnapFightInfo(fightInfo);
}
private void snapOneFightInfo(User self, ExpeditionNodeInfo nodeInfo, int defid) throws Exception {
int snapTeamId = GlobalsDef.TEAM_ARENA_DEFENSE;
if (!isBattleNode(nodeInfo.getType())) {
return;
}
User user = UserManager.getUser(defid);
SnapFightInfo fightInfo = new SnapFightInfo();
//血量处理buff处理
int force = HeroLogic.getInstance().calTeamTotalForce(user, snapTeamId, false);
Map<String, FamilyHeroInfo> heroAllAttribute = BloodLogic.getInstance().battleRecord(user, snapTeamId, null);
fightInfo.setHeroAttribute(heroAllAttribute);
fightInfo.setForce(force);
fightInfo.setUid(self.getId());
List<TeamPosHeroInfo> teamPosHeroInfoList = user.getTeamPosManager().getTeamPosForHero().get(snapTeamId);
if (teamPosHeroInfoList == null || teamPosHeroInfoList.size() < 1) {
teamPosHeroInfoList = user.getTeamPosManager().getTeamPosForHero().get(1);
}
Map<String, Hero> heroMap = user.getHeroManager().getHeroMap();
Map<String, Double> bossHP = new HashMap<>();
for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfoList) {
String heroId = teamPosHeroInfo.getHeroId();
bossHP.put(heroId, 1d);
Hero hero = heroMap.get(heroId);
StringBuilder skillSb = new StringBuilder();
String heroSkill = HeroLogic.getInstance().getHeroSkills(user, hero, skillSb).toString();
fightInfo.updateHeroSkill(heroId, heroSkill.substring(0, heroSkill.length() - 1));
}
nodeInfo.setBossHP(bossHP);
if (self.getPokemonManager().getPokemonMap().size()!=0) {
//玩家未激活异妖(神器)时,敌人阵容中不会出现异妖;激活异妖后,由敌人数据来源方决定战斗时是否有敌方异妖。
String pokenmonSkills = HeroLogic.getInstance().getPokenmonSkills(user, snapTeamId);
String pokenmonPassiveSkills = HeroLogic.getInstance().getPokenmonPassiveSkills(user, snapTeamId);
List<TeamPosForPokenInfo> teamPosForPokenInfos = user.getTeamPosManager().getTeamPosForPoken().get(snapTeamId);
if (null!=teamPosForPokenInfos) {
List<Integer> pokens = new ArrayList<>();
for (TeamPosForPokenInfo teamPosForPokenInfo : teamPosForPokenInfos) {
pokens.add(teamPosForPokenInfo.getPokenId());
}
fightInfo.setPokenmonIds(pokens);
}
fightInfo.setPokenmonSkills(pokenmonSkills);
fightInfo.setPassiveSkills(pokenmonPassiveSkills);
}
nodeInfo.setSnapFightInfo(fightInfo);
}
/**
*
*/
private void snapOneFightInfo(ExpeditionNodeInfo nodeInfo) throws ErrorCodeException{
SExpeditionNodeConfig sExpeditionNodeConfig = STableManager.getConfig(SExpeditionNodeConfig.class).get(nodeInfo.getType());
int poolId = sExpeditionNodeConfig.getPoolId();
int tempId =ExpeditionLogic.getRandomTid(poolId,1).first();
SExpeditionRecruitConfig sExpeditionRecruitConfig = STableManager.getConfig(SExpeditionRecruitConfig.class).get(tempId);
if(sExpeditionRecruitConfig==null) {
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
//grop config
int i = sExpeditionRecruitConfig.getHeroId();
SnapFightInfo fightInfo = new SnapFightInfo();
fightInfo.setUid(i);
int force = MonsterUtil.getMonsterForce(new int[]{i});
Map<String, Double> bossHP = new HashMap<>();
Map<String, FamilyHeroInfo> heroAllAttribute = new HashMap<>();
SMonsterGroup sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(i);
int[][] groupIds = sMonsterGroup.getContents();
int[] monsterIds = groupIds[0];
for (int monsterId : monsterIds) {
if(monsterId!=0){
bossHP.put(Integer.toString(monsterId), 1d);
heroAllAttribute.put(Integer.toString(monsterId), new FamilyHeroInfo());
}
}
fightInfo.setHeroAttribute(heroAllAttribute);
fightInfo.setForce(force);
nodeInfo.setBossHP(bossHP);
fightInfo.setPokenmonSkills("");
fightInfo.setPassiveSkills("");
nodeInfo.setSnapFightInfo(fightInfo);
}
/**
* type id state
*/
private Set<ExpeditionNodeInfo> createNodeSet(int leve) throws Exception {
int NODESTATE_CLOSE = 0;//0未开启
int NODESTATE_NOT_PASS = 1;//1未通过
int NODESTATE_NOT_GET = 2;//2未领取圣物
int NODESTATE_PASS = 3;//已完成
int NODESTATE_OVER_PASS = 4;//已完成
int NODESTATE_HERO = 5;//招募节点
int NODETYPE_ADVANCE = 1;//精英节点
int NODETYPE_BOSS = 2;//首领节点
int NODETYPE_RELIVE = 3;//复活节点
int NODETYPE_RECOVER = 4;//回复节点
int NODETYPE_NORMAL = 5;//普通节点
int NODETYPE_HERO_GET = 7;//招募节点
int NODETYPE_SHOP = 8;//商店节点
int NODETYPE_TRY = 9;//试炼节点
int NODETYPE_GREED= 10;//贪婪节点
int NODETYPE_REWARD= 11;//奖励节点
Map<Integer, SExpeditionFloorConfig> config = STableManager.getConfig(SExpeditionFloorConfig.class);
int totalIndex = 1;
Set<ExpeditionNodeInfo> nodeSets = new HashSet<>();
Set<Integer> ids = STableManager.getFigureConfig(CommonStaticConfig.class).leve2ids.get(leve);
if(ids==null){
return nodeSets;
}
int orDefault = STableManager.getFigureConfig(CommonStaticConfig.class).leve2num.getOrDefault(leve-1, 0)-1;//节点
Map<Integer,Set<Integer>> map = new HashMap<>();
for (Map.Entry<Integer, Map<Integer,Integer>> integerMapMap :STableManager.getFigureConfig(CommonStaticConfig.class).getType2lay2weight(leve).entrySet()){
int type = integerMapMap.getKey();
int lay = ranndomFromWeight(integerMapMap.getValue());
Set<Integer> value = map.getOrDefault(lay,new HashSet<>());
value.add(type);
map.put(lay,value);
}
for (SExpeditionFloorConfig sExpeditionFloorConfig : config.values()) {
if(!ids.contains(sExpeditionFloorConfig.getId())){
continue;
}
int lay = sExpeditionFloorConfig.getId();
isfirst =false;
if(lay-orDefault-1==ids.size()){
isfirst=true;
}
//必出节点 生成本层id
List<Integer> indexList = MathUtils.combineList(totalIndex, totalIndex + sExpeditionFloorConfig.getNode() - 1);
if (indexList.size() <= 0) {
continue;
}
//生成随机节点
if(map.containsKey(lay)){
for (Integer itemType:map.get(lay)) {
ExpeditionNodeInfo nodeInfo = getNode(sExpeditionFloorConfig, itemType);
nodeInfo.setLay(lay-orDefault);
nodeInfo.setState(NODESTATE_OVER_PASS);
if(!isfirst){
nodeInfo.setState(NODESTATE_PASS);
isfirst=true;
}
if(lay-orDefault-1==ids.size()){
nodeInfo.setState(NODESTATE_NOT_PASS);
}
nodeInfo.setSortId(indexList.remove(0));
nodeSets.add(nodeInfo);
totalIndex++;
if (indexList.size() == 0) {
break;
}
}
}
if (indexList.size() == 0) {
continue;
}
//生成必出节点id state
for (int i = 0; i < sExpeditionFloorConfig.getNodeType().length; i++) {
int[] typeArr = sExpeditionFloorConfig.getNodeType()[i];
if (typeArr.length != 2) {
continue;
}
Set<ExpeditionNodeInfo> tempnode = getNode(sExpeditionFloorConfig, typeArr[0], typeArr[1]);
tempnode.forEach(nodeInfo -> {
nodeInfo.setLay(lay-orDefault);
nodeInfo.setState(NODESTATE_OVER_PASS);
if(!isfirst){
isfirst=true;
nodeInfo.setState(NODESTATE_PASS);
}
if(lay-orDefault-1==ids.size()){
nodeInfo.setState(NODESTATE_NOT_PASS);
}
nodeInfo.setSortId(indexList.remove(0));
});
nodeSets.addAll(tempnode);
totalIndex += tempnode.size();
if (indexList.size() == 0) {
break;
}
}
if (indexList.size() == 0) {
continue;
}
//生成剩余节点
for (Integer anIndexList : indexList) {
//TODO 概率走配置
int type = NODETYPE_NORMAL;
if (Math.random() <= 0.3d) {
type = NODETYPE_ADVANCE;
}
ExpeditionNodeInfo nodeInfo = getNode(sExpeditionFloorConfig, type);
nodeInfo.setLay(lay-orDefault);
nodeInfo.setState(NODESTATE_OVER_PASS);
if(!isfirst){
isfirst=true;
nodeInfo.setState(NODESTATE_PASS);
}
nodeInfo.setSortId(anIndexList);
if(lay-orDefault-1==ids.size()){
nodeInfo.setState(NODESTATE_NOT_PASS);
}
nodeSets.add(nodeInfo);
totalIndex++;
}
}
return nodeSets;
}
private static int ranndomFromWeight(Map<Integer, Integer> weight) {
int amount;
int result = 0;
IntSummaryStatistics collect = weight.values().stream().collect(Collectors.summarizingInt(value -> value));
amount = (int) collect.getSum();
int rate = MathUtils.randomInt(amount);
amount = 0;
for (Map.Entry<Integer, Integer> integerIntegerMap : weight.entrySet()) {
amount += integerIntegerMap.getValue();
if (rate < amount) {
result = integerIntegerMap.getKey();
break;
}
}
return result;
}
private ExpeditionNodeInfo getNode(SExpeditionFloorConfig cfg, int type) throws Exception {
return getNode(cfg, type, 1).iterator().next();
}
private Set<ExpeditionNodeInfo> getNode(SExpeditionFloorConfig cfg, int type, int num) throws Exception {
int NODESTATE_CLOSE = 0;//0未开启
Set<ExpeditionNodeInfo> nodeSets = new HashSet<>();
for (int i = 0; i < num; i++) {
ExpeditionNodeInfo nodeInfo = new ExpeditionNodeInfo();
nodeInfo.setType(type);
nodeInfo.setState(NODESTATE_CLOSE);
nodeSets.add(nodeInfo);
}
return nodeSets;
}
}

View File

@ -0,0 +1,28 @@
package com.ljsd.jieling.kefu;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
/**
* Description: des
* Author: zsx
* CreateDate: 2020/5/28 15:43
* //reload 10043343
*/
public class cmd_reload extends GmRoleAbstract {
@Override
public boolean exec(String[] args) throws Exception {
User user = getUser();
if (null == user) {
return true;
}
int id = user.getId();
UserManager.removeUser(user.getId());
user = MongoUtil.getInstence().getMyMongoTemplate().findById(User.getCollectionName(), id, User.class);
UserManager.addUser(user);
return true;
}
}

View File

@ -13,7 +13,7 @@ public class OnlineUserManager {
sessionMap.put(uid, session);
}
public static Map<Integer, ISession> sessionMap = new DefinaMap<>();
public static Map<Integer, ISession> sessionMap = new ConcurrentHashMap<>();
public static void userOffline(int uid) {

View File

@ -215,12 +215,13 @@ public class ActivityLogic implements IEventHandler{
if (map.containsKey(activityId)) {
return false;
}
ActivityMission activityMission = new ActivityMission();
initMissionInfo(activityMission,activityId);
// activityMission.init(getRootId(), getMongoKey() + ".activityMissionMap." + activityId);
ActivityMission activityMission = new ActivityMission();
//自动初始化
map.put(activityId, activityMission);
initMissionInfo(activityMission,activityId);
// activityMission.init(getRootId(), getMongoKey() + ".activityMissionMap." + activityId);
return true;
}

View File

@ -1,5 +1,6 @@
package com.ljsd.jieling.logic.activity;
import com.ljsd.GameApplication;
import com.ljsd.jieling.jbean.ActivityMission;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.event.HourTaskEvent;
@ -31,13 +32,14 @@ class BuyGoldActivity extends AbstractActivity {
public BuyGoldActivity(int id) {
super(id);
Poster.getPoster().listenEvent(this, UserOnlineEvent.class);
Poster.getPoster().listenEvent(this, HourTaskEvent.class);
}
@Override
public void initActivity(User user) throws Exception {
super.initActivity(user);
SGlobalActivity sGlobalActivity = STableManager.getConfig(SGlobalActivity.class).get(id);
int time = (int) (sGlobalActivity.getEndTimeLong() / 1000);
int time = (int) (GameApplication.serverConfig.getCacheOpenTime()/1000+sGlobalActivity.getEndTimeLong());
HashSet<Integer> ids = new HashSet<>();
List<Integer> listValue = SSpecialConfig.getListValue(SSpecialConfig.Gold_touch);
listValue.forEach(type -> SPrivilegeTypeConfig.privilegeByType.get(type).forEach(sPrivilegeTypeConfig -> {
@ -52,53 +54,53 @@ class BuyGoldActivity extends AbstractActivity {
@Override
public void onEvent(IEvent event) throws Exception {
super.onEvent(event);
List<Integer> list = SSpecialConfig.getListValue(SSpecialConfig.Gold_touch_refresh);
if (event instanceof HourTaskEvent) {
if (list.contains(((HourTaskEvent) event).getHour())) {
InnerMessageUtil.broadcastWithRandom(user -> {
if (user == null) {
return;
}
setUpTime(user);
}, new ArrayList<>(OnlineUserManager.sessionMap.keySet()), 120);
}
}
if (event instanceof UserOnlineEvent) {
User user = UserManager.getUser(((UserOnlineEvent) event).getUid());
ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(id);
if (null == activityMission) {
return;
}
boolean needRefresh = false;
for (Integer aList : list) {
if (TimeUtils.isOverAppointRefreshTime(System.currentTimeMillis(), activityMission.getV() * 1000L, aList)) {
needRefresh = true;
break;
}
}
if (needRefresh) {
setUpTime(user);
}
}
//点金刷新走商店
// List<Integer> list = SSpecialConfig.getListValue(SSpecialConfig.Gold_touch_refresh);
// if (event instanceof HourTaskEvent) {
// if (list.contains(((HourTaskEvent) event).getHour())) {
// InnerMessageUtil.broadcastWithRandom(user -> {
// if (user == null) {
// return;
// }
// setUpTime(user);
// }, new ArrayList<>(OnlineUserManager.sessionMap.keySet()), 1);
//
// }
// }
// if (event instanceof UserOnlineEvent) {
// User user = UserManager.getUser(((UserOnlineEvent) event).getUid());
// ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(id);
// if (null == activityMission) {
// return;
// }
// boolean needRefresh = false;
// for (Integer aList : list) {
// if (TimeUtils.isOverAppointRefreshTime(System.currentTimeMillis(), activityMission.getV() * 1000L, aList)) {
// needRefresh = true;
// break;
// }
// }
// if (needRefresh) {
// setUpTime(user);
// }
// }
}
private void setUpTime(User user) {
ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(id);
if (null == activityMission) {
return;
}
//sendclient
activityMission.setV((int) (System.currentTimeMillis()/1000));
HashSet<Integer> ids = new HashSet<>();
List<Integer> listValue = SSpecialConfig.getListValue(SSpecialConfig.Gold_touch);
listValue.forEach(type -> SPrivilegeTypeConfig.privilegeByType.get(type).forEach(sPrivilegeTypeConfig -> {
ids.add(sPrivilegeTypeConfig.getId());
user.getPlayerInfoManager().refreshVipByType(sPrivilegeTypeConfig.getId());
}));
notifyClient(user, ids);
// ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(id);
// if (null == activityMission) {
// return;
// }
// //sendclient
// activityMission.setV((int) (System.currentTimeMillis()/1000));
// HashSet<Integer> ids = new HashSet<>();
// List<Integer> listValue = SSpecialConfig.getListValue(SSpecialConfig.Gold_touch);
// listValue.forEach(type -> SPrivilegeTypeConfig.privilegeByType.get(type).forEach(sPrivilegeTypeConfig -> {
// ids.add(sPrivilegeTypeConfig.getId());
// user.getPlayerInfoManager().refreshVipByType(type);
// }));
// notifyClient(user, ids);
}

View File

@ -477,22 +477,26 @@ public class ChampionshipLogic {
builder.setJoinState(1);
String key = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_MY_BATTLLE_IDS, Integer.toString(uid));
Object latestKey = RedisUtil.getInstence().lGetIndex(key, -1);
ArenaRecord arenaRecord = RedisUtil.getInstence().getMapValue(RedisKey.CHAMPION_ARENA_RECORD, "", latestKey.toString(), ArenaRecord.class);
int enemyId = arenaRecord.getDefUid();
int attackId = arenaRecord.getAttackId();
int fightResult = arenaRecord.getFightResult();
CommonProto.ChampionBattleInfo.Builder builder1 = CommonProto.ChampionBattleInfo.newBuilder();
if(roundTimes == arenaRecord.getRoundTims() && (progress%10%4 != 3 || fightResult==-2)){
fightResult =-1;
if(latestKey!=null){
ArenaRecord arenaRecord = RedisUtil.getInstence().getMapValue(RedisKey.CHAMPION_ARENA_RECORD, "", latestKey.toString(), ArenaRecord.class);
int enemyId = arenaRecord.getDefUid();
int attackId = arenaRecord.getAttackId();
int fightResult = arenaRecord.getFightResult();
CommonProto.ChampionBattleInfo.Builder builder1 = CommonProto.ChampionBattleInfo.newBuilder();
if(roundTimes == arenaRecord.getRoundTims() && (progress%10%4 != 3 || fightResult==-2)){
fightResult =-1;
}
if(fightResult!=-1){
builder1.setFightData( CommonProto.FightData.parseFrom(arenaRecord.getFightData()));
}
builder.setChampionBattleInfo(builder1
.setMyInfo(getChampionBattleInfo(attackId))
.setEnemyInfo(getChampionBattleInfo(enemyId))
.setResult(fightResult)
.build());
}
if(fightResult!=-1){
builder1.setFightData( CommonProto.FightData.parseFrom(arenaRecord.getFightData()));
}
builder.setChampionBattleInfo(builder1
.setMyInfo(getChampionBattleInfo(attackId))
.setEnemyInfo(getChampionBattleInfo(enemyId))
.setResult(fightResult)
.build());
}
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.CHAMPION_GET_RESPONSE_VALUE,builder.build(),true);

View File

@ -36,6 +36,7 @@ public class ExpeditionManager extends MongoBase {
private Map<String, Hero> heroMap = new HashMap<>();
private Map<String,PropertyItem> equipMap = new HashMap<>();
private Map<String, Hero> heroMapTemp = new HashMap<>();
private Map<Integer,Map<String, Hero>> heroNodeMapTemp = new HashMap<>();
private Map<String,PropertyItem> equipMapTemp = new HashMap<>();
public void putExpeditionNodeInfos(Integer key, ExpeditionNodeInfo nodeInfo) {
@ -174,16 +175,18 @@ public class ExpeditionManager extends MongoBase {
heroMap.put(hero.getId(), hero);
}
public void addHeroToTemp(Hero hero) throws Exception {
public void addHeroToTemp(Hero hero,int nodeID) throws Exception {
//绑定关系
hero.init(this.getRootId(),getMongoKey() + ".heroMapTemp." + hero.getId());
updateString("heroMapTemp." + hero.getId(), hero);
heroMapTemp.put(hero.getId(), hero);
hero.init(this.getRootId(),getMongoKey() + ".heroNodeMapTemp."+nodeID+"."+ hero.getId());
Map<String, Hero> orDefault = heroNodeMapTemp.getOrDefault(nodeID, new HashMap<>());
updateString("heroNodeMapTemp." + nodeID, orDefault);
orDefault.put(hero.getId(), hero);
heroNodeMapTemp.put(nodeID,orDefault);
}
public void clearHeroToTemp() throws Exception {
heroMapTemp.clear();
updateString("heroMapTemp" , heroMapTemp);
heroNodeMapTemp.clear();
updateString("heroNodeMapTemp" , heroNodeMapTemp);
}
@ -229,8 +232,8 @@ public class ExpeditionManager extends MongoBase {
updateString("freshTime" , freshTime);
}
public Map<String, Hero> getHeroMapTemp() {
return heroMapTemp;
public Map<String, Hero> getHeroMapTemp(int sortid) {
return heroNodeMapTemp.getOrDefault(sortid,new HashMap<>());
}
public Map<String, PropertyItem> getEquipMapTemp() {

View File

@ -60,6 +60,7 @@ public class Hero extends MongoBase {
this.templateId = heroTid;
this.level = initStar;
this.star =hero.getStar() ;
this.equipByPositionMap = new HashMap<>();
this.soulEquipByPositionMap = hero.soulEquipByPositionMap;
this.breakId = hero.breakId;
this.starBreakId = hero.starBreakId;

View File

@ -527,7 +527,7 @@ public class PlayerManager extends MongoBase {
}
public void setChannel(String channel) {
updateString("channel", this.channel);
updateString("channel", channel);
this.channel = channel;
}

View File

@ -27,6 +27,23 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* TODO zsx
* Q
* 1
* 2
* 3 type
* 4 eventtaskType
* 使if else
*
* F
* 1 task
* 2
* 3
* 4 id id
*
*
* */
public class UserMissionManager extends MongoBase {
private VipMissionIdsType vipMissionIdsType=new VipMissionIdsType();
private DailyMissionIdsType dailyMissionIdsType=new DailyMissionIdsType();
@ -49,6 +66,7 @@ public class UserMissionManager extends MongoBase {
private CumulationData sevenHappyCumulationData = new CumulationData();
private CumulationData achievementMap = new CumulationData();
//触发任务上身
public void openMission(User user,GameEvent event,Map<GameMisionType, List<MissionStateChangeInfo>> missionTypeEnumListMap, Object... parm) throws Exception {
ISession session= OnlineUserManager.getSessionByUid(user.getId());
switch (event){

View File

@ -10,7 +10,7 @@ import java.util.Map;
public class WorldTreasureReward extends MongoBase {
private int createTime; //取当天零点 根据其可以推算出期数。
private int round;
private int round=1;
private int score;
private Map<Integer,Integer> rewardStatusMap = new HashMap<>(); //领取状态 1表示领取基础奖励 2表示领取额外奖励。
@ -24,7 +24,7 @@ public class WorldTreasureReward extends MongoBase {
}
score = 0;
rewardStatusMap = new HashMap<>();
this.round = round;
}
@Override
@ -37,6 +37,10 @@ public class WorldTreasureReward extends MongoBase {
}
public int getRound() {
if(round == 0){
this.round = 1;
updateString("round", round);
}
return round;
}

View File

@ -82,7 +82,8 @@ public class ExpeditionLogic {
ExpeditionManager manager = user.getExpeditionManager();
TimeControllerOfFunction openTimeOfFuntionCacheByType = GlobalDataManaager.getInstance().getOpenTimeOfFuntionCacheByType(FunctionIdEnum.Expedition);
if(manager.getCurrentTime()==openTimeOfFuntionCacheByType.getTimes()){
if(openTimeOfFuntionCacheByType==null||manager.getCurrentTime()==openTimeOfFuntionCacheByType.getTimes()){
return;
}
takeAllReward(user);
@ -291,11 +292,11 @@ public class ExpeditionLogic {
if(isBattleNode(nodeInfo.getType())){
//生成节点boss信息
float size = STableManager.getFigureConfig(CommonStaticConfig.class).leve2num.get(1);
float size = STableManager.getFigureConfig(CommonStaticConfig.class).leve2num.get(leve);
//战力基准值=maxforce*0.8+1/15(max-min)*lay
int minFoce = sExpeditionSetting.getMatchForce()[leve][0];
int manFoce = sExpeditionSetting.getMatchForce()[leve][1];
int minFoce = sExpeditionSetting.getMatchForce()[leve-1][0];
int manFoce = sExpeditionSetting.getMatchForce()[leve-1][1];
int standerFoce = (int) (user.getPlayerInfoManager().getMaxForce() * ((minFoce / 10000f) + ((float) nodeInfo.getLay()) / size * ((float) (manFoce - minFoce)/10000f)));
float randomForce = (standerFoce * ((sExpeditionSetting.getMatchForceRange()[0] + (int) (Math.random() * (sExpeditionSetting.getMatchForceRange()[1] - sExpeditionSetting.getMatchForceRange()[0]))) / 10000f));
@ -812,7 +813,14 @@ public class ExpeditionLogic {
}
public static Hero createHero(int tempid,int uid,Hero hero,boolean isTemp)throws Exception{
/**
*
* @param nodeId -1
* @return
* @throws Exception
*/
public static Hero createHero(int tempid,int uid,Hero hero,int nodeId)throws Exception{
boolean isTemp = nodeId != -1;
int star = hero.getLevel();
User user = UserManager.getUser(uid);
SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1);
@ -863,7 +871,7 @@ public class ExpeditionLogic {
newHero.addJewel(newequip.getId());
}
if(isTemp){
user.getExpeditionManager().addHeroToTemp(newHero);
user.getExpeditionManager().addHeroToTemp(newHero,nodeId);
}else {
user.getExpeditionManager().addHero(newHero);
}
@ -989,14 +997,14 @@ public class ExpeditionLogic {
Expedition.ExpeditionTreasureInfoResponse.Builder response = Expedition.ExpeditionTreasureInfoResponse.newBuilder();
Map<Integer, Integer> rewardStatusMap = worldTreasureReward.getRewardStatusMap();
if(!rewardStatusMap.isEmpty()){
List<Expedition.TreasureRewardState> states = new ArrayList<>(100);
for(Map.Entry<Integer, Integer> entry:rewardStatusMap.entrySet()){
Expedition.TreasureRewardState.Builder builder = Expedition.TreasureRewardState.newBuilder().setId(entry.getKey()).setState(entry.getValue());
states.add(builder.build());
}
response.addAllTreasureRewardState(states);
}
WorldBossTreasureStaticConfig worldBossTreasureStaticConfig = STableManager.getFigureConfig(WorldBossTreasureStaticConfig.class);
Set<SWorldBossTreasureConfig> sWorldBossTreasureConfigs = worldBossTreasureStaticConfig.getIdsByPeriods().get(worldTreasureReward.getRound());
List<Expedition.TreasureRewardState> states = new ArrayList<>(100);
sWorldBossTreasureConfigs.forEach(item->{
Expedition.TreasureRewardState.Builder builder = Expedition.TreasureRewardState.newBuilder().setId(item.getId()).setState(rewardStatusMap.getOrDefault(item.getId(),0));
states.add(builder.build());
});
response.addAllTreasureRewardState(states);
response.setScore(worldTreasureReward.getScore());
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
}

View File

@ -384,6 +384,10 @@ public class DeathPathLogic {
User user = UserManager.getUser(session.getUid());
DeathChallengeCount countInfo = RedisUtil.getInstence().get(RedisKey.DEATH_PAHT_TOTAL_CHALLENGE_COUNT, String.valueOf(user.getPlayerInfoManager().getGuildId()), DeathChallengeCount.class);
Family.GetAllDeathPathRewardInfoResponse.Builder response = Family.GetAllDeathPathRewardInfoResponse.newBuilder();
if(countInfo==null){
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
return;
}
Map<Integer, DeathReward> userReward = countInfo.getUserReward();
if(userReward!=null){
for(Map.Entry<Integer, DeathReward> entry:userReward.entrySet()){

View File

@ -267,18 +267,20 @@ public class HeroLogic{
}
int j=0;
//标记是否触发保底
boolean specialTrigger=false;
for(int i=0;i<perCount;i++){
randCount++;
poolCount++;
int randomPoolId = pooId;
int specialPoolId = getSpecialPoolByRandcount(sLotterySetting, randCount,poolCount);
if(specialPoolId == 0){
if(randomPoolId==0){
randomPoolId = getPooId(sLotterySetting);
}
}else{
randomPoolId =specialPoolId;
if(!specialTrigger){
randomPoolId = getSpecialPoolByRandcount(sLotterySetting, randCount,poolCount);
specialTrigger=true;
}
if(randomPoolId==0){
randomPoolId = getPooId(sLotterySetting);
}
totalCount++;
SLotteryRewardConfig sLotteryRewardConfig = randomHeroByPoolId(randomPoolId, totalCount, user.getPlayerInfoManager().getLevel());
LOGGER.info("the uid={},the type={},the poolId={},reward={},poolCount={}",uid,type,randomPoolId,sLotteryRewardConfig.getId(),poolCount);
@ -1606,9 +1608,9 @@ public class HeroLogic{
float score = sPropertyConfig.getScore();
result += propertyValue*score;
LOGGER.info("the propertyId={} the value is ={},propertyValue={},score={}result ={},the value={}",propertyId,propertyValue*score,propertyValue,score,result,propertyValue*score);
// LOGGER.info("the propertyId={} the value is ={},propertyValue={},score={}result ={},the value={}",propertyId,propertyValue*score,propertyValue,score,result,propertyValue*score);
}
System.out.println(result);
// System.out.println(result);
return (int)result;
}

View File

@ -321,11 +321,14 @@ public class ItemLogic {
}
SItem sItem = SItem.getsItemMap().get(hero.getTemplateId());
if (reward.length() == 0) {
reward = new StringBuilder(sItem.getResolveReward());
} else {
reward.append("#").append(sItem.getResolveReward());
if(null==filterItem){
if (reward.length() == 0) {
reward = new StringBuilder(sItem.getResolveReward());
} else {
reward.append("#").append(sItem.getResolveReward());
}
}
}
ItemUtil.combineReward(user,false, StringUtil.parseFiledInt(reward.toString()),1,baseItemMap,baseCardMap,baseEquipMap,baseRandomMap,-1);

View File

@ -448,6 +448,12 @@ public class MissionLoigc {
}
}
/**
* TODO ifelse
*
* ifelse 1001
*/
public static int getDoingProgress(User user,CumulationData cumulationData, int missionTypeId, int[] missionSubType){
MissionType missionType = MissionType.findByMissionId(missionTypeId);
if(missionType == null){

View File

@ -1,5 +1,8 @@
package com.ljsd.jieling.logic.mission;
import java.util.HashMap;
import java.util.Map;
public enum MissionType {
RECRUITMENT_RANDOM_HEROES(1), //群英征募 群英招募次数
COLLECT_QUALITY_HERO (2), //获得某品质妖灵师 获得SSR、SR品质的妖灵师数量
@ -92,7 +95,11 @@ public enum MissionType {
FINISH_EXPEDITION_HERO_TIMES(84),//完成猎妖之路次数达到
SEVEN_GIFT_BUY(86),//购买7日狂欢福利礼包%s次七日狂欢积分
FINISIN_DAILY_CHALLENGE_TIMES(87),//完成%s类型0为不限类型的日常副本%s次
SIX_RANDOM_TIMES(88),//使用6灵阁召唤num次
EXPEDITION_FLOOR_TIMES(89),//猎妖之路通过第floor层的首领节点每层最多一个num次
DECOMPOSE_TIMES(100),//献祭武将num个
DEATH_PATH_TIMES(101),//击杀过关十绝阵num次
JEWL_ALL_LEVE(102),//全体上阵成员法宝等级达到level需求人数6人不满上阵不计完成度
;
private int missionType;
@ -105,163 +112,176 @@ public enum MissionType {
this.missionType = missionType;
}
public static MissionType findByMissionId(int missionTypeId){
switch (missionTypeId){
case 1:
return RECRUITMENT_RANDOM_HEROES;
case 2:
return COLLECT_QUALITY_HERO;
case 3:
return HERO_LEVLE_COUNT;
case 4:
return POKEMON_ADVANCED;
case 5:
return POKEMON_FORCE;
case 6:
return POKEMON_ALL_FORCE;
case 7:
return ARENA_CHALLENEGE_NUMS;
case 8:
return ARENA_SCORE;
case 9:
return USER_LEVEL;
case 10:
return USER_FORCE;
case 11:
return USER_CONSUMER_GEM;
case 12:
return USER_WORKSHOP_LEVEL;
case 13:
return USER_GET_EQUIP_QUALITY;
case 14:
return LEVEL_STORY_PASS;
case 15:
return GENERAL_STORY_PASS;
case 16:
return HERO_STORY_PASS;
case 17:
return KILL_INVASIONBOSS;
case 18:
return SECRETBOX_TIMES;
case 19:
return EQUIP_FORCE_NUMS;
case 20:
return BUY_GOLD_TIMES;
case 21:
return BUY_STAMINA_TIMES;
case 22:
return WORKSHOP_CREATE_EQUIP_NUMS;
case 23:
return GENERAL_STORY_TIMES;
case 24:
return HERO_STORY_TIMES;
case 25:
return LEVEL_STORY_TIMES;
case 26:
return HERO_LEVLE_TIMES;
case 27:
return TAKE_ADVENTUREREWARD_TIMES;
case 28:
return ARENA_FIGHTSUCCES_TIMES;
case 29:
return FINSIH_DAYILY_TIMES;
case 30:
return RING_FIREA_DVANCED;
case 31:
return COPY_STORY_LEVLE;
case 32:
return COPY_STORY_TIMES;
case 33:
return ELEMENT_RANDOM_TIMES;
case 34:
return HERO_STORY_PLAY_TIMES;
case 35:
return INVASIONBOSS_PLAY_TIMES;
case 36:
return FAST_ADVENTUREREWARD_TIMES;
case 37:
return ARENA_RANK;
case 38:
return SENVER_HAPPY;
case 39:
return HERO_BREAK_TIMES;
case 40:
return TAKE_CHAPTER_REWARD_TIMES;
case 41:
return HERO_UP_STAR_TIMES;
case 42:
return VIP_LEVEL;
case 43:
return TAKE_ONLINE_REWARD_TIMES;
case 44:
return TAKE_SENVEN_LOGIN_REWARD_TIMES;
case 45:
return TAKE_DAILY_BOX_TIMES;
case 46:
return HERO_WEAR_EQUIP_TIMES;
case 47:
return SYNTHESIS_HERO_STAR_TIMES;
case 48:
return USER_CONSUMER_STAMINA;
case 49:
return COLLECT_DIFFERENT_HEROS;
case 50:
return ONE_HERO_UP_STAR_TIMES;
case 51:
return HERO_IN_TEAM_NUMS;
case 52:
return BUY_GROCERY_TIMES;
case 53:
return FRIEND_NUMS;
case 54:
return GIVE_FRIEND_STAMIN_TIMES;
case 55:
return HERO_UP_SOME_STAR_TIMES;
case 56:
return JOIN_MONSTER_ATTACK_TIMES;//参与兽潮来袭的次数
case 57:
return MONSTER_ATTACK_LEVEL;//兽潮来袭到达x层
case 58:
return TO_BE_STRONGER;
case 59:
return BLOODY_KILL_NUMS;
case 60:
return ENDLESS_CONSUME_ACTION;
case 61:
return FAMILY_FIGHT_ATTACK;
case 62:
return ESPECIAL_EQUIP;
case 65:
return FIND_STAR;
case 66:
return TAKE_FRIEND_GIFT;
case 69:
return JOIN_FAMILY;
case 71:
return FRIEND_APPLY;
case 72:
return COMHERO_STORY_PASS;
case 73:
return LOGIN_TIMES;
case 74:
return REARGE_TOTAL;
case 76:
return FINISH_MISSING_ROOM;
case 77:
return REFRESH_MISSING_ROOM;
case 78:
return SPECIAL_EQUIP_LEVEL_UP;
case 83:
return LUCKY_WHEELS_TIMES;
case 84:
return FINISH_EXPEDITION_HERO_TIMES;
case 86:
return SEVEN_GIFT_BUY;
case 87:
return FINISIN_DAILY_CHALLENGE_TIMES;
default:
return null;
}
static Map<Integer,MissionType> map = new HashMap<>();
static {
for (MissionType type:MissionType.values()) {
map.put(type.getMissionTypeValue(),type);
}
}
public static MissionType findByMissionId(int missionTypeId){
return map.get(missionTypeId);
}
//fix 扩展麻烦
// public static MissionType findByMissionId(int missionTypeId){
// switch (missionTypeId){
// case 1:
// return RECRUITMENT_RANDOM_HEROES;
// case 2:
// return COLLECT_QUALITY_HERO;
// case 3:
// return HERO_LEVLE_COUNT;
// case 4:
// return POKEMON_ADVANCED;
// case 5:
// return POKEMON_FORCE;
// case 6:
// return POKEMON_ALL_FORCE;
// case 7:
// return ARENA_CHALLENEGE_NUMS;
// case 8:
// return ARENA_SCORE;
// case 9:
// return USER_LEVEL;
// case 10:
// return USER_FORCE;
// case 11:
// return USER_CONSUMER_GEM;
// case 12:
// return USER_WORKSHOP_LEVEL;
// case 13:
// return USER_GET_EQUIP_QUALITY;
// case 14:
// return LEVEL_STORY_PASS;
// case 15:
// return GENERAL_STORY_PASS;
// case 16:
// return HERO_STORY_PASS;
// case 17:
// return KILL_INVASIONBOSS;
// case 18:
// return SECRETBOX_TIMES;
// case 19:
// return EQUIP_FORCE_NUMS;
// case 20:
// return BUY_GOLD_TIMES;
// case 21:
// return BUY_STAMINA_TIMES;
// case 22:
// return WORKSHOP_CREATE_EQUIP_NUMS;
// case 23:
// return GENERAL_STORY_TIMES;
// case 24:
// return HERO_STORY_TIMES;
// case 25:
// return LEVEL_STORY_TIMES;
// case 26:
// return HERO_LEVLE_TIMES;
// case 27:
// return TAKE_ADVENTUREREWARD_TIMES;
// case 28:
// return ARENA_FIGHTSUCCES_TIMES;
// case 29:
// return FINSIH_DAYILY_TIMES;
// case 30:
// return RING_FIREA_DVANCED;
// case 31:
// return COPY_STORY_LEVLE;
// case 32:
// return COPY_STORY_TIMES;
// case 33:
// return ELEMENT_RANDOM_TIMES;
// case 34:
// return HERO_STORY_PLAY_TIMES;
// case 35:
// return INVASIONBOSS_PLAY_TIMES;
// case 36:
// return FAST_ADVENTUREREWARD_TIMES;
// case 37:
// return ARENA_RANK;
// case 38:
// return SENVER_HAPPY;
// case 39:
// return HERO_BREAK_TIMES;
// case 40:
// return TAKE_CHAPTER_REWARD_TIMES;
// case 41:
// return HERO_UP_STAR_TIMES;
// case 42:
// return VIP_LEVEL;
// case 43:
// return TAKE_ONLINE_REWARD_TIMES;
// case 44:
// return TAKE_SENVEN_LOGIN_REWARD_TIMES;
// case 45:
// return TAKE_DAILY_BOX_TIMES;
// case 46:
// return HERO_WEAR_EQUIP_TIMES;
// case 47:
// return SYNTHESIS_HERO_STAR_TIMES;
// case 48:
// return USER_CONSUMER_STAMINA;
// case 49:
// return COLLECT_DIFFERENT_HEROS;
// case 50:
// return ONE_HERO_UP_STAR_TIMES;
// case 51:
// return HERO_IN_TEAM_NUMS;
// case 52:
// return BUY_GROCERY_TIMES;
// case 53:
// return FRIEND_NUMS;
// case 54:
// return GIVE_FRIEND_STAMIN_TIMES;
// case 55:
// return HERO_UP_SOME_STAR_TIMES;
// case 56:
// return JOIN_MONSTER_ATTACK_TIMES;//参与兽潮来袭的次数
// case 57:
// return MONSTER_ATTACK_LEVEL;//兽潮来袭到达x层
// case 58:
// return TO_BE_STRONGER;
// case 59:
// return BLOODY_KILL_NUMS;
// case 60:
// return ENDLESS_CONSUME_ACTION;
// case 61:
// return FAMILY_FIGHT_ATTACK;
// case 62:
// return ESPECIAL_EQUIP;
// case 65:
// return FIND_STAR;
// case 66:
// return TAKE_FRIEND_GIFT;
// case 69:
// return JOIN_FAMILY;
// case 71:
// return FRIEND_APPLY;
// case 72:
// return COMHERO_STORY_PASS;
// case 73:
// return LOGIN_TIMES;
// case 74:
// return REARGE_TOTAL;
// case 76:
// return FINISH_MISSING_ROOM;
// case 77:
// return REFRESH_MISSING_ROOM;
// case 78:
// return SPECIAL_EQUIP_LEVEL_UP;
// case 83:
// return LUCKY_WHEELS_TIMES;
// case 84:
// return FINISH_EXPEDITION_HERO_TIMES;
// case 86:
// return SEVEN_GIFT_BUY;
// case 87:
// return FINISIN_DAILY_CHALLENGE_TIMES;
// default:
// return null;
// }
//
// }
}

View File

@ -49,7 +49,7 @@ public class BuyGoodsLogic {
public static void flushEveryDay(User user) throws Exception {
//更新5星成长礼
user.getPlayerInfoManager().getRechargeInfo().getBuyGoodsTimes().put(21,0);
user.getPlayerInfoManager().getRechargeInfo().updateBuyGoodsTimes(21,0);
List<CommonProto.GiftGoodsInfo> goodsBagInfo = new ArrayList<>(SRechargeCommodityConfig.rechargeCommodityConfigMap.size());
BuyGoodsLogic.getGoodsBagInfo(user.getId(), goodsBagInfo,false);
ISession session = OnlineUserManager.getSessionByUid(user.getId());

View File

@ -130,26 +130,37 @@ public class StoreLogic implements IEventHandler {
}
}
if(sStoreTypeConfig.getRefreshType()[0]==2&& calendar.get(Calendar.MINUTE) ==0 && sStoreTypeConfig.getRefreshType()[1]==calendar.get(Calendar.HOUR_OF_DAY)){
for(ISession session : OnlineUserManager.sessionMap.values()){
if(session.getFiveReady() == 1){
User user = UserManager.getUser(session.getUid());
if(user.getStoreManager().getStoreInfoMap().containsKey(sStoreTypeConfig.getId())){
updateUsersStoreAyync(UserManager.getUser(session.getUid()),user1 -> {
StoreInfo storeInfo = user.getStoreManager().getStoreInfoMap().get(sStoreTypeConfig.getId());
if(sStoreTypeConfig.getRefreshType()[0]==2&& calendar.get(Calendar.MINUTE) ==0){
Map<Integer, Integer> storeItem = getStoreItem(sStoreTypeConfig.getId(), sStoreTypeConfig, user);
if(storeItem == null){
LOGGER.error("the uid={},the storeID={} is null",user.getId(),sStoreTypeConfig.getId());
return;
}
storeInfo.setItemNumMap(storeItem);
storeInfo.setLastRefreshTime(now);
MongoUtil.getInstence().lastUpdate();
sendStoreUpdateIndication(user.getId(),storeInfo);
});
}
for(int i = 1;i<sStoreTypeConfig.getRefreshType().length;i++){
if(sStoreTypeConfig.getRefreshType()[i]!=calendar.get(Calendar.HOUR_OF_DAY)){
continue;
}
sendRefreshIndication(sStoreTypeConfig,now);
break ;
}
}
}
}
private static void sendRefreshIndication(SStoreTypeConfig sStoreTypeConfig,long lastRefreshTime) throws Exception {
for(ISession session : OnlineUserManager.sessionMap.values()){
if(session.getFiveReady() == 1){
User user = UserManager.getUser(session.getUid());
if(user.getStoreManager().getStoreInfoMap().containsKey(sStoreTypeConfig.getId())){
updateUsersStoreAyync(UserManager.getUser(session.getUid()),user1 -> {
StoreInfo storeInfo = user.getStoreManager().getStoreInfoMap().get(sStoreTypeConfig.getId());
Map<Integer, Integer> storeItem = getStoreItem(sStoreTypeConfig.getId(), sStoreTypeConfig, user);
if(storeItem == null){
LOGGER.error("the uid={},the storeID={} is null",user.getId(),sStoreTypeConfig.getId());
return;
}
storeInfo.setItemNumMap(storeItem);
storeInfo.setLastRefreshTime(lastRefreshTime);
MongoUtil.getInstence().lastUpdate();
sendStoreUpdateIndication(user.getId(),storeInfo);
});
}
}
}
@ -219,11 +230,13 @@ public class StoreLogic implements IEventHandler {
}
}
if(sStoreTypeConfig.getRefreshType()[0] == 2){
if (TimeUtils.isOverAppointRefreshTime(nowTime,storeInfo.getLastRefreshTime(),sStoreTypeConfig.getRefreshType()[1])){
Map<Integer, Integer> storeItem = getStoreItem(sStoreTypeConfig.getId(), sStoreTypeConfig, user);
storeInfo.setLastRefreshTime(nowTime);
storeInfo.setItemNumMap(storeItem);
sendStoreUpdateIndication(user.getId(),storeInfo);
for(int i = 0 ; i<sStoreTypeConfig.getRefreshType().length;i++){
if (TimeUtils.isOverAppointRefreshTime(nowTime,storeInfo.getLastRefreshTime(),sStoreTypeConfig.getRefreshType()[i])){
Map<Integer, Integer> storeItem = getStoreItem(sStoreTypeConfig.getId(), sStoreTypeConfig, user);
storeInfo.setLastRefreshTime(nowTime);
storeInfo.setItemNumMap(storeItem);
sendStoreUpdateIndication(user.getId(),storeInfo);
}
}
}
@ -632,12 +645,14 @@ public class StoreLogic implements IEventHandler {
long nowTime = System.currentTimeMillis();
switch (type){
case 2:
boolean overTime = TimeUtils.isOverTime(time, storeInfo.getLastRefreshTime());
if (overTime){
itemNumMap = getStoreItem(sStoreTypeConfig.getId(),sStoreTypeConfig,user);
storeInfo.setLastRefreshTime(nowTime);
for(int i=1;i<sStoreTypeConfig.getRefreshType().length;i++){
boolean overTime = TimeUtils.isOverTime(i, storeInfo.getLastRefreshTime());
if (overTime){
itemNumMap = getStoreItem(sStoreTypeConfig.getId(),sStoreTypeConfig,user);
storeInfo.setLastRefreshTime(nowTime);
}
break;
}
break;
case 3:
long lastRefreshTime = storeInfo.getLastRefreshTime();
int intervalTime = time*1000*60*60;

View File

@ -1,5 +1,9 @@
package com.ljsd.jieling.thread.task;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ljsd.GameApplication;
import com.ljsd.fight.CheckFight;
import com.ljsd.jieling.config.reportData.DataMessageUtils;
@ -12,6 +16,7 @@ import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.hotfix.HotfixUtil;
import com.ljsd.jieling.kefu.GmRoleAbstract;
import com.ljsd.jieling.ktbeans.BeanBuilder.KtBeanBuilderUtils;
import com.ljsd.jieling.ktbeans.KTRequestBeans.LoginParamType;
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
@ -38,13 +43,21 @@ import com.ljsd.jieling.logic.question.QuestionLogic;
import com.ljsd.jieling.logic.store.BuyGoodsLogic;
import com.ljsd.jieling.logic.store.StoreLogic;
import com.ljsd.jieling.network.server.ProtocolsManager;
import com.ljsd.jieling.network.server.SessionManager;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.Family;
import com.ljsd.jieling.util.InnerMessageUtil;
import com.ljsd.jieling.util.MessageUtil;
import com.ljsd.jieling.util.SysUtil;
import manager.STableManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.annotation.Transient;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.*;
public class MinuteTask extends Thread {
@ -119,6 +132,11 @@ public class MinuteTask extends Thread {
if(minute ==0){
LOGGER.info("everyHourTask start ...");
Poster.getPoster().dispatchEvent(new HourTaskEvent(hour));
try {
MongoUtil.checkDb();
}catch (Exception e){
LOGGER.error("定期检查数据库对象数据一致性err"+e);
}
LOGGER.info("everyHourTask end ...");
}
}