new fight

back_recharge
wangyuan 2019-09-27 10:18:38 +08:00
parent 9357d3e802
commit 405ab16ed0
23 changed files with 275 additions and 525 deletions

View File

@ -6,9 +6,7 @@ import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import com.ljsd.jieling.util.TimeUtils;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.*;
@Table(name ="GlobalSystemConfig")
public class SGlobalSystemConfig implements BaseConfig {
@ -40,9 +38,13 @@ public class SGlobalSystemConfig implements BaseConfig {
private int type;
private int[][] openGifts;
private static Map<Integer,SGlobalSystemConfig> sGlobalSystemConfigMap;
public static Map<Integer,Map<Integer, List<SGlobalSystemConfig>>> sGlobalSystemConfigMapByTypeAndConditionMap;
@Override
public void init() throws Exception {
@ -50,6 +52,7 @@ public class SGlobalSystemConfig implements BaseConfig {
return;
}
Map<Integer, SGlobalSystemConfig> config = STableManager.getConfig(SGlobalSystemConfig.class);
Map<Integer,Map<Integer, List<SGlobalSystemConfig>>> sGlobalSystemConfigMapByTypeAndConditionMapTmp = new HashMap<>();
Iterator<Map.Entry<Integer, SGlobalSystemConfig>> iterator = config.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry<Integer, SGlobalSystemConfig> next = iterator.next();
@ -69,9 +72,21 @@ public class SGlobalSystemConfig implements BaseConfig {
sGlobalSystemConfig.setSystemOpenLong(TimeUtils.parseTimeToMiles(sGlobalSystemConfig.getSystemOpen(), TimeUtils.Stand_CeHua_Data_format));
sGlobalSystemConfig.setSystemEndLong(TimeUtils.parseTimeToMiles(sGlobalSystemConfig.getSystemEnd(), TimeUtils.Stand_CeHua_Data_format));
int[] openRules = sGlobalSystemConfig.getOpenRules();
int openType = openRules[0];
int openCondition = openRules[1];
if(!sGlobalSystemConfigMapByTypeAndConditionMapTmp.containsKey(openType)){
sGlobalSystemConfigMapByTypeAndConditionMapTmp.put(openType,new HashMap<>());
}
if(!sGlobalSystemConfigMapByTypeAndConditionMapTmp.get(openType).containsKey(openCondition)){
sGlobalSystemConfigMapByTypeAndConditionMapTmp.get(openType).put(openCondition,new ArrayList<>());
}
sGlobalSystemConfigMapByTypeAndConditionMapTmp.get(openType).get(openCondition).add(sGlobalSystemConfig);
}
sGlobalSystemConfigMap = config;
sGlobalSystemConfigMapByTypeAndConditionMap = sGlobalSystemConfigMapByTypeAndConditionMapTmp;
}
public static SGlobalSystemConfig getsGlobalSystemConfigByFunctionId(FunctionIdEnum workShop) {
@ -151,4 +166,8 @@ public class SGlobalSystemConfig implements BaseConfig {
public int getType() {
return type;
}
public int[][] getOpenGifts() {
return openGifts;
}
}

View File

@ -1,120 +0,0 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import com.ljsd.jieling.logic.dao.LevelDifficulty;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Table(name ="LevelDifficultyConfig")
public class SLevelDifficultyConfig implements BaseConfig {
private static Map<Integer, SLevelDifficultyConfig> sLevelDifficultyConfigMap;
private static Map<Integer, LevelDifficulty> levelDifficultyMap;
private int id;
private int precondition;
private int levelLimit;
private int monsterGroup;
private int[][] cost;
private int[][] preLevelCost;
private int money;
private int exp;
private int[] randomReward;
private int rankTime;
private int maxCountPerDay;
private int recommendFightAbility;
private int[] firstReward;
@Override
public void init() throws Exception {
sLevelDifficultyConfigMap = STableManager.getConfig(SLevelDifficultyConfig.class);
Map<Integer, LevelDifficulty> levelDifficultyMap = new ConcurrentHashMap<>();
for (Map.Entry<Integer, SLevelDifficultyConfig> entry : sLevelDifficultyConfigMap.entrySet()) {
String fightId = String.valueOf(entry.getKey());
int length = fightId.length();
int areaId = Integer.parseInt(fightId)/1000;
int type = Integer.parseInt(fightId.substring(length - 1, length));
LevelDifficulty levelDifficulty = new LevelDifficulty();
levelDifficulty.setAreaId(areaId);
levelDifficulty.setFightId(Integer.parseInt(fightId));
levelDifficulty.setType(type);
levelDifficultyMap.put(entry.getKey(),levelDifficulty);
levelDifficultyMap.put(entry.getKey(),levelDifficulty);
}
SLevelDifficultyConfig.levelDifficultyMap = levelDifficultyMap;
}
public int getId() {
return id;
}
public int getPrecondition() {
return precondition;
}
public int getLevelLimit() {
return levelLimit;
}
public int getMonsterGroup() {
return monsterGroup;
}
public int[][] getCost() {
return cost;
}
public int[][] getPreLevelCost() {
return preLevelCost;
}
public int getMoney() {
return money;
}
public int getExp() {
return exp;
}
public int[] getRandomReward() {
return randomReward;
}
public int getRankTime() {
return rankTime;
}
public int getMaxCountPerDay() {
return maxCountPerDay;
}
public int getRecommendFightAbility() {
return recommendFightAbility;
}
public int[] getFirstReward() {
return firstReward;
}
public static Map<Integer, SLevelDifficultyConfig> getsLevelDifficultyConfigMap() {
return sLevelDifficultyConfigMap;
}
public static Map<Integer, LevelDifficulty> getLevelDifficultyMap() {
return levelDifficultyMap;
}
}

View File

@ -95,4 +95,8 @@ public class SMainLevelConfig implements BaseConfig {
public int getNextLevel() {
return nextLevel;
}
public int getDifficulty() {
return difficulty;
}
}

View File

@ -9,7 +9,7 @@ import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.GlobalDataManaager;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.dao.LevelDifficulty;
import com.ljsd.jieling.logic.dao.MainLevelManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.mission.event.MissionEventDistributor;
@ -299,11 +299,11 @@ public class HandlerLogicThread extends Thread{
}
int level = user.getPlayerInfoManager().getLevel();
int workShopLevel = user.getWorkShopController().getWorkShopLevel();
Map<Integer, LevelDifficulty> levelDifficultyInfosMap = user.getLevelDifficultyManager().getLevelDifficultyInfosMap();
MainLevelManager mainLevelManager = user.getMainLevelManager();
int type = sGlobalSystemConfig.getOpenRules()[0];
int condition = sGlobalSystemConfig.getOpenRules()[1];
if (type ==1){
if (!levelDifficultyInfosMap.containsKey(condition) || levelDifficultyInfosMap.containsKey(condition) && levelDifficultyInfosMap.get(condition).getState() != Global.FIGHT_CLEARANCE) {
if (mainLevelManager.getFightId()>condition) {
return true;
}
}else if(type == 2){

View File

@ -4,6 +4,7 @@ public interface VipPrivilegeType {
int ADVENTURE_BASE_REWARD = 1;//探险基础奖励收益
int ADVENTURE_MINERAL_REWARD = 2;//探险矿石奖励收益
int ADVENTURE_RUNNE_REWARD = 3;//探险符文奖励收益
int ADVENTURE_EXP_REWARD = 27;//探险符文奖励收益
int FAST_MAP_LIMIT = 4;//快速探险的次数上限
int BUY_STAIM_LIMIT = 5;//购买体力次数上限

View File

@ -86,6 +86,8 @@ public interface BIReason {
int MAIN_LEVEL_STATE_REWARD = 53; // 关卡挂机奖励
int SYSTERM_OPEN_REWARD = 54; //系统开放奖励
//道具消耗原因 1000开头
int ADVENTURE_UPLEVEL_CONSUME = 1000; //秘境升级

View File

@ -131,15 +131,18 @@ public class GMRequestHandler extends BaseHandler{
ItemUtil.userLevelUp(cUser,exp);
break;
case GlobalGm.ADOPT_ALL_DIFFICULTY:
sPlayerLevelConfigMap = SPlayerLevelConfig.getsPlayerLevelConfigMap();
LevelDifficultyManager levelDifficultyManager = cUser.getLevelDifficultyManager();
openFightids(levelDifficultyManager,sPlayerLevelConfigMap.size());
adoptAllFight(cUser,levelDifficultyManager);
break;
while (true){
int fightId = cUser.getMainLevelManager().getFightId();
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
if(sMainLevelConfig.getNextLevel() != -1){
MapLogic.getInstance().openNextMainLevel(cUser,fightId);
}else{
break;
}
}
case GlobalGm.ADOPT_FIGHT_BY_LEVE:
levelDifficultyManager = cUser.getLevelDifficultyManager();
openFightids(levelDifficultyManager,prarm1);
adoptAllFight(cUser,levelDifficultyManager);
break;
case GlobalGm.ONE_KEY_ITEM_OR_HERO:{
//道具
@ -262,32 +265,12 @@ public class GMRequestHandler extends BaseHandler{
}
}
private void adoptAllFight(User user,LevelDifficultyManager levelDifficultyManager) throws Exception {
Map<Integer, LevelDifficulty> levelDifficultyInfosMap = levelDifficultyManager.getLevelDifficultyInfosMap();
for (Map.Entry<Integer,LevelDifficulty> entry :levelDifficultyInfosMap.entrySet()){
entry.getValue().setState(Global.FIGHT_CLEARANCE);
user.getUserMissionManager().onGameEvent(user, GameEvent.STORY_FIGHT, entry.getValue().getFightId(),0,1);
}
}
private String parseTimeToString(long time){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return simpleDateFormat.format(time);
}
//开启所有关卡
private void openFightids(LevelDifficultyManager levelDifficultyManager,int level) {
Map<Integer, LevelDifficulty> levelDifficultyMap = SLevelDifficultyConfig.getLevelDifficultyMap();
for (Map.Entry<Integer,LevelDifficulty> entry :levelDifficultyMap.entrySet()){
LevelDifficulty levelDifficulty = entry.getValue();
SLevelDifficultyConfig sLevelDifficultyConfig = SLevelDifficultyConfig.getsLevelDifficultyConfigMap().get(entry.getKey());
if (sLevelDifficultyConfig.getLevelLimit() > level){
continue;
}
levelDifficultyManager.newLevelDifficulty(levelDifficulty.getFightId(),levelDifficulty.getType(),levelDifficulty.getAreaId());
}
}
private CommonProto.Drop.Builder giveHero(User cUser, int cardId, int cardNum) throws Exception {
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
Map<Integer,Integer> cardMap = new ConcurrentHashMap<>();

View File

@ -19,8 +19,10 @@ import com.ljsd.jieling.ktbeans.KtEventUtils;
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
import com.ljsd.jieling.logic.GlobalDataManaager;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.event.FightMainEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.activity.event.StoryEvent;
import com.ljsd.jieling.logic.activity.event.UserLevelEvent;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.fight.CheckFight;
@ -142,12 +144,9 @@ public class MapLogic {
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "需要等级:" + openRule[0][1]);
return;
}
LevelDifficulty levelDifficulty = user.getLevelDifficultyManager().getLevelDifficultyInfosMap().get(openRule[0][0]);
if (levelDifficulty == null || levelDifficulty.getState() != 4) {
if (user.getPlayerInfoManager().getLevel() < openRule[0][1]) {
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "需要通关:" + openRule[0][0]);
return;
}
if(user.getMainLevelManager().getFightId()>openRule[0][0]){
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "需要通关:" + openRule[0][0]);
return;
}
}
@ -1985,97 +1984,6 @@ public class MapLogic {
}
/**
*
*
* @param iSession
* @param msgId
*/
public void getAllLevelDifficultyInfos(ISession iSession, int msgId) throws Exception {
int uid = iSession.getUid();
User user = UserManager.getUser(uid);
LevelDifficultyManager levelDifficultyManager = user.getLevelDifficultyManager();
Map<Integer, LevelDifficulty> levelDifficultyInfosMap = levelDifficultyManager.getLevelDifficultyInfosMap();
if (levelDifficultyInfosMap.size() == 0) {
levelDifficultyInfosMap = initLevelDifficultyInfo(user, levelDifficultyManager);
}
List<Integer> getOpenAreaIds = levelDifficultyManager.getOpenAreaIds();
List<CommonProto.LevelDifficultyInfos> levelDifficultyInfos = new CopyOnWriteArrayList<>();
for (Integer areaId : getOpenAreaIds) {
CommonProto.LevelDifficultyInfos.Builder levelDifficultyInfosBuilder = CommonProto.LevelDifficultyInfos.newBuilder();
levelDifficultyInfosBuilder.setAreaId(areaId);
List<CommonProto.LevelDifficulty> builderList = new CopyOnWriteArrayList<>();
for (Map.Entry<Integer, LevelDifficulty> entry : levelDifficultyInfosMap.entrySet()) {
LevelDifficulty levelDifficulty = entry.getValue();
if (levelDifficulty.getAreaId() != areaId) {
continue;
}
CommonProto.LevelDifficulty.Builder lLevelDifficultyBuilder = CommonProto.LevelDifficulty.newBuilder();
lLevelDifficultyBuilder.setFightId(levelDifficulty.getFightId());
lLevelDifficultyBuilder.setState(levelDifficulty.getState());
lLevelDifficultyBuilder.setNum(levelDifficulty.getChallengeTimes());
lLevelDifficultyBuilder.setType(levelDifficulty.getType());
builderList.add(lLevelDifficultyBuilder.build());
}
levelDifficultyInfosBuilder.addAllLevelDifficulty(builderList);
levelDifficultyInfos.add(levelDifficultyInfosBuilder.build());
}
MapInfoProto.getAllLevelDifficultyInfosResponse.Builder builder = MapInfoProto.getAllLevelDifficultyInfosResponse.newBuilder();
builder.addAllLevelDifficultyInfos(levelDifficultyInfos);
MapManager mapManager = user.getMapManager();
Map<Integer, CrossInfo> crossInfoMap = mapManager.getCrossInfoMap();
for (Map.Entry<Integer, CrossInfo> entry : crossInfoMap.entrySet()) {
CommonProto.MapInfo mapInfo = CommonProto.MapInfo
.newBuilder()
.setMapId(entry.getKey())
.setLeastTime(entry.getValue().getLeastTime())
.addAllStars(entry.getValue().getStars())
.build();
builder.addMapInfos(mapInfo);
}
int starReward = mapManager.getStarReward();
SChallengeStarBox sChallengeStarBox = SChallengeStarBox.sChallengeStarBoxMap.get(starReward);
if(sChallengeStarBox == null ){
builder.setStarNum(0);
}else{
builder.setStarNum(sChallengeStarBox.getStarNum());
}
MapInfoProto.TowerCopyInfo towerCopyInfo = MapInfoProto.TowerCopyInfo.newBuilder()
.setTower(mapManager.getTower())
.setFightCount(mapManager.getFightCount())
.setHighestTower(mapManager.getHighestTower())
.setEssenceValue(mapManager.getEssenceValue())
.setMapIntoReset(mapManager.getMapIntoFlag())
.setTowerUseTime((int)(mapManager.getCurrTowerTime()/1000))
.build();
builder.setTowerCopyInfo(towerCopyInfo);
builder.addAllPlayedGenMapId(mapManager.getPlayGenMaps());
for(Map.Entry<Integer,Integer> entry:mapManager.getDifficultyOptions().entrySet()){
MapInfoProto.DifficultMapOption.Builder difficultMapOption = MapInfoProto.DifficultMapOption.newBuilder();
difficultMapOption.setId(entry.getKey());
difficultMapOption.setMapdifficulty(entry.getValue());
builder.addDifficultMapOptions(difficultMapOption);
}
// LOGGER.info("关卡信息{}",towerCopyInfo.toString());
MessageUtil.sendMessage(iSession, 1, msgId, builder.build(), true);
}
private Map<Integer, LevelDifficulty> initLevelDifficultyInfo(User user, LevelDifficultyManager levelDifficultyManager) {
Map<Integer, LevelDifficulty> levelDifficultyMap = SLevelDifficultyConfig.getLevelDifficultyMap();
for (Map.Entry<Integer, LevelDifficulty> entry : levelDifficultyMap.entrySet()) {
LevelDifficulty levelDifficulty = entry.getValue();
int fightId = levelDifficulty.getFightId();
SLevelDifficultyConfig sLevelDifficultyConfig = SLevelDifficultyConfig.getsLevelDifficultyConfigMap().get(fightId);
if (sLevelDifficultyConfig.getPrecondition() != 0 || sLevelDifficultyConfig.getLevelLimit() > user.getPlayerInfoManager().getLevel()) {
continue;
}
levelDifficultyManager.newLevelDifficulty(fightId, levelDifficulty.getType(), levelDifficulty.getAreaId());
}
return levelDifficultyManager.getLevelDifficultyInfosMap();
}
//挑战精英怪
public void startSuddlenlyFight(ISession session, int teamId, MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid();
@ -2143,24 +2051,53 @@ public class MapLogic {
public int[][] getCost(SLevelDifficultyConfig sLevelDifficultyConfig, int sweepTimes) {
StringBuilder cost = new StringBuilder();
int[][] costArr = sLevelDifficultyConfig.getCost();
int[][] preLevelCostArr = sLevelDifficultyConfig.getPreLevelCost();
for (int i = 0; i < costArr.length; i++) {
int[] ints = costArr[i];
int[] ints1 = preLevelCostArr[i];
int itemNum = ints[1] * sweepTimes + ints1[1] * sweepTimes;
if (cost.length() == 0) {
cost = new StringBuilder(ints[0] + "#" + itemNum);
} else {
cost.append("|").append(ints[0]).append("#").append(itemNum);
}
/**
*
*
* @param iSession
* @param msgId
*/
public void getAllLevelDifficultyInfos(ISession iSession, int msgId) throws Exception {
int uid = iSession.getUid();
User user = UserManager.getUser(uid);
MapInfoProto.getAllLevelDifficultyInfosResponse.Builder builder = MapInfoProto.getAllLevelDifficultyInfosResponse.newBuilder();
MapManager mapManager = user.getMapManager();
Map<Integer, CrossInfo> crossInfoMap = mapManager.getCrossInfoMap();
for (Map.Entry<Integer, CrossInfo> entry : crossInfoMap.entrySet()) {
CommonProto.MapInfo mapInfo = CommonProto.MapInfo
.newBuilder()
.setMapId(entry.getKey())
.setLeastTime(entry.getValue().getLeastTime())
.addAllStars(entry.getValue().getStars())
.build();
builder.addMapInfos(mapInfo);
}
return StringUtil.parseFiledInt2(cost.toString());
}
int starReward = mapManager.getStarReward();
SChallengeStarBox sChallengeStarBox = SChallengeStarBox.sChallengeStarBoxMap.get(starReward);
if(sChallengeStarBox == null ){
builder.setStarNum(0);
}else{
builder.setStarNum(sChallengeStarBox.getStarNum());
}
MapInfoProto.TowerCopyInfo towerCopyInfo = MapInfoProto.TowerCopyInfo.newBuilder()
.setTower(mapManager.getTower())
.setFightCount(mapManager.getFightCount())
.setHighestTower(mapManager.getHighestTower())
.setEssenceValue(mapManager.getEssenceValue())
.setMapIntoReset(mapManager.getMapIntoFlag())
.setTowerUseTime((int)(mapManager.getCurrTowerTime()/1000))
.build();
builder.setTowerCopyInfo(towerCopyInfo);
builder.addAllPlayedGenMapId(mapManager.getPlayGenMaps());
for(Map.Entry<Integer,Integer> entry:mapManager.getDifficultyOptions().entrySet()){
MapInfoProto.DifficultMapOption.Builder difficultMapOption = MapInfoProto.DifficultMapOption.newBuilder();
difficultMapOption.setId(entry.getKey());
difficultMapOption.setMapdifficulty(entry.getValue());
builder.addDifficultMapOptions(difficultMapOption);
}
MessageUtil.sendMessage(iSession, 1, msgId, builder.build(), true);
}
@ -2250,7 +2187,7 @@ public class MapLogic {
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true);
}
private void openNextMainLevel(User user,int fightId){
public void openNextMainLevel(User user,int fightId) throws Exception {
int level = user.getPlayerInfoManager().getLevel();
int state = 1;
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
@ -2258,7 +2195,24 @@ public class MapLogic {
if(sMainLevelConfig.getLevelLimit()>level){
state =-1;
}
user.getMainLevelManager().updateFight(sMainLevelConfig.getNextLevel(),state);
}else{
state =2;
}
user.getUserMissionManager().onGameEvent(user, GameEvent.STORY_FIGHT, fightId,0,1);
Poster.getPoster().dispatchEvent(new FightMainEvent(user.getId(),fightId));
user.getMainLevelManager().updateFight(sMainLevelConfig.getNextLevel(),state);
if(state == -1){
//删除为0的
Map<Integer, Integer> fightStateInfo = user.getMainLevelManager().getFightStateInfo();
Set<Integer> removeCache = new HashSet<>();
for(Map.Entry<Integer,Integer> item : fightStateInfo.entrySet()){
if(item.getValue()==0 && item.getKey()!=fightId){
removeCache.add(item.getKey());
}
}
for(Integer removeId : removeCache){
user.getMainLevelManager().removeFightStateInfo(removeId);
}
}
}
@ -2402,31 +2356,6 @@ public class MapLogic {
/**
*
*
* @param levelDifficultyManager
* @param fightId
*/
private void openNextFightIds(LevelDifficultyManager levelDifficultyManager, PlayerManager playerInfoManager, int fightId) {
Map<Integer, LevelDifficulty> levelDifficultyMap = SLevelDifficultyConfig.getLevelDifficultyMap();
Map<Integer, LevelDifficulty> levelDifficultyInfosMap = levelDifficultyManager.getLevelDifficultyInfosMap();
for (Map.Entry<Integer, LevelDifficulty> entry : levelDifficultyMap.entrySet()) {
LevelDifficulty levelDifficulty = entry.getValue();
int id = levelDifficulty.getFightId();
SLevelDifficultyConfig sLevelDifficultyConfig = SLevelDifficultyConfig.getsLevelDifficultyConfigMap().get(id);
if (levelDifficultyInfosMap.containsKey(id)) {
continue;
}
if (sLevelDifficultyConfig.getPrecondition() != fightId) {
continue;
}
levelDifficultyManager.newLevelDifficulty(id, levelDifficulty.getType(), levelDifficulty.getAreaId());
}
}
public void gmCrossFight(int uid, int arrayMapId) throws Exception {
User user = UserManager.getUser(uid);

View File

@ -1,26 +1,15 @@
package com.ljsd.jieling.handler.map;
import com.ljsd.jieling.config.SLevelDifficultyConfig;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.handler.map.behavior.BaseBehavior;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.FightInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.CBean2Proto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import com.ljsd.jieling.util.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ConfigurableApplicationContext;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.HashMap;
import java.util.Map;
public class SweepLogic {
@ -59,55 +48,6 @@ public class SweepLogic {
* @param fightId
* @param sweepTimes
*/
public void sweepFight(ISession session, int fightId, int sweepTimes,int targetItem,int targetNum,MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
LevelDifficultyManager levelDifficultyManager = user.getLevelDifficultyManager();
LevelDifficulty levelDifficulty = levelDifficultyManager.getLevelDifficultyInfosMap().get(fightId);
if (levelDifficulty.getState() != Global.FIGHT_CLEARANCE){
LOGGER.info("startLevelDifficultyFight==> uid={},fightId, levelDifficulty is null ",uid,fightId);
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "该地图未通关");
return;
}
SLevelDifficultyConfig sLevelDifficultyConfig = SLevelDifficultyConfig.getsLevelDifficultyConfigMap().get(fightId);
if (sLevelDifficultyConfig.getMaxCountPerDay() != 0 && levelDifficulty.getChallengeTimes() +sweepTimes > sLevelDifficultyConfig.getMaxCountPerDay()){
LOGGER.info("startLevelDifficultyFight==>uid={},fightId={} challengeTimes={},MaxTime={}",uid,fightId,levelDifficulty.getChallengeTimes(),sLevelDifficultyConfig.getMaxCountPerDay());
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "次数不足");
return;
}
int[][] cost = MapLogic.getInstance().getCost(sLevelDifficultyConfig, sweepTimes);
boolean flag = ItemUtil.fightItemCost(user,cost);
if (!flag){
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "道具不足");
return;
}
boolean change = false;
List<CommonProto.Drop> dropList = new CopyOnWriteArrayList<>();
for (int i = 0 ; i < sweepTimes ;i++){
if (targetItem!= 0){
Item item = user.getItemManager().getItem(targetItem);
if(item!=null && item.getItemNum()>=targetNum){
sweepTimes=i;
change = true;
break;
}
}
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sLevelDifficultyConfig.getRandomReward(), 1, 0, BIReason.LEVELDIFFICULTY_SWEEP_REWARD);
dropList.add(drop.build());
}
if(change){
cost = MapLogic.getInstance().getCost(sLevelDifficultyConfig, sweepTimes);
}
//扣除道具
ItemUtil.itemCost(user, cost,BIReason.SWEEP_FIGHT_CONSUME,fightId);
LOGGER.info("sweepFight=>uid={},sweepTimes={},exp={}",uid,sweepTimes,sLevelDifficultyConfig.getExp());
FightInfoProto.SweepRightResponse.Builder builder = FightInfoProto.SweepRightResponse.newBuilder();
builder.addAllDrop(dropList);
builder.setItemInfo(CBean2Proto.getItemInfo(user.getItemManager().getItemMap().get(Global.STAMINA)));
levelDifficulty.setChallengeTimes(levelDifficulty.getChallengeTimes() +sweepTimes);
user.getUserMissionManager().onGameEvent(user, GameEvent.STORY_FIGHT, fightId, 0,sweepTimes);
MessageUtil.sendMessage(session, 1, messageType.getNumber(), builder.build(), true);
public void sweepFight(ISession session, int fightId, int sweepTimes, int targetItem, int targetNum, MessageTypeProto.MessageType messageType) throws Exception {
}
}

View File

@ -12,6 +12,8 @@ import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.logic.activity.ActivityLogic;
import com.ljsd.jieling.logic.activity.FightMainEventHandler;
import com.ljsd.jieling.logic.activity.UserLevelEventHandler;
import com.ljsd.jieling.logic.arena.ArenaLogic;
import com.ljsd.jieling.logic.blood.BloodLogic;
import com.ljsd.jieling.logic.dao.*;
@ -231,6 +233,8 @@ public class GlobalDataManaager {
StoreLogic.checkGlobalStore(true);
new RPCServerTask(configurableApplicationContext).start();
new RPCGmServerTask(configurableApplicationContext).start();
new UserLevelEventHandler();
new FightMainEventHandler();
} catch (Exception e) {
LOGGER.error("e",e);
}
@ -379,6 +383,7 @@ public class GlobalDataManaager {
for(int i = 0 ; i <size;i++){
level+=users.get(i).getPlayerInfoManager().getLevel();
}
LOGGER.info("计算世界等级为{}",level/size);
return level/size;
}

View File

@ -1,13 +1,10 @@
package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.config.SActivityRewardConfig;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.logic.dao.ActivityProgressInfo;
import com.ljsd.jieling.logic.dao.LevelDifficulty;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.util.MessageUtil;
class ChapterRewardActivity extends AbstractActivity {
@ -19,10 +16,6 @@ class ChapterRewardActivity extends AbstractActivity {
boolean takeRewardsProcess(ISession session, SActivityRewardConfig sActivityRewardConfig, ActivityProgressInfo activityProgressInfo) throws Exception {
int[][] values = sActivityRewardConfig.getValues();
User user = UserManager.getUser(session.getUid());
LevelDifficulty levelDifficulty = user.getLevelDifficultyManager().getLevelDifficultyInfosMap().get(values[0][0]);
if (levelDifficulty == null || levelDifficulty.getState() != Global.FIGHT_CLEARANCE) {
return false;
}
return true;
return user.getMainLevelManager().getFightId()>values[0][0];
}
}

View File

@ -0,0 +1,47 @@
package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.config.SGlobalActivity;
import com.ljsd.jieling.config.SGlobalSystemConfig;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.logic.activity.event.FightMainEvent;
import com.ljsd.jieling.logic.activity.event.GoldEvent;
import com.ljsd.jieling.logic.activity.event.IEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.util.ItemUtil;
import java.util.List;
public class FightMainEventHandler implements IEventHandler{
public FightMainEventHandler() {
Poster.getPoster().listenEvent(this, FightMainEvent.class);
}
@Override
public void onEvent(IEvent event) throws Exception {
if (!(event instanceof FightMainEvent))
return;
FightMainEvent fightMainEvent = (FightMainEvent) event;
int fightId = fightMainEvent.getFightId();
List<SGlobalSystemConfig> sGlobalSystemConfigs = SGlobalSystemConfig.sGlobalSystemConfigMapByTypeAndConditionMap.get(1).get(fightId);
if(sGlobalSystemConfigs == null){
return;
}
for(SGlobalSystemConfig sGlobalSystemConfig : sGlobalSystemConfigs){
int[][] openGifts = sGlobalSystemConfig.getOpenGifts();
if(openGifts!=null && openGifts.length>0){
int uid = fightMainEvent.getUid();
User user = UserManager.getUser(uid);
ItemUtil.drop(user,openGifts, BIReason.SYSTERM_OPEN_REWARD);
}
}
}
}

View File

@ -3,12 +3,9 @@ package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.config.SActivityRewardConfig;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.logic.dao.ActivityProgressInfo;
import com.ljsd.jieling.logic.dao.LevelDifficulty;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.util.MessageUtil;
class GrowthFundActivity extends AbstractActivity {
public GrowthFundActivity(int id) {
@ -27,10 +24,7 @@ class GrowthFundActivity extends AbstractActivity {
return false;
}
}else if(type == 15){
LevelDifficulty levelDifficulty = user.getLevelDifficultyManager().getLevelDifficultyInfosMap().get(value);
if(levelDifficulty == null || levelDifficulty.getState()!= Global.FIGHT_CLEARANCE){
return false;
}
return user.getMainLevelManager().getFightId()>value;
}
return true;
}

View File

@ -0,0 +1,39 @@
package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.config.SGlobalSystemConfig;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.logic.activity.event.FightMainEvent;
import com.ljsd.jieling.logic.activity.event.IEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.activity.event.UserLevelEvent;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.util.ItemUtil;
import java.util.List;
public class UserLevelEventHandler implements IEventHandler{
public UserLevelEventHandler() {
Poster.getPoster().listenEvent(this, UserLevelEvent.class);
}
@Override
public void onEvent(IEvent event) throws Exception {
if (!(event instanceof UserLevelEvent))
return;
UserLevelEvent userLevelEvent = (UserLevelEvent) event;
int level = userLevelEvent.getLevel();
List<SGlobalSystemConfig> sGlobalSystemConfigs = SGlobalSystemConfig.sGlobalSystemConfigMapByTypeAndConditionMap.get(2).get(level);
if(sGlobalSystemConfigs == null){
return;
}
for(SGlobalSystemConfig sGlobalSystemConfig : sGlobalSystemConfigs){
int[][] openGifts = sGlobalSystemConfig.getOpenGifts();
if(openGifts!=null && openGifts.length>0){
int uid = userLevelEvent.getUid();
User user = UserManager.getUser(uid);
ItemUtil.drop(user,openGifts, BIReason.SYSTERM_OPEN_REWARD);
}
}
}
}

View File

@ -0,0 +1,20 @@
package com.ljsd.jieling.logic.activity.event;
public class FightMainEvent implements IEvent {
private int uid;
private int fightId;
public FightMainEvent(int uid, int fightId) {
this.uid = uid;
this.fightId = fightId;
}
public int getUid() {
return uid;
}
public int getFightId() {
return fightId;
}
}

View File

@ -0,0 +1,19 @@
package com.ljsd.jieling.logic.activity.event;
public class UserLevelEvent implements IEvent {
private int uid;
private int level;
public UserLevelEvent(int uid, int level) {
this.uid = uid;
this.level = level;
}
public int getUid() {
return uid;
}
public int getLevel() {
return level;
}
}

View File

@ -1,77 +0,0 @@
package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.logic.dao.root.User;
public class LevelDifficulty extends MongoBase {
private int areaId;
private int fightId;
private int state; //2 已开启 3:已打过未通过,=4已通过.
private int challengeTimes;
private int type; //1:简单 2:中等 3:困难
public LevelDifficulty(){
//绑定关系
// this.setRootCollection(User._COLLECTION_NAME);
}
public LevelDifficulty(int fightId,int type,int areaId){
this.setRootCollection(User._COLLECTION_NAME);
this.areaId = areaId;
this.fightId = fightId;
this.state = Global.FIGHT_OPEND;
this.challengeTimes = 0;
this.type = type;
}
public void setFightId(int fightId) {
updateString("fightId", fightId);
this.fightId = fightId;
}
public void setState(int state) {
updateString("state", state);
this.state = state;
}
public void setChallengeTimes(int challengeTimes) {
updateString("challengeTimes", challengeTimes);
this.challengeTimes = challengeTimes;
}
public void setType(int type) {
updateString("type", type);
this.type = type;
}
public void setAreaId(int areaId) {
updateString("areaId", areaId);
this.areaId = areaId;
}
public int getFightId() {
return fightId;
}
public int getState() {
return state;
}
public int getChallengeTimes() {
return challengeTimes;
}
public int getType() {
return type;
}
public int getAreaId() {
return areaId;
}
}

View File

@ -1,48 +0,0 @@
package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
public class LevelDifficultyManager extends MongoBase {
private Map<Integer,LevelDifficulty> levelDifficultyInfosMap = new ConcurrentHashMap<>();
private List<Integer> openAreaIds = new CopyOnWriteArrayList<>();
public void addLevelDifficulty(LevelDifficulty LevelDifficulty) {
LevelDifficulty.init(this.getRootId(), getMongoKey() + ".levelDifficultyInfosMap." + LevelDifficulty.getFightId());
updateString("levelDifficultyInfosMap." + LevelDifficulty.getFightId(), LevelDifficulty);
levelDifficultyInfosMap.put(LevelDifficulty.getFightId(), LevelDifficulty);
}
public Map<Integer, LevelDifficulty> getLevelDifficultyInfosMap() {
return levelDifficultyInfosMap;
}
public LevelDifficulty newLevelDifficulty(int fightId,int type,int areaId) {
LevelDifficulty levelDifficulty = new LevelDifficulty(fightId,type,areaId);
addLevelDifficulty(levelDifficulty);
addOpendAreaid(areaId);
return levelDifficulty;
}
public void setLevelDifficultyInfosMap(Map<Integer, LevelDifficulty> levelDifficultyInfosMap) {
this.levelDifficultyInfosMap = levelDifficultyInfosMap;
}
public List<Integer> getOpenAreaIds() {
return openAreaIds;
}
public void addOpendAreaid(int openAreaId) {
if (!this.openAreaIds.contains(openAreaId)){
this.openAreaIds.add(openAreaId);
updateString("openAreaIds" , openAreaIds);
}
}
}

View File

@ -30,11 +30,21 @@ public class MainLevelManager extends MongoBase {
int timeDuration = (int)(System.currentTimeMillis()/1000) - lastTime;
int times = timeDuration / adventureRefresh;
int mod = timeDuration % adventureRefresh;
int adventureOffline = gameSetting.getAdventureOffline()*60*60/adventureRefresh;
if(mod!=0){
times += 1;
startTime-=mod;
updateString("startTime",startTime);
}
if(times<1){
times=1;
startTime-=adventureRefresh;
updateString("startTime",startTime);
}
int adventurenTimes = ((int) (System.currentTimeMillis() / 1000) - lastTime) / SGameSetting.getGameSetting().getAdventureRefresh();
if(adventureOffline<=adventurenTimes){
times=0;
}
fightStateInfo.put(fightId,times);
updateString("fightStateInfo." + fightId,times);
@ -62,6 +72,11 @@ public class MainLevelManager extends MongoBase {
updateString("fightStateInfo",fightStateInfo);
}
public void removeFightStateInfo(int fightId){
fightStateInfo.remove(fightId);
removeString(getMongoKey()+"fightStateInfo."+fightId);
}
public void addBossGroup(String bossId){
if(!bossIds.containsKey(fightId)){
bossIds.put(fightId,new HashSet<>());
@ -70,15 +85,6 @@ public class MainLevelManager extends MongoBase {
updateString("bossIds." + fightId,bossIds);
}
public void removeBossGroup(String bossId){
bossIds.remove(bossId);
updateString("bossIds",bossIds);
}
public void removeMutBossGroup(Set<String> bossIdsTmp){
bossIds.clear();
updateString("bossIds",bossIds);
}
public int getFightId() {
return fightId;

View File

@ -30,8 +30,6 @@ public class User {
private WorkShopController workShopController;
private LevelDifficultyManager levelDifficultyManager; // 关卡信息
private ActivityManager activityManager;
private ArenaManager arenaManager;
@ -66,7 +64,6 @@ public class User {
this.equipManager = new EquipManager();
this.pokemonManager = new PokemonManager();
this.workShopController = new WorkShopController();
this.levelDifficultyManager = new LevelDifficultyManager();
this.activityManager = new ActivityManager();
this.arenaManager = new ArenaManager();
this.secretBoxManager = new SecretBoxManager();
@ -89,7 +86,6 @@ public class User {
this.equipManager.init(id, MongoKey.equipManager);
this.pokemonManager.init(id, MongoKey.pokemonManager);
this.workShopController.init(id, MongoKey.workShopController);
this.levelDifficultyManager.init(id, MongoKey.levelDifficultyManager);
this.activityManager.init(id, MongoKey.activityManager);
this.arenaManager.init(id, MongoKey.arenaManager);
this.secretBoxManager.init(id, MongoKey.secretBoxManager);
@ -174,14 +170,6 @@ public class User {
return workShopController;
}
public LevelDifficultyManager getLevelDifficultyManager() {
return levelDifficultyManager;
}
public void setLevelDifficultyManager(LevelDifficultyManager levelDifficultyManager) {
this.levelDifficultyManager = levelDifficultyManager;
}
public ActivityManager getActivityManager() {
return activityManager;
}

View File

@ -453,8 +453,8 @@ public class MissionLoigc {
count = cumulationData.getsEquipQualityCount()[missionSubType[0]-1];
break;
case LEVEL_STORY_PASS:
if(SLevelDifficultyConfig.getLevelDifficultyMap().containsKey(missionSubType[0])){
int type = SLevelDifficultyConfig.getLevelDifficultyMap().get(missionSubType[0]).getType();
if(SMainLevelConfig.config.containsKey(missionSubType[0])){
int type = SMainLevelConfig.config.get(missionSubType[0]).getDifficulty();
if(cumulationData.levlePassMap.containsKey(type)){
count =missionSubType[0] <=cumulationData.levlePassMap.get(type) ?1:0;
}

View File

@ -1,9 +1,8 @@
package com.ljsd.jieling.logic.mission.data;
import com.ljsd.jieling.config.SChallengeConfig;
import com.ljsd.jieling.config.SLevelDifficultyConfig;
import com.ljsd.jieling.config.SMainLevelConfig;
import com.ljsd.jieling.logic.dao.CumulationData;
import com.ljsd.jieling.logic.dao.LevelDifficulty;
import com.ljsd.jieling.logic.mission.MissionType;
public class FightDataManager implements BaseDataManager{
@ -18,8 +17,8 @@ public class FightDataManager implements BaseDataManager{
data.levelStoryTimes+=fightTimes;
result = new CumulationData.Result(missionType);
}else if(missionType == MissionType.LEVEL_STORY_PASS){
LevelDifficulty levelDifficulty = SLevelDifficultyConfig.getLevelDifficultyMap().get(fightId);
int type = levelDifficulty.getType();
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
int type = sMainLevelConfig.getDifficulty();
Integer maxFightId = data.levlePassMap.get(type);
if(maxFightId!=null){
if(fightId>maxFightId){

View File

@ -13,8 +13,10 @@ import com.ljsd.jieling.handler.map.TemporaryItems;
import com.ljsd.jieling.ktbeans.KtEventUtils;
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.event.ArenaChallengeEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.activity.event.UseItemEvent;
import com.ljsd.jieling.logic.activity.event.UserLevelEvent;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.hero.HeroLogic;
@ -532,6 +534,7 @@ public class ItemUtil {
}
while (curExp >= levelUpExp && curExp <= maxExp) {
playerInfoManager.setLevel(playerInfoManager.getLevel() + 1);
Poster.getPoster().dispatchEvent(new UserLevelEvent(user.getId(),playerInfoManager.getLevel()));
if(playerInfoManager.getLevel()==2&&playerInfoManager.getNickName().equals(String.valueOf(playerInfoManager.getRootId()))){
//TODO 走表
String title ="改名卡奖励";
@ -1291,6 +1294,10 @@ public class ItemUtil {
SVipLevelConfig sVipLevelConfig = SVipLevelConfig.getsVipLevelConfigMap().get(vipLevel);
Map<Integer, Integer> privilegeMap = sVipLevelConfig.getPrivilegeMap();
if(reason == BIReason.ADVENTURE_BASE_REWARD){
if(itemType == GlobalItemType.EXP){
sourceNum = parseTheValueByPrivilegeMap(privilegeMap,sourceNum,VipPrivilegeType.ADVENTURE_EXP_REWARD);
return sourceNum;
}
sourceNum = parseTheValueByPrivilegeMap(privilegeMap,sourceNum, VipPrivilegeType.ADVENTURE_BASE_REWARD);
}
if(reason == BIReason.ADVENTURE_BASE_REWARD || reason == BIReason.ADVENTURE_RANDOM_REWARDD ){