back_recharge
zhangshanxue 2020-06-03 09:53:13 +08:00
commit 9942b4abb3
11 changed files with 291 additions and 357 deletions

View File

@ -38,11 +38,11 @@ public class SignInHandler extends BaseHandler {
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
Calendar cale = Calendar.getInstance();
int month = cale.get(Calendar.MONTH) + 1;
if (sign.getMonth() != month) {
return;
}
// Calendar cale = Calendar.getInstance();
// int month = cale.get(Calendar.MONTH) + 1;
// if (sign.getMonth() != month) {
// return;
// }
User user = UserManager.getUser(iSession.getUid());
if (sign.getDay() != (user.getPlayerInfoManager().getSign() + 1)) {

View File

@ -111,6 +111,7 @@ public class EventType {
public static final int fourtySeven = 47;
public static final int fourtyEight = 48;
public static final int fourtyNine = 49;
public static final int fifty = 50;
public static final int updatePonintEvent = 1;
public static final int fightEvent = 2;

View File

@ -2139,79 +2139,6 @@ public class MapLogic {
RankContext.getRankEnum(RankEnum.MAIN_LEVEL_RANK.getType()).addRank(uid,"",sMainLevelConfig.getVirtureId(),user.getPlayerInfoManager().getMaxForce());
}
// public void getMainLevelRankInfo(ISession session) throws Exception {
// int rankEndLine = SSpecialConfig.getIntegerValue(SSpecialConfig.Level_RankingShowNum);
// int rank =1;
// Set<ZSetOperations.TypedTuple<String>> arenaRankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.MAINLEVEL_RANK, "", 0, rankEndLine-1);
// FightInfoProto.MainLevelRankInfoResponse.Builder builder = FightInfoProto.MainLevelRankInfoResponse.newBuilder();
// List<CommonProto.MainLevelRankInfo.Builder> mainLevelRankInfoList = new ArrayList<>(rankEndLine);
// for (ZSetOperations.TypedTuple<String> item : arenaRankInfo) {
// String value = item.getValue();
// int score = item.getScore().intValue();
// int uidTmp = Integer.parseInt(value);
// User userTmp = UserManager.getUser(uidTmp, true);
// if (null == userTmp) {
// continue;
// }
// PlayerManager playerInfoManager = userTmp.getPlayerInfoManager();
// mainLevelRankInfoList.add(CommonProto.MainLevelRankInfo.newBuilder()
// .setUid(uidTmp)
// .setLevel(playerInfoManager.getLevel())
// .setName(playerInfoManager.getNickName())
// .setFightId(SMainLevelConfig.sMainLevelConfigByVirtureIdMap.get(score).getVirtureId())
// .setHead(playerInfoManager.getHead())
// .setRank(rank++)
// .setTotalForce(userTmp.getPlayerInfoManager().getMaxForce())
// .setHeadFrame(playerInfoManager.getHeadFrame()));
//// }
// Collections.sort(mainLevelRankInfoList, new Comparator<CommonProto.MainLevelRankInfo.Builder>() {
// @Override
// public int compare(CommonProto.MainLevelRankInfo.Builder o1, CommonProto.MainLevelRankInfo.Builder o2) {
// if(o1.getFightId()==o2.getFightId()){
// if(o1.getTotalForce()>o2.getTotalForce() && o1.getRank()>o2.getRank()){
// int rank = o1.getRank();
// o1.setRank(o2.getRank());
// o2.setRank(rank);
// }
// }
// return o1.getRank()-o2.getRank();
// }
// });
//// rank =1;
// int myRank =-1;
// int uid = session.getUid();
// for(CommonProto.MainLevelRankInfo.Builder builder1 : mainLevelRankInfoList){
// builder1.setRank(rank++);
// builder1.setFightId(SMainLevelConfig.sMainLevelConfigByVirtureIdMap.get(builder1.getFightId()).getId());
// builder.addMainLevelRankInfo(builder1.build());
// if(builder1.getUid() == uid){
// myRank = builder1.getRank();
// }
// }
//
// int score = RedisUtil.getInstence().getZSetScore(RedisKey.MAINLEVEL_RANK,"", Integer.toString(uid)).intValue();
// if(score == -1){
// score = 1011;
// }else{
// if(myRank==-1){
// myRank= RedisUtil.getInstence().getZSetreverseRank(RedisKey.MAINLEVEL_RANK,"",Integer.toString(uid)).intValue();
// }
// score= SMainLevelConfig.sMainLevelConfigByVirtureIdMap.get(score).getId();
// }
// User user = UserManager.getUser(uid);
// PlayerManager playerInfoManager = user.getPlayerInfoManager();
// builder.setMyMainLevelRankInfo(CommonProto.MainLevelRankInfo.newBuilder()
// .setUid(uid)
// .setLevel(playerInfoManager.getLevel())
// .setName(playerInfoManager.getNickName())
// .setFightId(score)
// .setHead(playerInfoManager.getHead())
// .setRank(myRank)
// .setTotalForce(playerInfoManager.getMaxForce())
// .setHeadFrame(playerInfoManager.getHeadFrame()).build());
// MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.MAIN_LEVEL_GET_RANK_RESPONSE_VALUE,builder.build(),true);
//
// }
public void openNextMainLevel(User user,int fightId) throws Exception {
int level = user.getPlayerInfoManager().getLevel();
@ -2385,215 +2312,6 @@ public class MapLogic {
}
}
// /**
// * 初始化爬塔副本
// * @param mapManager
// * @param user
// * @return
// * @throws Exception
// */
// public String initTrialMap(MapManager mapManager, User user) throws Exception {
//
// STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(mapManager.getTrialInfo().getFloor());
// if(mapManager.getTrialInfo().getFloor()>1&&mapManager.getMapIntoFlag()==0){
// for(int i = 1 ; i <mapManager.getTrialInfo().getFloor();i++){
// ItemUtil.drop(user,STrialConfig.sTrialConfigMap.get(i).getReward(),1.0f,1,BIReason.TOWER_SWEEP_REWARD);
// int type = MathUtils.randomFromWeight(STrialConfig.sTrialConfigMap.get(i).getRandomBossType());
// if(type == 3){
// STrialConfig config = STrialConfig.sTrialConfigMap.get(i);
// int[][][] randomMapPointId = config.getRandomMapPointId();
// int randomPoint = MathUtils.randomFromWeight(randomMapPointId[type-1]);
// int initialEventId = MapPointConfig.getScMapEventMap().get(randomPoint).getInitialEventId();
// mapManager.addTowerUnusedBuffer(i,initialEventId);
// }
// if(type == 4){
// int storeIndex = MathUtils.randomFromWeight(STrialConfig.sTrialConfigMap.get(mapManager.getTrialInfo().getFloor()).getRandomStore());
// StoreLogic.initOrUpdateOneStore(user,8,storeIndex);
// }
// }
// }
// if (sTrialConfig == null) {
// LOGGER.info("initTrialMap() uid=>{} sTrialConfig == null =>{} ", user.getId(), mapManager.getTrialInfo().getFloor());
// return "";
// }
// SChallengeMapConfig scMapConfig = STableManager.getConfig(SChallengeMapConfig.class).get(sTrialConfig.getMapId());
// if (scMapConfig == null) {
// LOGGER.info("initTrialMap() uid=>{} sChallengeConfig == null =>{} ", user.getId(), sTrialConfig.getMapId());
// return "该地图不存在";
// }
// Map<Integer, Cell> newMap = new HashMap<>();
// Random random = new Random();
// Map<Integer, SCMap> scMap = SCMap.sCMap.get(sTrialConfig.getMapId());
// Map<Integer, Cell> cellMap1 = new HashMap<>(sTrialConfig.getMonsterCount()[0]);
// Map<Integer, Cell> cellMap2 = new HashMap<>(sTrialConfig.getMonsterCount()[1]);
//
// /* if(mapManager.getTowerStartTime()!=0){
// mapManager.setCurrTowerTime((TimeUtils.now()-mapManager.getTowerStartTime())/1000);
// }*/
// mapManager.setTowerStartTime(TimeUtils.now());
//
// for (Map.Entry<Integer, SCMap> entry : scMap.entrySet()) {
// SCMap scMap1 = entry.getValue();
// // 必出现的事件点
// if (scMap1.getIsMustAppear() == 1) {
// for (int i = 0; i < scMap1.getGroups().length; i++) {
// int x = scMap1.getGroups()[i][0];
// int y = scMap1.getGroups()[i][1];
// int xy = CellUtil.xy2Pos(x, y);
// MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(scMap1.getEvent());
// Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId());
// newMap.put(xy, cellValue);
// }
// continue;
// }
// if (scMap1.getEvent() == 1) {
// int i = 0;
// while (cellMap1.size() < sTrialConfig.getMonsterCount()[0]) {
// i++;
// if (i >= 10000) {
// break;
// }
// int randomIndex = random.nextInt(scMap1.getGroups().length);
// int x = scMap1.getGroups()[randomIndex][0];
// int y = scMap1.getGroups()[randomIndex][1];
// int xy = CellUtil.xy2Pos(x, y);
// MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(sTrialConfig.getRandomMonsterType()[0][1]);
// if (mapPointConfig == null) {
// LOGGER.info("====initTrialMap()====mapPointConfig == null======>{}", scMap1.getEvent());
// continue;
// }
// Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId());
// cellMap1.put(xy, cellValue);
// }
// } else if (scMap1.getEvent() == 2) {
// int i = 0;
// while (cellMap2.size() < sTrialConfig.getMonsterCount()[1]) {
// i++;
// if (i >= 10000) {
// break;
// }
// int randomIndex = random.nextInt(scMap1.getGroups().length);
// int x = scMap1.getGroups()[randomIndex][0];
// int y = scMap1.getGroups()[randomIndex][1];
// int xy = CellUtil.xy2Pos(x, y);
// MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(sTrialConfig.getRandomMonsterType()[1][1]);
// if (mapPointConfig == null) {
// LOGGER.info("====initTrialMap()====mapPointConfig == null======>{}", scMap1.getEvent());
// continue;
// }
// Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId());
// cellMap2.put(xy, cellValue);
// }
// } else {
// // 随机出现的事件点
// int randomIndex = random.nextInt(scMap1.getGroups().length);
// int x = scMap1.getGroups()[randomIndex][0];
// int y = scMap1.getGroups()[randomIndex][1];
// int xy = CellUtil.xy2Pos(x, y);
// MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(scMap1.getEvent());
// if (mapPointConfig == null) {
// LOGGER.info("====initTrialMap()====mapPointConfig == null======>{}", scMap1.getEvent());
// continue;
// }
// Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId());
// newMap.put(xy, cellValue);
// }
// newMap.putAll(cellMap1);
// newMap.putAll(cellMap2);
// }
// SChallengeMapConfig challengeMapConfig = STableManager.getConfig(SChallengeMapConfig.class).get(sTrialConfig.getMapId());
// int xy = CellUtil.xy2Pos(challengeMapConfig.getPosition()[0], challengeMapConfig.getPosition()[1]);
// mapManager.setCurXY(xy);
// mapManager.setMapInfo(newMap);
// mapManager.setTrialEnergy(0);
//// mapManager.setHeroAllAttributeMap(mapManager.getHeroAllAttributeMap());
// if(mapManager.getTowerUnusedBuffer()==null){
// mapManager.setTowerUnusedBuffer(new HashMap<>());
// }
// return "";
// }
/**
*
*
* @param session
* @param messageType
*/
public void callChief(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
// LOGGER.info("进入召唤boss");
int uid = session.getUid();
User user = UserManager.getUser(uid);
MapManager mapManager = user.getMapManager();
if(mapManager.getTrialInfo().getEnergy()<100){
throw new ErrorCodeException(ErrorCode.newDefineCode("精气值不足!!"));
}
int currTower = mapManager.getTrialInfo().getFloor();
STrialConfig config = STrialConfig.sTrialConfigMap.get(currTower);
int type = 1;
int[][] bossType = config.getRandomBossType();
type = MathUtils.randomFromWeight(bossType);
// if(mapManager.getTrialInfo().getFloor()%5!=0){
// type = 3;
// }
LOGGER.info("trigger!!!!!!!!!!!!!!!!!-------->{},{}",CellUtil.pos2XY(mapManager.getCurXY())[0],CellUtil.pos2XY(mapManager.getCurXY())[1]);
int[][][] pointId = config.getRandomMapPointId();
int mapId = config.getMapId();
SChallengeMapConfig challengeMapConfig = STableManager.getConfig(SChallengeMapConfig.class).get(mapId);
int[] mapSize = challengeMapConfig.getSize();
// LOGGER.info("width:{},height:{},当前:{}==={}",String.valueOf(mapSize[0]),String.valueOf(mapSize[1]),CellUtil.pos2XY(mapManager.getCurXY())[0],CellUtil.pos2XY(mapManager.getCurXY())[1]);
Set<Integer> xySet = CellUtil.getSurroundPos(mapSize[0],mapSize[1],mapManager.getCurXY());
LOGGER.info(xySet.toString());
Map<Integer, Cell> mapInfo = mapManager.getMapInfo();
clearNormalMonster(user);
Iterator<Integer> it = xySet.iterator();
Map<Integer, MapPointConfig> pointConfig = MapPointConfig.scMapEventMap;
while (it.hasNext()){
Integer n = it.next();
// LOGGER.info("遍历{},{}",CellUtil.pos2XY(n)[0],CellUtil.pos2XY(n)[1]);
for(Map.Entry<Integer,Cell> cellEntry:mapInfo.entrySet()){
if(cellEntry.getKey().equals(n)) {
if (pointConfig.get(cellEntry.getValue().getPointId()).getStyle() != 0) {
it.remove();
break;
}
}
}
}
// LOGGER.info("怪物可出现格子数量{}",String.valueOf(xySet.size()));
// int random = MathUtils.randomInt(xySet.size());
// LOGGER.info("random"+String.valueOf(random));
int i = 0;
// int xyResult = 0;
// for(Integer xy:xySet){
//// LOGGER.info("怪物位置:{},{}",String.valueOf(CellUtil.pos2XY(xy)[0]),String.valueOf(CellUtil.pos2XY(xy)[1]));
// if(random==i){
// xyResult = xy;
// break;
// }
// i++;
// }
//更改成固定boss位置
int[] bossPosition = STrialSetting.sTrialSetting.getBossPosition();
mapManager.setBossType(type);
mapManager.setBossXY(CellUtil.xy2Pos(bossPosition[0],bossPosition[1]));
int randomPoint = MathUtils.randomFromWeight(pointId[type-1]);
// LOGGER.info("随机事件id==>{}",randomPoint);
MapInfoProto.MapTowerCallChiefResponse.Builder response = MapInfoProto.MapTowerCallChiefResponse.newBuilder();
Cell cell = BehaviorUtil.addBehaviorInfo(user,randomPoint,mapManager,mapManager.getCurMapId(),bossPosition[0],bossPosition[1],false);
CommonProto.Cell protoCell =CBean2Proto.getCell(cell);
response.setType(type);
mapManager.setTrialEnergy(-1);
response.setMonsterInfo(protoCell);
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
}
/**
* 使`
*
@ -2655,7 +2373,6 @@ public class MapLogic {
}
public void clearNormalMonster(User user) throws Exception {
MapManager mapManager = user.getMapManager();
LOGGER.info("删除当前地图小怪!!");
Map<Integer, MapPointConfig> configMap = MapPointConfig.scMapEventMap;
Set<Integer> destoryCell = new HashSet<>();
@ -3363,6 +3080,13 @@ public class MapLogic {
mapManager.updateTrailHeroInfo(heroInfo);
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
}
/**
*
* @param session
* @param messageType
* @throws Exception
*/
public void trialGetBox(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
User user = UserManager.getUser(session.getUid());
MapManager mapManager = user.getMapManager();
@ -3371,24 +3095,46 @@ public class MapLogic {
//是否在试炼副本中
if(map instanceof TowerMap){
int curXY = mapManager.getCurXY();
STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(mapManager.getTrialInfo().getFloor());
for(int i = 0 ; i<sTrialConfig.getBoxPosition().length;i++){
int xyPos = CellUtil.xy2Pos(sTrialConfig.getBoxPosition()[i][0], sTrialConfig.getBoxPosition()[i][1]);
Cell cell = mapManager.getMapInfo().get(xyPos);
if(xyPos==curXY){
if(cell!=null&&cell.getPointId()==STrialSetting.sTrialSetting.getBoxPointId()) {
cell.setPointId(0);
int[][] dropArray = sTrialConfig.getBoxReward()[i];
drop = ItemUtil.drop(user, dropArray, BIReason.MAP_EVENET_REWARD);
mapManager.addOrUpdateCell(cell.getCellId(), cell);
break;
}else{
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
}
int floor = mapManager.getTrialInfo().getFloor();
if(floor>10000){
STrialwelfareConfig welfareConfig = STrialwelfareConfig.sTrialwelfareConfigMap.get(floor % 10000);
drop = getBoxReward(welfareConfig.getBoxPosition(),welfareConfig.getBoxReward(),user,curXY);
}else{
STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(floor);
drop = getBoxReward(sTrialConfig.getBoxPosition(),sTrialConfig.getBoxReward(),user,curXY);
}
}
MapInfoProto.GetTrialBoxRewardResponse response = MapInfoProto.GetTrialBoxRewardResponse.newBuilder().setBoxDrop(drop).build();
MessageUtil.sendMessage(session,1,messageType.getNumber(),response,true);
}
/**
*
* @param boxPosition
* @param boxReward
* @param user
* @param curXY
* @return
* @throws Exception
*/
private CommonProto.Drop.Builder getBoxReward(int[][] boxPosition,int[][][] boxReward,User user,int curXY) throws Exception {
MapManager mapManager = user.getMapManager();
CommonProto.Drop.Builder drop= null;
for(int i = 0 ; i<boxPosition.length;i++){
int xyPos = CellUtil.xy2Pos(boxPosition[i][0], boxPosition[i][1]);
Cell cell = mapManager.getMapInfo().get(xyPos);
if(xyPos==curXY){
if(cell!=null&&cell.getPointId()==STrialSetting.sTrialSetting.getBoxPointId()) {
cell.setPointId(0);
int[][] dropArray = boxReward[i];
drop = ItemUtil.drop(user, dropArray, BIReason.MAP_EVENET_REWARD);
mapManager.addOrUpdateCell(cell.getCellId(), cell);
break;
}else{
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
}
}
return drop;
}
}

View File

@ -0,0 +1,32 @@
package com.ljsd.jieling.handler.map.behavior;
import com.ljsd.jieling.handler.map.EventType;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.handler.map.MapManager;
import com.ljsd.jieling.handler.map.TrialInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.protocols.MapInfoProto;
import org.springframework.stereotype.Component;
/**
* @author lvxinran
* @date 2020/6/2
* @discribe
*/
@Component
public class FiftyBehavior extends BaseBehavior{
@Override
public int getBehaviorType() {
return EventType.fifty;
}
@Override
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
MapManager mapManager = user.getMapManager();
TrialInfo trialInfo = mapManager.getTrialInfo();
MapLogic.getInstance().clearNormalMonster(user);
mapManager.removeBoss();
mapManager.setTrialFloor(trialInfo.getFloor() + 10000);
return true;
}
}

View File

@ -33,38 +33,35 @@ public class FourtyTwoBehavior extends BaseBehavior {
int maxTower = STrialConfig.getHighestTower();
SChallengeConfig challengeConfig = SChallengeConfig.sChallengeConfigs.get(user.getMapManager().getCurMapId());
TrialInfo trialInfo = mapManager.getTrialInfo();
if (challengeConfig.getType() == 2 && trialInfo.getFloor() >= maxTower) {
mapManager.setTrialFloor(trialInfo.getFloor() + 1);
LOGGER.info("当前层为{},最大层为{}", trialInfo.getFloor(), maxTower);
int floor = trialInfo.getFloor();
//奖励层处理
if(floor>10000){
floor = floor%10000;
}
//----
if (challengeConfig.getType() == 2 && floor >= maxTower) {
mapManager.setTrialFloor(floor + 1);
LOGGER.info("当前层为{},最大层为{}", floor, maxTower);
return false;
}
LOGGER.info("当前层为{},进入下一层", trialInfo.getFloor());
LOGGER.info("当前层为{},进入下一层", floor);
MapLogic.getInstance().clearNormalMonster(user);
mapManager.removeBoss();
long time = TimeUtils.now() - mapManager.getTowerStartTime();
mapManager.setCurrTowerTime(time);
LOGGER.info("上层使用时间{}", time);
//判断通关最高层是否需要替换
if(trialInfo.getFloor()> trialInfo.getHighestTower()){
trialInfo.setHighestTower(trialInfo.getFloor());
if(floor > trialInfo.getHighestTower()){
trialInfo.setHighestTower(floor);
AbstractRank towerRank = RankContext.getRankEnum(RankEnum.TOWER_RANK.getType());
if(towerRank.getScore(trialInfo.getFloor(),(int)(time/1000))>towerRank.getScoreById(user.getId(),"")){
towerRank.addRank(user.getId(),"", trialInfo.getFloor(),(int)(time/1000));
if(towerRank.getScore(floor,(int)(time/1000))>towerRank.getScoreById(user.getId(),"")){
towerRank.addRank(user.getId(),"", floor,(int)(time/1000));
}
}
user.getUserMissionManager().onGameEvent(user, GameEvent.COPY_TOWER_LEVEL, trialInfo.getFloor());
mapManager.setTrialFloor(trialInfo.getFloor() + 1);
// if(mapManager.getTower()==6){
// mapManager.setTower(50);
// }
user.getUserMissionManager().onGameEvent(user, GameEvent.COPY_TOWER_LEVEL, floor);
mapManager.setTrialFloor(floor + 1);
mapManager.setTrialEnergy(0);
// mapManager.setStartExporeTime(0);
mapManager.setMapIntoFlag(2);
// STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(trialInfo.getFloor());
// mapManager.setCurMapId(sTrialConfig.getMapId());
// mapManager.updateTrialMapInfo(mapManager.getMapInfo());
// MapLogic.getInstance().getMap(user).initMap(mapManager, user);
return true;
}
}

View File

@ -16,6 +16,6 @@ public class MapTowerCallChiefRequest extends BaseHandler {
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
MapLogic.getInstance().callChief(iSession, MessageTypeProto.MessageType.MAP_TOWER_CALL_CHIEF_RESPONSE);
// MapLogic.getInstance().callChief(iSession, MessageTypeProto.MessageType.MAP_TOWER_CALL_CHIEF_RESPONSE);
}
}

View File

@ -25,9 +25,11 @@ import com.ljsd.jieling.logic.fight.result.FightResult;
import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.store.StoreLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.FightInfoProto;
import com.ljsd.jieling.protocols.MapInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.*;
import config.*;
import manager.STableManager;
@ -90,9 +92,11 @@ public class TowerMap extends AbstractMap {
MapManager mapManager = UserManager.getUser(uid).getMapManager();
TrialInfo trialInfo = mapManager.getTrialInfo();
int curFloor = trialInfo.getFloor();
STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(curFloor);
if(sTrialConfig.getMapId()!=mapId){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
if(curFloor<10000){
STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(curFloor);
if(sTrialConfig.getMapId()!=mapId){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
}
if(!trialInfo.getMapInfo().isEmpty()&&mapManager.getCurMapId()==0){
mapManager.setMapInfo(trialInfo.getMapInfo());
@ -162,7 +166,7 @@ public class TowerMap extends AbstractMap {
Cell cell = mapManager.getMapInfo().get(mapManager.getTriggerXY());
int[][] randomMonsterType = sTrialConfig.getRandomMonsterType();
if(cell.getCellId()!=mapManager.getBossXY()){
if(mapManager.getTrialInfo().getEnergy()!=-1){
if(mapManager.getTrialInfo().getEnergy()>=0){
if (randomMonsterType[0][1] == cell.getPointId()) {
mapManager.setTrialEnergy(mapManager.getTrialInfo().getEnergy() + sTrialConfig.getNormalEnergy());
} else {
@ -177,26 +181,35 @@ public class TowerMap extends AbstractMap {
mapManager.setMapInfo(trialMapInfo);
return;
}
STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(mapManager.getTrialInfo().getFloor());
// if(mapManager.getTrialInfo().getFloor()>1&&mapManager.getMapIntoFlag()==0){
// for(int i = 1 ; i <mapManager.getTrialInfo().getFloor();i++){
//// ItemUtil.drop(user,STrialConfig.sTrialConfigMap.get(i).getReward(),1.0f,1,BIReason.TOWER_SWEEP_REWARD);
// int type = MathUtils.randomFromWeight(STrialConfig.sTrialConfigMap.get(i).getRandomBossType());
// if(type == 3){
// STrialConfig config = STrialConfig.sTrialConfigMap.get(i);
// int[][][] randomMapPointId = config.getRandomMapPointId();
// int randomPoint = MathUtils.randomFromWeight(randomMapPointId[type-1]);
// int initialEventId = MapPointConfig.getScMapEventMap().get(randomPoint).getInitialEventId();
// mapManager.addTowerUnusedBuffer(i,initialEventId);
// }
// if(type == 4){
// int storeIndex = MathUtils.randomFromWeight(STrialConfig.sTrialConfigMap.get(mapManager.getTrialInfo().getFloor()).getRandomStore());
// StoreLogic.initOrUpdateOneStore(user,8,storeIndex);
// }
// }
// }
int floor = mapManager.getTrialInfo().getFloor();
if(floor>10000){
int realFloor = floor%10000;
Map<Integer,STrialwelfareConfig> welfareMap = STableManager.getConfig(STrialwelfareConfig.class);
STrialwelfareConfig useConfig = null;
for(STrialwelfareConfig config :welfareMap.values()){
int[] section = config.getSection();
if(realFloor>section[0]&&realFloor<=section[1]){
useConfig = config;
break;
}
}
Map<Integer, Cell> newMap = new HashMap<>();
if(useConfig!=null&&useConfig.getBoxPosition()!=null){
for(int[] position:useConfig.getBoxPosition()){
int cellXY = CellUtil.xy2Pos(position[0], position[1]);
Cell cell = new Cell(cellXY,0,STrialSetting.sTrialSetting.getBoxPointId());
newMap.put(cellXY,cell);
}
}
//生成普通传送门
Cell transport = createTransport(floor);
newMap.put(transport.getCellId(),transport);
mapManager.setMapInfo(newMap);
return;
}
STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(floor);
if (sTrialConfig == null) {
LOGGER.info("initTrialMap() uid=>{} sTrialConfig == null =>{} ", user.getId(), mapManager.getTrialInfo().getFloor());
LOGGER.info("initTrialMap() uid=>{} sTrialConfig == null =>{} ", user.getId(), floor);
return;
}
SChallengeMapConfig scMapConfig = STableManager.getConfig(SChallengeMapConfig.class).get(sTrialConfig.getMapId());
@ -356,8 +369,13 @@ public class TowerMap extends AbstractMap {
if(trialInfo.getEnergy()==-1){
//生成传送门
createCell = createTransport(trialInfo.getFloor());
mapManager.setTrialEnergy(-2);
}
updateEnergy(user);
if(trialInfo.getEnergy()>=100){
//如果大于100则生成boss点
createCell=callChief(user);
}
remainHp = checkResult[2];
}
BehaviorUtil.destoryApointXY(user, destoryXY);
@ -392,10 +410,11 @@ public class TowerMap extends AbstractMap {
// LOGGER.info("endFight() uid=>{} sMonsterGroup.getRewardgroup()=>{} misson=>{} eventDrop=>{}, missionDrop=>{}", uid, sMonsterGroup.getRewardgroup(), fastFightResponse.getMission(), fastFightResponse.getEnventDrop(), fastFightResponse.getMissionDrop());
}
//根据层数判断生成传送门
private Cell createTransport(int floor){
int transportPoint;
//是否为5层整数倍
if(floor%2==0){
if(floor%2==0&&floor<10000){
//如果是则进行随机
int[] treasureProbability = STrialSetting.sTrialSetting.getTreasureProbability();
int[] transportPointId= STrialSetting.sTrialSetting.getTransportPoint();
@ -411,4 +430,70 @@ public class TowerMap extends AbstractMap {
LOGGER.info("生成传送门信息:{}",createCell.toString());
return createCell;
}
private Cell callChief(User user) throws Exception {
MapManager mapManager = user.getMapManager();
// LOGGER.info("进入召唤boss");
if(mapManager.getTrialInfo().getEnergy()<100){
throw new ErrorCodeException(ErrorCode.newDefineCode("精气值不足!!"));
}
int currTower = mapManager.getTrialInfo().getFloor();
STrialConfig config = STrialConfig.sTrialConfigMap.get(currTower);
int type = 1;
int[][] bossType = config.getRandomBossType();
type = MathUtils.randomFromWeight(bossType);
// if(mapManager.getTrialInfo().getFloor()%5!=0){
// type = 3;
// }
LOGGER.info("trigger!!!!!!!!!!!!!!!!!-------->{},{}",CellUtil.pos2XY(mapManager.getCurXY())[0],CellUtil.pos2XY(mapManager.getCurXY())[1]);
int[][][] pointId = config.getRandomMapPointId();
int mapId = config.getMapId();
SChallengeMapConfig challengeMapConfig = STableManager.getConfig(SChallengeMapConfig.class).get(mapId);
int[] mapSize = challengeMapConfig.getSize();
// LOGGER.info("width:{},height:{},当前:{}==={}",String.valueOf(mapSize[0]),String.valueOf(mapSize[1]),CellUtil.pos2XY(mapManager.getCurXY())[0],CellUtil.pos2XY(mapManager.getCurXY())[1]);
Set<Integer> xySet = CellUtil.getSurroundPos(mapSize[0],mapSize[1],mapManager.getCurXY());
LOGGER.info(xySet.toString());
Map<Integer, Cell> mapInfo = mapManager.getMapInfo();
MapLogic.getInstance().clearNormalMonster(user);
Iterator<Integer> it = xySet.iterator();
Map<Integer, MapPointConfig> pointConfig = MapPointConfig.scMapEventMap;
while (it.hasNext()){
Integer n = it.next();
// LOGGER.info("遍历{},{}",CellUtil.pos2XY(n)[0],CellUtil.pos2XY(n)[1]);
for(Map.Entry<Integer,Cell> cellEntry:mapInfo.entrySet()){
if(cellEntry.getKey().equals(n)) {
if (pointConfig.get(cellEntry.getValue().getPointId()).getStyle() != 0) {
it.remove();
break;
}
}
}
}
// LOGGER.info("怪物可出现格子数量{}",String.valueOf(xySet.size()));
// int random = MathUtils.randomInt(xySet.size());
// LOGGER.info("random"+String.valueOf(random));
// int xyResult = 0;
// for(Integer xy:xySet){
//// LOGGER.info("怪物位置:{},{}",String.valueOf(CellUtil.pos2XY(xy)[0]),String.valueOf(CellUtil.pos2XY(xy)[1]));
// if(random==i){
// xyResult = xy;
// break;
// }
// i++;
// }
//更改成固定boss位置
int[] bossPosition = STrialSetting.sTrialSetting.getBossPosition();
mapManager.setBossType(type);
mapManager.setBossXY(CellUtil.xy2Pos(bossPosition[0],bossPosition[1]));
mapManager.setTrialEnergy(-1);
int randomPoint = MathUtils.randomFromWeight(pointId[type-1]);
// LOGGER.info("随机事件id==>{}",randomPoint);
Cell cell = BehaviorUtil.addBehaviorInfo(user, randomPoint, mapManager, mapManager.getCurMapId(), bossPosition[0], bossPosition[1], false);
return cell;
}
}

View File

@ -66,12 +66,16 @@ public class ActivityLogic implements IEventHandler{
public void flushEveryDay(User user, PlayerInfoProto.FivePlayerUpdateIndication.Builder fBuilder) throws Exception {
//跟新签到天数
if (user.getPlayerInfoManager().getOffLineTime()!=0&&!TimeUtils.isSameMonthFiveWithNow(user.getPlayerInfoManager().getOffLineTime())) {
user.getPlayerInfoManager().setSign(0);
user.getPlayerInfoManager().setSignTotay(0);
} else if (user.getPlayerInfoManager().getSignTotay() == 1) {
if (user.getPlayerInfoManager().getSignTotay() == 1) {
user.getPlayerInfoManager().setSign(user.getPlayerInfoManager().getSign() + 1);
user.getPlayerInfoManager().setSignTotay(0);
if (user.getPlayerInfoManager().getOffLineTime()!=0){
if(user.getPlayerInfoManager().getSign()>=SSignInConfig.getsSignInConfigMap().size()){
user.getPlayerInfoManager().setSign(0);
user.getPlayerInfoManager().setSignTotay(0);
}
}
}
//更新每日充值
ActivityLogic.getInstance().resumeActivity(user, ActivityType.DAILY_RECHARGE);

View File

@ -10,8 +10,6 @@ public class SSignInConfig implements BaseConfig {
private int id;
private int month;
private int day;
private int[] reward;
@ -32,10 +30,6 @@ public class SSignInConfig implements BaseConfig {
return id;
}
public int getMonth() {
return month;
}
public int getDay() {
return day;
}

View File

@ -64,6 +64,8 @@ public class STrialConfig implements BaseConfig {
private int eliteEnergy;
private int[][] randomStore;
private int[] monsterPoint;
/**
*
*/
@ -128,4 +130,8 @@ public class STrialConfig implements BaseConfig {
public int[][] getBoxPosition() {
return boxPosition;
}
public int[] getMonsterPoint() {
return monsterPoint;
}
}

View File

@ -0,0 +1,69 @@
package config;
import manager.STableManager;
import manager.Table;
import java.util.HashMap;
import java.util.Map;
@Table(name ="TrialwelfareConfig")
public class STrialwelfareConfig implements BaseConfig {
private int id;
private int[] section;
private int mapId;
private int[][] randomMonsterType;
private int[] monsterCount;
private int[][][] boxReward;
private int[][] boxPosition;
public static Map<Integer,STrialwelfareConfig> sTrialwelfareConfigMap = new HashMap<>();
@Override
public void init() throws Exception {
Map<Integer, STrialwelfareConfig> config = STableManager.getConfig(STrialwelfareConfig.class);
for(STrialwelfareConfig value:config.values()){
int[] section = value.getSection();
for(int i = section[0];i <= section[1];i++){
sTrialwelfareConfigMap.put(i,value);
}
}
}
public int getId() {
return id;
}
public int[] getSection() {
return section;
}
public int getMapId() {
return mapId;
}
public int[][] getRandomMonsterType() {
return randomMonsterType;
}
public int[] getMonsterCount() {
return monsterCount;
}
public int[][][] getBoxReward() {
return boxReward;
}
public int[][] getBoxPosition() {
return boxPosition;
}
}