back_recharge
gaojie 2019-07-02 17:52:40 +08:00
commit 074cd07972
7 changed files with 80 additions and 49 deletions

View File

@ -102,6 +102,8 @@ public class RedisKey {
public static final String CUser_Chat = ":CUser_Chat:"; public static final String CUser_Chat = ":CUser_Chat:";
public static final String USER_LOGIN_URL = "USER_LOGIN_URL:";
public static String getKey(String type, String key, boolean withoutServerId) { public static String getKey(String type, String key, boolean withoutServerId) {
if (withoutServerId) { if (withoutServerId) {
return GameApplication.areaId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key); return GameApplication.areaId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key);

View File

@ -1,5 +1,7 @@
package com.ljsd.jieling.handler; package com.ljsd.jieling.handler;
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.handler.map.MapLogic;
import com.ljsd.jieling.handler.map.MapManager; import com.ljsd.jieling.handler.map.MapManager;
import com.ljsd.jieling.logic.GlobalDataManaager; import com.ljsd.jieling.logic.GlobalDataManaager;
@ -20,6 +22,7 @@ import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto; import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.MessageTypeProto; import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.protocols.PlayerInfoProto; import com.ljsd.jieling.protocols.PlayerInfoProto;
import com.ljsd.jieling.thread.task.RPCServerTask;
import com.ljsd.jieling.util.CBean2Proto; import com.ljsd.jieling.util.CBean2Proto;
import com.ljsd.jieling.util.MessageUtil; import com.ljsd.jieling.util.MessageUtil;
import com.ljsd.jieling.util.TimeUtils; import com.ljsd.jieling.util.TimeUtils;
@ -97,6 +100,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
try { try {
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_PLAYERINFO_RESPONSE_VALUE, getPlayerInfoResponse, true); MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_PLAYERINFO_RESPONSE_VALUE, getPlayerInfoResponse, true);
ActivityLogic.getInstance().flushForLogin(user); ActivityLogic.getInstance().flushForLogin(user);
RedisUtil.getInstence().set(RedisKey.USER_LOGIN_URL + userId, RPCServerTask.userCallBackUrl);
LOGGER.info("back to client!"); LOGGER.info("back to client!");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -192,7 +192,7 @@ public class MapLogic {
if (reviveTime > 0) { if (reviveTime > 0) {
mapEnterResponse.setReviveTime(reviveTime); mapEnterResponse.setReviveTime(reviveTime);
} }
if(mapManager.getTowerUnusedBuffer()!=null&&mapManager.getTowerUnusedBuffer().size()>1){ if(mapManager.getTowerUnusedBuffer()!=null&&mapManager.getTowerUnusedBuffer().size()>=1){
List<MapInfoProto.TowerBuff> towerBuffs = new ArrayList<>(); List<MapInfoProto.TowerBuff> towerBuffs = new ArrayList<>();
for(Map.Entry<Integer,Integer> buffer:mapManager.getTowerUnusedBuffer().entrySet()){ for(Map.Entry<Integer,Integer> buffer:mapManager.getTowerUnusedBuffer().entrySet()){
TowerBuff towerBuff = new TowerBuff(buffer.getKey(),buffer.getValue()); TowerBuff towerBuff = new TowerBuff(buffer.getKey(),buffer.getValue());
@ -232,15 +232,14 @@ public class MapLogic {
.build(); .build();
mapEnterResponse.addHeroInfos(heroInfo); mapEnterResponse.addHeroInfos(heroInfo);
} }
List<MapInfoProto.TowerBuff> buffers = new ArrayList<>(); // List<MapInfoProto.TowerBuff> buffers = new ArrayList<>();
if(mapManager.getTowerUnusedBuffer()!=null){ // if(mapManager.getTowerUnusedBuffer()!=null){
for(Map.Entry<Integer,Integer> entry:mapManager.getTowerUnusedBuffer().entrySet()){ // for(Map.Entry<Integer,Integer> entry:mapManager.getTowerUnusedBuffer().entrySet()){
TowerBuff buff = new TowerBuff(entry.getKey(),entry.getValue()); // TowerBuff buff = new TowerBuff(entry.getKey(),entry.getValue());
buffers.add(CBean2Proto.getTowerBuff(buff)); // buffers.add(CBean2Proto.getTowerBuff(buff));
} // }
} // }
// mapManager.setStartExporeTime(System.currentTimeMillis()); // mapManager.setStartExporeTime(System.currentTimeMillis());
mapEnterResponse.addAllBuf(buffers);
LOGGER.info("enterMap() uid=>{} mapId =>{}", uid, mapManager.getCurMapId()); LOGGER.info("enterMap() uid=>{} mapId =>{}", uid, mapManager.getCurMapId());
MessageUtil.sendMessage(iSession, 1, messageType.getNumber(), mapEnterResponse.build(), true); MessageUtil.sendMessage(iSession, 1, messageType.getNumber(), mapEnterResponse.build(), true);
} }
@ -809,27 +808,32 @@ public class MapLogic {
MapManager mapManager = user.getMapManager(); MapManager mapManager = user.getMapManager();
SChallengeConfig challengeConfig = SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()); SChallengeConfig challengeConfig = SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId());
if(challengeConfig.getType()==2){ if(challengeConfig.getType()==2){
int time = (int)((System.currentTimeMillis()-mapManager.getStartExporeTime())/1000); // int time = (int)((System.currentTimeMillis()-mapManager.getStartExporeTime())/1000);
mapManager.setCurrTowerTime(time); // mapManager.setCurrTowerTime(time);
if(mapManager.getEveryTowerTime()!=null&&mapManager.getEveryTowerTime().get(mapManager.getTower())!=null){ // if(mapManager.getEveryTowerTime()!=null&&mapManager.getEveryTowerTime().get(mapManager.getTower())!=null){
mapManager.setTowerTimeByTower(mapManager.getTower(),time); // mapManager.setTowerTimeByTower(mapManager.getTower(),time);
} // }
if(mapManager.getTower()>=1){ if(mapManager.getTower()>=1){
mapManager.setMapIntoFlag(1); mapManager.setMapIntoFlag(1);
} }
} }
MapInfoProto.MapOutResponse.Builder builder = MapInfoProto.MapOutResponse.newBuilder();
if(outType == 0||mapManager.getTower()-1==STrialConfig.getHighestTower()){ if(outType == 0||mapManager.getTower()-1==STrialConfig.getHighestTower()){
if(mapManager.getTowerUnusedBuffer()!=null){
mapManager.setTowerUnusedBuffer(null);
};
LOGGER.info("退出地图");
boolean result = onlyLevelMap(user, true); boolean result = onlyLevelMap(user, true);
if (!result) { if (!result) {
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), ""); MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
return; return;
} }
} }
MapInfoProto.MapOutResponse.Builder builder = MapInfoProto.MapOutResponse.newBuilder(); int time = (int)(TimeUtils.now()-mapManager.getCurrTowerTime())/1000;
// builder.setUseTime(mapManager.getCurrTowerTime()); builder.setUseTime(time);
LOGGER.info("当前层使用时间{}"+mapManager.getCurrTowerTime()); LOGGER.info("当前层使用时间{}",time);
if(mapManager.getTower()>mapManager.getHighestTower()){ if(mapManager.getTower()>mapManager.getHighestTower()){
mapManager.setHighestTower(mapManager.getTower()); mapManager.setHighestTower(mapManager.getTower());
} }
@ -1247,7 +1251,7 @@ public class MapLogic {
} }
// if(mapManager.getBossType()==1) // if(mapManager.getBossType()==1)
if(mapManager.getTower()==STrialConfig.getHighestTower()&&mapManager.getBossType()!=0){ if(mapManager.getTower()==STrialConfig.getHighestTower()&&mapManager.getBossType()!=0){
// fightEndResponse.setLastTowerTime(mapManager.getCurrTowerTime()); fightEndResponse.setLastTowerTime((int)(TimeUtils.now()-mapManager.getCurrTowerTime())/1000);
}else{ }else{
fightEndResponse.setLastTowerTime(0); fightEndResponse.setLastTowerTime(0);
} }
@ -1564,7 +1568,7 @@ public class MapLogic {
.setMapIntoReset(mapManager.getMapIntoFlag()) .setMapIntoReset(mapManager.getMapIntoFlag())
.build(); .build();
builder.setTowerCopyInfo(towerCopyInfo); builder.setTowerCopyInfo(towerCopyInfo);
LOGGER.info("关卡信息{}"+towerCopyInfo.toString()); LOGGER.info("关卡信息{}",towerCopyInfo.toString());
MessageUtil.sendMessage(iSession, 1, msgId, builder.build(), true); MessageUtil.sendMessage(iSession, 1, msgId, builder.build(), true);
} }
@ -2080,28 +2084,14 @@ public class MapLogic {
int[][] bossType = config.getRandomBossType(); int[][] bossType = config.getRandomBossType();
type = MathUtils.randomFromWeight(bossType); type = MathUtils.randomFromWeight(bossType);
if(mapManager.getTower()==1){ if(mapManager.getTower()<=3){
type = 2; type = 3;
}else if(mapManager.getTower()==2){
type = 4;
} }
// }else if(mapManager.getTower()==2){
// type = 3;
// int amount = 0;
// for(int i = 0 ; i <bossType.length;i++){
// amount+=bossType[i][1];
//
// }
// int rate = MathUtils.randomInt(amount);
// LOGGER.info("怪物种类rate"+String.valueOf(rate));
// amount = 0;
// for (int i = 0 ; i<bossType.length;i++){
// amount+=bossType[i][1];
// if(rate<amount){
// type = bossType[i][0];
// break;
// }
// }
int[][][] pointId = config.getRandomMapPointId(); int[][][] pointId = config.getRandomMapPointId();
int mapId = config.getMapId(); int mapId = config.getMapId();
SChallengeMapConfig challengeMapConfig = SChallengeMapConfig.integerSChallengeMapConfigMap.get(mapId); SChallengeMapConfig challengeMapConfig = SChallengeMapConfig.integerSChallengeMapConfigMap.get(mapId);
@ -2247,9 +2237,9 @@ public class MapLogic {
return; return;
} }
playerInfoManager.updateVipPrivilage(VipPrivilegeType.TOWER_RESRT_NUM,1); playerInfoManager.updateVipPrivilage(VipPrivilegeType.TOWER_RESRT_NUM,1);
LOGGER.info("重置当前层,当前层为{}",mapManager.getTower());
if(mapManager.getTower()>5){ if(mapManager.getTower()>5){
mapManager.setTower(mapManager.getTower()-mapManager.getTower()%5); mapManager.setTower(mapManager.getTower()-(mapManager.getTower()%5));
}else{ }else{
mapManager.setTower(1); mapManager.setTower(1);
} }
@ -2277,20 +2267,51 @@ public class MapLogic {
public void useTowerBuff(ISession session,int towerLevel,int optionId , MessageTypeProto.MessageType messageType) throws Exception { public void useTowerBuff(ISession session,int towerLevel,int optionId , MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid(); int uid = session.getUid();
MapManager mapManager = UserManager.getUser(uid).getMapManager(); MapManager mapManager = UserManager.getUser(uid).getMapManager();
User user = UserManager.getUser(uid);
String err = checkUseTowerBuff(mapManager, towerLevel, optionId); String err = checkUseTowerBuff(mapManager, towerLevel, optionId);
if(!"".equals(err)){ if(!"".equals(err)){
MessageUtil.sendErrorResponse(session,0,messageType.getNumber(),err); MessageUtil.sendErrorResponse(session,0,messageType.getNumber(),err);
return; return;
} }
int mapPointId = mapManager.getTowerUnusedBuffer().get(towerLevel); int eventId = mapManager.getTowerUnusedBuffer().get(towerLevel);
mapManager.consunmeTowerBuffer(towerLevel); mapManager.consunmeTowerBuffer(towerLevel);
int buffId = SOptionConfig.sOptionConfigMap.get(optionId).getBehaviorTypeValues()[0][0]; // MapPointConfig pointConfig = MapPointConfig.getScMapEventMap().get(mapPointId);
// int initialEventId = pointConfig.getInitialEventId();
LOGGER.info("使用第{},mapPointId,id是:{}",towerLevel,mapPointId); SEventPointConfig sEventPointConfig = SEventPointConfig.sEventPointConfigMap.get(eventId);
CombatLogic.getInstance().bufferAddByEatFoodOrEventTrigger(mapManager,buffId); int[] options = sEventPointConfig.getOption();
LOGGER.info("使用第"+towerLevel+"层buff,id是:"+buffId); // for(int option : options){
//
// }
SOptionConfig sOptionConfig = SOptionConfig.sOptionConfigMap.get(optionId);
int behaviorType = sOptionConfig.getBehaviorType();
int[][] behaviorTypeValues = sOptionConfig.getBehaviorTypeValues();
BaseBehavior baseBehavior = baseBehaviorMap.get(behaviorType);
MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse = MapInfoProto.EventUpdateResponse.newBuilder();
if (baseBehavior != null) {
boolean isSuccess = baseBehavior.process(optionId, user, behaviorTypeValues, eventUpdateResponse);
if (!isSuccess) {
LOGGER.info("updatePonintEvent() baseBehavior process fail! behaviorType=>{}", behaviorType);
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
return;
}
}
List<CommonProto.EventBehaviorValues> eventBehaviorValuesList = new ArrayList<>();
for (int i = 0; i < sOptionConfig.getBehaviorTypeValues().length; i++) {
CommonProto.EventBehaviorValues.Builder eventBehaviorValues = CommonProto.EventBehaviorValues
.newBuilder();
for (int j = 0; j < sOptionConfig.getBehaviorTypeValues()[i].length; j++) {
eventBehaviorValues.addBehaviorValues(sOptionConfig.getBehaviorTypeValues()[i][j]);
}
eventBehaviorValuesList.add(eventBehaviorValues.build());
}
CommonProto.EventBehaviorCommon eventBehaviorCommon = CommonProto.EventBehaviorCommon
.newBuilder()
.setBehaviorType(sOptionConfig.getBehaviorType())
.addAllEventBehaviorValues(eventBehaviorValuesList)
.build();
LOGGER.info("使用第{},mapPointId,id是:{}",towerLevel,eventId);
MapInfoProto.UseTowerBuffResponse.Builder useTowerBuffResponse = MapInfoProto.UseTowerBuffResponse.newBuilder(); MapInfoProto.UseTowerBuffResponse.Builder useTowerBuffResponse = MapInfoProto.UseTowerBuffResponse.newBuilder();
useTowerBuffResponse.setEventBehaviorCommon(eventBehaviorCommon);
// useTowerBuffResponse.setBuffId(buffId); // useTowerBuffResponse.setBuffId(buffId);
MessageUtil.sendMessage(session,1,messageType.getNumber(),useTowerBuffResponse.build(),true); MessageUtil.sendMessage(session,1,messageType.getNumber(),useTowerBuffResponse.build(),true);

View File

@ -30,7 +30,7 @@ public class FourtyThreeBehavior extends BaseBehavior{
}; };
if (mapManager.getBossType()==3){ if (mapManager.getBossType()==3){
Cell cell = mapManager.getMapInfo().get(mapManager.getBossXY()); Cell cell = mapManager.getMapInfo().get(mapManager.getBossXY());
LOGGER.info("暂存buff层数:"+mapManager.getTower()+",buff:"+cell.getEventId()); LOGGER.info("暂存buff层数:"+mapManager.getTower()+",buff:"+cell.getEventId()+"pointId:"+cell.getPointId());
mapManager.addTowerUnusedBuffer(mapManager.getTower(),cell.getEventId()); mapManager.addTowerUnusedBuffer(mapManager.getTower(),cell.getEventId());
return true; return true;
}else if(mapManager.getBossType()==4){ }else if(mapManager.getBossType()==4){

View File

@ -32,6 +32,7 @@ public class FourtyTwoBehavior extends BaseBehavior{
mapManager.removeBoss(); mapManager.removeBoss();
mapManager.setTower(mapManager.getTower()+1); mapManager.setTower(mapManager.getTower()+1);
mapManager.setEssenceValue(0); mapManager.setEssenceValue(0);
mapManager.setStartExporeTime(0);
mapManager.setCurrTowerTime(TimeUtils.now()); mapManager.setCurrTowerTime(TimeUtils.now());
user.getUserMissionManager().onGameEvent(user, GameEvent.COPY_TOWER_LEVEL,mapManager.getTower()); user.getUserMissionManager().onGameEvent(user, GameEvent.COPY_TOWER_LEVEL,mapManager.getTower());
MapLogic.getInstance().initTrialMap(mapManager, user); MapLogic.getInstance().initTrialMap(mapManager, user);

View File

@ -87,7 +87,7 @@ public enum MissionType {
case 14: case 14:
return LEVEL_STORY_PASS; return LEVEL_STORY_PASS;
case 15: case 15:
return HERO_STORY_PASS; return GENERAL_STORY_PASS;
case 16: case 16:
return HERO_STORY_PASS; return HERO_STORY_PASS;
case 17: case 17:

View File

@ -18,10 +18,13 @@ import java.net.InetSocketAddress;
public class RPCServerTask extends Thread{ public class RPCServerTask extends Thread{
private static final Logger LOGGER = LoggerFactory.getLogger(RPCServerTask.class); private static final Logger LOGGER = LoggerFactory.getLogger(RPCServerTask.class);
public static String userCallBackUrl;
private CoreSettings coreSettings; private CoreSettings coreSettings;
public RPCServerTask(ConfigurableApplicationContext configurableApplicationContext){ public RPCServerTask(ConfigurableApplicationContext configurableApplicationContext){
this.coreSettings = configurableApplicationContext.getBean(CoreSettings.class); this.coreSettings = configurableApplicationContext.getBean(CoreSettings.class);
userCallBackUrl = this.coreSettings.getIp() + ":" + this.coreSettings.getPort();
setName("rpc"); setName("rpc");
} }