generated from root/miduo_server
优化服务器战斗
parent
b2493176ce
commit
7c7d5ab773
|
|
@ -2107,7 +2107,7 @@ public class MapLogic {
|
|||
}
|
||||
|
||||
public static void addFightLog(int uid, FightLog fightLog) throws Exception {
|
||||
MongoUtil.getInstence().getMyMongoTemplate().save(uid,fightLog);
|
||||
// MongoUtil.getInstence().getMyMongoTemplate().save(uid,fightLog);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.ljsd.jieling.handler.BaseHandler;
|
|||
import com.ljsd.jieling.logic.dao.ArenaRecord;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.FightUtil;
|
||||
import com.ljsd.jieling.logic.virtualBattle.VirtualBattleLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
|
|
@ -38,9 +39,12 @@ public class FightVirtualBattleFightRePlayRequestHandler extends BaseHandler< Fi
|
|||
String selfKey = VirtualBattleLogic.getInstance().getSelfKeyForRePlay(uid,fightId);
|
||||
|
||||
|
||||
ArenaRecord power = RedisUtil.getInstence().get(RedisKey.VirtualBattle_POWER_TOP_RECORD, gameLevelId, ArenaRecord.class);
|
||||
ArenaRecord fast = RedisUtil.getInstence().get(RedisKey.VirtualBattle_FAST_RECORD, gameLevelId, ArenaRecord.class);
|
||||
ArenaRecord self = RedisUtil.getInstence().get(RedisKey.VirtualBattle_SELF_RECORD, selfKey, ArenaRecord.class);
|
||||
// ArenaRecord power = RedisUtil.getInstence().get(RedisKey.VirtualBattle_POWER_TOP_RECORD, gameLevelId, ArenaRecord.class);
|
||||
// ArenaRecord fast = RedisUtil.getInstence().get(RedisKey.VirtualBattle_FAST_RECORD, gameLevelId, ArenaRecord.class);
|
||||
// ArenaRecord self = RedisUtil.getInstence().get(RedisKey.VirtualBattle_SELF_RECORD, selfKey, ArenaRecord.class);
|
||||
ArenaRecord power = FightUtil.getBattleRecord(RedisKey.VirtualBattle_POWER_TOP_RECORD,gameLevelId);
|
||||
ArenaRecord fast = FightUtil.getBattleRecord(RedisKey.VirtualBattle_FAST_RECORD,gameLevelId);
|
||||
ArenaRecord self = FightUtil.getBattleRecord(RedisKey.VirtualBattle_SELF_RECORD,selfKey);
|
||||
FightInfoProto.VirtualBattleFightRePlayResponse.Builder fightRePlayResponse = FightInfoProto.VirtualBattleFightRePlayResponse.newBuilder();
|
||||
List<ArenaRecord> list = new ArrayList<>();
|
||||
list.add(power);
|
||||
|
|
|
|||
|
|
@ -31,28 +31,28 @@ public class ReportUtil extends Thread {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
while (GameApplication.start) {
|
||||
ReportUserEvent ReportUserEvent = reportUserEventQueue.poll();
|
||||
if (ReportUserEvent == null) {
|
||||
try {
|
||||
Thread.sleep(10);
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
}
|
||||
}else{
|
||||
try {
|
||||
doReport(ReportUserEvent);
|
||||
} catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// while (GameApplication.start) {
|
||||
// ReportUserEvent ReportUserEvent = reportUserEventQueue.poll();
|
||||
// if (ReportUserEvent == null) {
|
||||
// try {
|
||||
// Thread.sleep(10);
|
||||
// } catch (InterruptedException e) {
|
||||
//
|
||||
// }
|
||||
// }else{
|
||||
// try {
|
||||
// doReport(ReportUserEvent);
|
||||
// } catch (Exception e){
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
//对外接口只有一个
|
||||
public static void onReportEvent(User user, int type, Object... param) throws Exception {
|
||||
if(!GameApplication.openTdAnalytics) {
|
||||
/*if(!GameApplication.openTdAnalytics) {
|
||||
return;
|
||||
}
|
||||
ReportUserEvent reportUserEvent = userToReportBean(user);
|
||||
|
|
@ -69,7 +69,7 @@ public class ReportUtil extends Thread {
|
|||
reportUserEvent.setEventInfo(eventProperties);
|
||||
//设置事件名称
|
||||
reportUserEvent.setEventName(report.getEventName());
|
||||
report(reportUserEvent);
|
||||
report(reportUserEvent);*/
|
||||
}
|
||||
|
||||
private static ReportUserEvent userToReportBean(User user) {
|
||||
|
|
|
|||
|
|
@ -370,4 +370,19 @@ public class UserManager {
|
|||
return userMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 只在内存中获取数据,不放内存里
|
||||
* @param uid
|
||||
* @param canNull
|
||||
* @return
|
||||
*/
|
||||
public static User getUserOnlyInMap(int uid, boolean canNull) {
|
||||
User user = userMap.get(uid);
|
||||
if (user != null) {
|
||||
initHeroMedal(user);
|
||||
return user;
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,7 @@ import com.ljsd.jieling.exception.ErrorCodeException;
|
|||
import com.ljsd.jieling.handler.map.TrailHero;
|
||||
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
||||
import com.ljsd.jieling.logic.blood.BloodLogic;
|
||||
import com.ljsd.jieling.logic.dao.Hero;
|
||||
import com.ljsd.jieling.logic.dao.MotherShipPlan;
|
||||
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.gm.ArenaOfHero;
|
||||
import com.ljsd.jieling.logic.dao.gm.ArenaOfUser;
|
||||
import com.ljsd.jieling.logic.dao.root.FightResDiffLog;
|
||||
|
|
@ -40,6 +37,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class FightUtil {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(FightUtil.class);
|
||||
|
|
@ -50,6 +48,7 @@ public class FightUtil {
|
|||
public static final int STAR_HERO_SUR_CON = 5;
|
||||
public static final int STAR_FIGHT_FORMATION = 6;
|
||||
public static final int STAR_FIGHT_VICTORY = 7;
|
||||
public static Map<String, Map<String,ArenaRecord>> battleRecords = new ConcurrentHashMap<String,Map<String,ArenaRecord>>();
|
||||
|
||||
public static CommonProto.FightTeamInfo makePersonFightData(User player, int teamId, Map<String, Double> attackBloodMap, List<Integer> buffIds) {
|
||||
if (buffIds != null) {
|
||||
|
|
@ -1162,4 +1161,40 @@ public class FightUtil {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加内存战报记录,服务器重启后清空
|
||||
* @param type
|
||||
* @param key
|
||||
* @param record
|
||||
*/
|
||||
public static void addBattleRecord(String type,String key,ArenaRecord record) {
|
||||
if(FightUtil.battleRecords.containsKey(type)){
|
||||
Map<String,ArenaRecord> records = FightUtil.battleRecords.get(type);
|
||||
records.put(key, record);
|
||||
}else{
|
||||
Map<String,ArenaRecord> records = new HashMap<String,ArenaRecord>();
|
||||
records.put(key, record);
|
||||
FightUtil.battleRecords.put(type, records);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取内存战报记录
|
||||
* @param type
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static ArenaRecord getBattleRecord(String type,String key) {
|
||||
if(!FightUtil.battleRecords.containsKey(type)){
|
||||
return null;
|
||||
}
|
||||
Map<String,ArenaRecord> records = FightUtil.battleRecords.get(type);
|
||||
if(!records.containsKey(key)){
|
||||
return null;
|
||||
}
|
||||
return records.get(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ public class FriendLogic {
|
|||
if (!checkIsAllowRecommandFriend(friendManager, recommandId, recommondIds)) {
|
||||
continue;
|
||||
}
|
||||
User recommandIdUser = UserManager.getUserInMem(recommandId);
|
||||
User recommandIdUser = UserManager.getUserOnlyInMap(recommandId,true);
|
||||
if (recommandFriends == null || recommandIdUser == null) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.ljsd.jieling.logic.encourage.EncourageLogic;
|
|||
import com.ljsd.jieling.logic.encourage.EncouragePlanTypeEnum;
|
||||
import com.ljsd.jieling.logic.fight.FightDispatcher;
|
||||
import com.ljsd.jieling.logic.fight.FightEvent;
|
||||
import com.ljsd.jieling.logic.fight.FightUtil;
|
||||
import com.ljsd.jieling.logic.fight.GameFightType;
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
|
|
@ -449,23 +450,30 @@ public class VirtualBattleLogic {
|
|||
|
||||
String selfKey = getSelfKeyForRePlay(user.getId(), Integer.valueOf(gameLevelId));
|
||||
|
||||
RedisUtil.getInstence().set(RedisKey.VirtualBattle_SELF_RECORD, selfKey, arenaRecord);
|
||||
arenaRecordTemp = RedisUtil.getInstence().get(RedisKey.VirtualBattle_FAST_RECORD, gameLevelId, ArenaRecord.class);
|
||||
// RedisUtil.getInstence().set(RedisKey.VirtualBattle_SELF_RECORD, selfKey, arenaRecord);
|
||||
FightUtil.addBattleRecord(RedisKey.VirtualBattle_SELF_RECORD, selfKey, arenaRecord);
|
||||
// arenaRecordTemp = RedisUtil.getInstence().get(RedisKey.VirtualBattle_FAST_RECORD, gameLevelId, ArenaRecord.class);
|
||||
arenaRecordTemp = FightUtil.getBattleRecord(RedisKey.VirtualBattle_FAST_RECORD, gameLevelId);
|
||||
if (arenaRecordTemp == null) {
|
||||
RedisUtil.getInstence().set(RedisKey.VirtualBattle_FAST_RECORD, gameLevelId, arenaRecord);
|
||||
// RedisUtil.getInstence().set(RedisKey.VirtualBattle_FAST_RECORD, gameLevelId, arenaRecord);
|
||||
FightUtil.addBattleRecord(RedisKey.VirtualBattle_FAST_RECORD, gameLevelId, arenaRecord);
|
||||
} else {
|
||||
if (arenaRecord.getUseTime() < arenaRecordTemp.getUseTime()) {
|
||||
RedisUtil.getInstence().set(RedisKey.VirtualBattle_FAST_RECORD, gameLevelId, arenaRecord);
|
||||
// RedisUtil.getInstence().set(RedisKey.VirtualBattle_FAST_RECORD, gameLevelId, arenaRecord);
|
||||
FightUtil.addBattleRecord(RedisKey.VirtualBattle_FAST_RECORD, gameLevelId, arenaRecord);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
arenaRecordTemp = RedisUtil.getInstence().get(RedisKey.VirtualBattle_POWER_TOP_RECORD, gameLevelId, ArenaRecord.class);
|
||||
// arenaRecordTemp = RedisUtil.getInstence().get(RedisKey.VirtualBattle_POWER_TOP_RECORD, gameLevelId, ArenaRecord.class);
|
||||
arenaRecordTemp = FightUtil.getBattleRecord(RedisKey.VirtualBattle_POWER_TOP_RECORD, gameLevelId);
|
||||
if (arenaRecordTemp == null) {
|
||||
RedisUtil.getInstence().set(RedisKey.VirtualBattle_POWER_TOP_RECORD, gameLevelId, arenaRecord);
|
||||
// RedisUtil.getInstence().set(RedisKey.VirtualBattle_POWER_TOP_RECORD, gameLevelId, arenaRecord);
|
||||
FightUtil.addBattleRecord(RedisKey.VirtualBattle_POWER_TOP_RECORD, gameLevelId, arenaRecord);
|
||||
} else {
|
||||
if (arenaRecord.getFightPower() < arenaRecordTemp.getFightPower()) {
|
||||
RedisUtil.getInstence().set(RedisKey.VirtualBattle_POWER_TOP_RECORD, gameLevelId, arenaRecord);
|
||||
// RedisUtil.getInstence().set(RedisKey.VirtualBattle_POWER_TOP_RECORD, gameLevelId, arenaRecord);
|
||||
FightUtil.addBattleRecord(RedisKey.VirtualBattle_POWER_TOP_RECORD, gameLevelId, arenaRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue