Merge branch 'master_test_hw' of http://60.1.1.230/backend/jieling_server into master_test_hw

back_recharge
lvxinran 2020-11-27 10:49:33 +08:00
commit fd5d07ee15
12 changed files with 600 additions and 17 deletions

View File

@ -298,4 +298,8 @@ public interface BIReason {
int SKIN_USE_CONSUME = 1073;//激活皮肤消耗
int SUB_ACTIVITY_CONSUME = 1074;//易经宝库
int SUB_ACTIVITY_CONSUME_FINISH = 1075;//易经宝库活动结束补发消耗
int OPEN_HONGMENG_GRAID = 1076; // 开鸿蒙阵格子消耗
int CLEAR_HONGMENG_GRAID = 1077; // 清鸿蒙阵格子cd
int HONGMENG_UPGRIDE = 1078; // 鸿蒙碑升级消耗
}

View File

@ -20,6 +20,8 @@ import com.ljsd.jieling.logic.activity.event.UserOnlineEvent;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.GlobalSystemControl;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.logic.hero.HongMengAttributeEnum;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.logic.question.QuestionLogic;
@ -77,7 +79,8 @@ public class GetPlayerInfoHandler extends BaseHandler{
BuyGoodsLogic.initOwernBagInfo(user);
// Poster.getPoster().dispatchEvent(new UserOnlineEvent(userId));
user.getUserMissionManager().onGameEvent(user, GameEvent.LOGIN_GAME,0);
playerInfoManager.setLoginTime(TimeUtils.now());
long now = TimeUtils.now();
playerInfoManager.setLoginTime(now);
Map<Integer, Integer> guidePoints = playerInfoManager.getGuidePoints();
Map<Integer, VipInfo> vipInfo = playerInfoManager.getVipInfo();
List<CommonProto.NewPlayerGuidePoint> list = new ArrayList<>();
@ -119,7 +122,8 @@ public class GetPlayerInfoHandler extends BaseHandler{
.setPhoneNum(user.getPlayerInfoManager().getPhoneBindInfo().getPhoneNum())
.setState(user.getPlayerInfoManager().getPhoneBindInfo().getState()).build();
RechargeInfo rechargeInfo = playerInfoManager.getRechargeInfo();
Map<Integer, Integer> totalCountMap = user.getHeroManager().getTotalCount();
HeroManager heroManager = user.getHeroManager();
Map<Integer, Integer> totalCountMap = heroManager.getTotalCount();
int alreadyCount =0;
for(Integer id : STableManager.getFigureConfig(HeroStaticConfig.class).getRandomHeroIds()){
Integer count = totalCountMap.get(id);
@ -144,7 +148,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
questState=user.getQuestionManager().getQuestState();
}
//图鉴信息
Map<Integer, Integer> heroHandBook = user.getHeroManager().getHeroHandBook();
Map<Integer, Integer> heroHandBook = heroManager.getHeroHandBook();
List<CommonProto.EveryHeroHandBook> heroHandBookList = new ArrayList<>();
heroHandBook.forEach((k,v)->heroHandBookList.add(CommonProto.EveryHeroHandBook.newBuilder().setHeroId(k).setMaxStar(v).build()));
@ -165,7 +169,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
remove.removeAll(user.getItemManager().getItemMap().keySet());
remove.forEach(n->{
try {
System.out.println("n = " + n);
LOGGER.info("GET_PLAYERINFO_REQUEST uid n = {}", userId, n);
user.getItemManager().newItem(n, 0);
}catch (Exception e){
e.printStackTrace();
@ -186,8 +190,30 @@ public class GetPlayerInfoHandler extends BaseHandler{
user.getPlayerInfoManager().getMonthCard().put(Global.LMONTHCARDID, (int) (System.currentTimeMillis() / 1000));
Poster.getPoster().dispatchEvent(new NewWelfareEvent(user, NewWelfareTypeEnum.RECHARGE_BUY.getType(),Global.LMONTHCARDID));
}
// 刷新鸿蒙阵
// HeroLogic.getInstance().addOrUpdateHongmeng(user);
// 组装鸿蒙阵信息
List<PlayerInfoProto.HongmengHeroInfo> hongmengHeroInfos = new ArrayList<>();
Map<Integer, String> resonances = heroManager.getResonances();
Map<Integer, Long> resonancesTime = heroManager.getResonancesTime();
for (Map.Entry<Integer, String> entry : resonances.entrySet()) {
PlayerInfoProto.HongmengHeroInfo hongmengHeroInfo = PlayerInfoProto.HongmengHeroInfo.newBuilder()
.setGridId(entry.getKey())
.setHeroId(entry.getValue())
.setTime(resonancesTime.containsKey(entry.getKey()) ? (resonancesTime.get(entry.getKey()) - now < 0 ? 0 : (resonancesTime.get(entry.getKey()) - now) / 1000) : 0)
.build();
hongmengHeroInfos.add(hongmengHeroInfo);
}
List<PlayerInfoProto.HongmengAddition> hongmengAdditions = new ArrayList<>();
Map<HongMengAttributeEnum, Integer> resonanceAddition = heroManager.getResonanceAddition();
for (Map.Entry<HongMengAttributeEnum, Integer> entry : resonanceAddition.entrySet()) {
PlayerInfoProto.HongmengAddition hongmengAddition = PlayerInfoProto.HongmengAddition
.newBuilder()
.setAdditionType(entry.getKey().getPropertyId())
.setValue(entry.getValue())
.build();
hongmengAdditions.add(hongmengAddition);
}
StoreLogic.reloadStoreInfo(user,7);//重载功能商店
PlayerInfoProto.GetPlayerInfoResponse getPlayerInfoResponse
= PlayerInfoProto.GetPlayerInfoResponse.newBuilder()
@ -207,7 +233,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
.setTreasureLevel(playerInfoManager.getTreasureLevel())
.setSignInInfo(CommonProto.SignInInfo.newBuilder().setDays(playerInfoManager.getSign()+1).setState(playerInfoManager.getSignTotay()).build())
.setMonsterAttackTime(user.getMapManager().getLastMonsterAttack())
.setFirstTenth(user.getHeroManager().getFirstTenth())
.setFirstTenth(heroManager.getFirstTenth())
.setIsDayFirst(playerInfoManager.getIsdayFirst())
.setEndInfo(endless)
.setPlayerBindPhone(playerBindPhone)
@ -222,6 +248,10 @@ public class GetPlayerInfoHandler extends BaseHandler{
.setExpeditionLeve(user.getExpeditionManager().getExpeditionLeve())
.setHadLuckTime( user.getPlayerInfoManager().getLuckWheelLimitTime())
.setHadAdvanceLuckTime(user.getPlayerInfoManager().getLuckAdvanceWheelLimitTime())
.addAllHongmengGuards(heroManager.getHongmengGuard())
.setHongmengTablet(heroManager.getHongmengTablet())
.addAllHongmengHeroInfos(hongmengHeroInfos)
.addAllHongmengAdditions(hongmengAdditions)
.build();
ReportUtil.onReportEvent(user, ReportEventEnum.APP_LOGIN.getType());
try {

View File

@ -0,0 +1,22 @@
package com.ljsd.jieling.handler.hero;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.HeroInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class HongmengCleanTimeRequestHandler extends BaseHandler<HeroInfoProto.CleanResonanceTimeRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.HONGMENG_CLEAN_TIME_RESQUEST;
}
@Override
public void processWithProto(ISession session, HeroInfoProto.CleanResonanceTimeRequest proto) throws Exception {
int gridId = proto.getGridId();
HeroLogic.getInstance().cleanTime(session, MessageTypeProto.MessageType.HONGMENG_CLEAN_TIME_RESPONSE, gridId);
}
}

View File

@ -0,0 +1,21 @@
package com.ljsd.jieling.handler.hero;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.HeroInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class HongmengOpenResonanceRequestHandler extends BaseHandler<HeroInfoProto.OpenResonanceRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.HONGMENG_OPEN_RESONANCE_REQUEST;
}
@Override
public void processWithProto(ISession session, HeroInfoProto.OpenResonanceRequest proto) throws Exception {
HeroLogic.getInstance().openResonance(session, MessageTypeProto.MessageType.HONGMENG_OPEN_RESONANCE_RESPONSE, proto.getGridId());
}
}

View File

@ -0,0 +1,25 @@
package com.ljsd.jieling.handler.hero;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.HeroInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class HongmengResonanceRequestHandler extends BaseHandler<HeroInfoProto.ResonanceRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.HONGMENG_RESONANCE_REQUEST;
}
@Override
public void processWithProto(ISession session, HeroInfoProto.ResonanceRequest proto) throws Exception {
if (proto.getType() == 1) {
HeroLogic.getInstance().resonance(session, MessageTypeProto.MessageType.HONGMENG_RESONANCE_RESPONSE, proto.getHeroId(), proto.getGridId());
} else {
HeroLogic.getInstance().unLoadResonance(session, MessageTypeProto.MessageType.HONGMENG_RESONANCE_RESPONSE, proto.getGridId());
}
}
}

View File

@ -0,0 +1,21 @@
package com.ljsd.jieling.handler.hero;
import com.google.protobuf.GeneratedMessage;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class HongmengUpgradRequestHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.HONGMENG_UPGRADE_REQUEST;
}
@Override
public void processWithProto(ISession iSession, GeneratedMessage proto) throws Exception {
HeroLogic.getInstance().updateHongmengTablet(iSession, MessageTypeProto.MessageType.HONGMENG_UPGRADE_RESPONSE);
}
}

View File

@ -1,13 +1,13 @@
package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.db.mongo.MongoKey;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.activity.event.RemoveHeroEvent;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.hero.HongMengAttributeEnum;
import org.luaj.vm2.ast.Str;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
public class HeroManager extends MongoBase {
@ -30,6 +30,19 @@ public class HeroManager extends MongoBase {
this.setRootCollection(User._COLLECTION_NAME);
}
// 鸿蒙守卫
private List<String> hongmengGuard = new ArrayList<>();
// 共鸣英雄<格子id英雄id>
private Map<Integer, String> resonances = new HashMap<>();
// 共鸣英雄<格子id冷却时间>
private Map<Integer, Long> resonancesTime = new HashMap<>();
// 共鸣加成
private Map<HongMengAttributeEnum, Integer> resonanceAddition = new HashMap<>();
// 鸿蒙碑等级
private int hongmengTablet;
// 鸿蒙碑最大等级
private Set<Integer> hongmengMaxLevel = new HashSet<>();
public void updateRandCount(int type,int count){
updateString("totalCount." + type, count);
totalCount.put(type,count);
@ -129,5 +142,64 @@ public class HeroManager extends MongoBase {
skinInfo.remove(skinId);
removeString(getMongoKey()+"skinInfo."+skinId);
}
public List<String> getHongmengGuard() {
return hongmengGuard;
}
public void setHongmengGuard(List<String> hongmengGuard) {
this.hongmengGuard = hongmengGuard;
updateString("hongmengGuard", hongmengGuard);
}
public Map<Integer, String> getResonances() {
return resonances;
}
public void setResonances(Map<Integer, String> resonances) {
this.resonances = resonances;
updateString("resonances", resonances);
}
public void updateResonances(int index, String heroId) {
this.resonances.put(index, heroId);
updateString("resonances."+ index, heroId);
}
public Map<Integer, Long> getResonancesTime() {
return resonancesTime;
}
public void updateResonancesTime(int index, long time) {
this.resonancesTime.put(index, time);
updateString("resonancesTime."+ index, time);
}
public Map<HongMengAttributeEnum, Integer> getResonanceAddition() {
return resonanceAddition;
}
public void setResonanceAddition(Map<HongMengAttributeEnum, Integer> resonanceAddition) {
this.resonanceAddition = resonanceAddition;
updateString("resonanceAddition", resonanceAddition);
}
public int getHongmengTablet() {
return hongmengTablet;
}
public void setHongmengTablet(int hongmengTablet) {
this.hongmengTablet = hongmengTablet;
updateString("hongmengTablet", hongmengTablet);
}
public Set<Integer> getHongmengMaxLevel() {
return hongmengMaxLevel;
}
public void setHongmengMaxLevel(Set<Integer> hongmengMaxLevel) {
this.hongmengMaxLevel = hongmengMaxLevel;
updateString("hongmengMaxLevel", hongmengMaxLevel);
}
}

View File

@ -1,18 +1,15 @@
package com.ljsd.jieling.logic.hero;
import com.ljsd.GameApplication;
import com.ljsd.jieling.chat.logic.ChatLogic;
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
import com.ljsd.jieling.config.clazzStaticCfg.HeroStaticConfig;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.core.VipPrivilegeType;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.globals.GlobalItemType;
import com.ljsd.jieling.jbean.ActivityMission;
import com.ljsd.jieling.jbean.ActivityProgressInfo;
@ -29,7 +26,6 @@ import com.ljsd.jieling.logic.fight.CombatLogic;
import com.ljsd.jieling.logic.fight.passiveSkillCal.PassiveskillCalEnum;
import com.ljsd.jieling.logic.item.ItemLogic;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.mission.MissionLoigc;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.network.server.ProtocolsManager;
import com.ljsd.jieling.network.session.ISession;
@ -40,7 +36,6 @@ import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.*;
import config.*;
import manager.STableManager;
import org.luaj.vm2.ast.Str;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import util.MathUtils;
@ -51,7 +46,6 @@ import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
public class HeroLogic{
@ -3272,7 +3266,6 @@ public class HeroLogic{
*
* @param session
* @param pokemonId
* @param level
* @param messageType
* @throws Exception
*/
@ -3407,4 +3400,287 @@ public class HeroLogic{
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
}
// ================共鸣、鸿蒙碑=========
/**
* 鸿
* @param user
*/
public void addOrUpdateHongmeng(User user) {
if (user.getPlayerInfoManager().getLevel() < SSpecialConfig.getIntegerValue(SSpecialConfig.HONGMENG_OPENLEVEL)) {
return;
}
HeroManager heroManager = user.getHeroManager();
Collection<Hero> values = heroManager.getHeroMap().values();
List<Hero> heroes = new ArrayList<>(values);
Collections.sort(heroes, new Comparator<Hero>() {
@Override
public int compare(Hero hero1, Hero hero2) {
int compareValue = hero2.getLevel() - hero1.getLevel();
if (compareValue != 0) {
return compareValue;
}
return Integer.compare(hero2.getStar(), hero1.getStar());
}
});
List<String> hongmengs = heroManager.getHongmengGuard();
hongmengs.clear();
// 只要任意鸿蒙守卫中有未穿戴装备的部位,就不会触发装备共鸣,共鸣区域放入神将时不再自动卸下装备 1:不卸下装备
int isUnloadEquip = 1;
// 只要任意鸿蒙守卫未穿戴魂宝/灵宝或强化等级为0便不会触发对应宝物的共鸣
int soulEquip = 1000;
int spiritEquip = 1000;
// 共鸣等级=鸿蒙守卫中最低的等级
int resonanceLevel = 1000;
// 共鸣法宝=鸿蒙守卫中法宝强化最低等级
int especialEquipLevel = 100;
// 是否开启鸿蒙碑
int tablet = 1;
Collection<String> values2 = heroManager.getResonances().values();
Map<String, PropertyItem> equipMap = user.getEquipManager().getEquipMap();
String[] openLevel = SSpecialConfig.getStringValue(SSpecialConfig.HONGMENG_UPGRADE_LIMIT).split("#");
for (int i = 0; i < heroes.size(); i++) {
Hero hero = heroes.get(i);
if (values2.contains(hero.getId())) {
continue;
}
if (hero.getEquipByPositionMap().size() != 4 && isUnloadEquip == 1) {
isUnloadEquip = 0;
}
if (hero.getJewelInfo().isEmpty()) {
soulEquip = 0;
spiritEquip = 0;
} else {
for (String jewel : hero.getJewelInfo()) {
PropertyItem propertyItem = equipMap.get(jewel);
if (propertyItem == null) {
soulEquip = 0;
spiritEquip = 0;
} else {
SJewelConfig config = STableManager.getConfig(SJewelConfig.class).get(propertyItem.getEquipId());
if (config == null) {
continue;
}
// getLocation 1魂宝 2灵宝
if (config.getLocation() == 1) {
soulEquip = propertyItem.getLevel() < soulEquip ? propertyItem.getLevel() : soulEquip;
} else {
spiritEquip = propertyItem.getLevel() < soulEquip ? propertyItem.getLevel() : soulEquip;
}
}
}
}
if (hero.getEspecialEquipLevel() < especialEquipLevel) {
especialEquipLevel = hero.getEspecialEquipLevel();
}
if (hero.getLevel() < Integer.parseInt(openLevel[1])) {
tablet = 0;
}
if (hero.getLevel() < resonanceLevel) {
resonanceLevel = hero.getLevel();
}
hongmengs.add(hero.getId());
if (hongmengs.size() >= Integer.parseInt(openLevel[0])) {
break;
}
}
if (hongmengs.size() < Integer.parseInt(openLevel[0])) {
return;
}
heroManager.setHongmengGuard(hongmengs);
// 计算共鸣属性
Map<HongMengAttributeEnum, Integer> resonanceAddition = heroManager.getResonanceAddition();
resonanceAddition.clear();
resonanceAddition.put(HongMengAttributeEnum.LEVEL, resonanceLevel);
resonanceAddition.put(HongMengAttributeEnum.EQUIP, isUnloadEquip);
resonanceAddition.put(HongMengAttributeEnum.SOUL_EQUIP, soulEquip);
resonanceAddition.put(HongMengAttributeEnum.SPIRIT_EQUIP, spiritEquip);
resonanceAddition.put(HongMengAttributeEnum.MAGIC_WEAPON, especialEquipLevel);
heroManager.setResonanceAddition(resonanceAddition);
// 鸿蒙碑
if (tablet == 1 && heroManager.getHongmengTablet() == 0) {
// 开启鸿蒙碑
heroManager.setHongmengTablet(Integer.parseInt(openLevel[1]));
}
}
/**
*
* @param session
* @param messageType
* @throws Exception
*/
public void openResonance(ISession session, MessageTypeProto.MessageType messageType, int graidId) throws Exception {
User user = UserManager.getUser(session.getUid());
HeroManager heroManager = user.getHeroManager();
Map<Integer, String> resonances = heroManager.getResonances();
if (resonances.containsKey(graidId)) {
LOGGER.info("openResonance uid=>{} has open=>{}", user.getId(), graidId);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
SHongmeng hongmeng = SHongmeng.hongmengs.get(graidId);
if (hongmeng == null) {
LOGGER.info("openResonance uid=>{} graidId not exist=>{}", user.getId(), graidId);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
Map<Integer, Integer> cost1 = new HashMap<>(1);
cost1.put(hongmeng.getPropPrice()[0], hongmeng.getPropPrice()[1]);
boolean checkCost1 = ItemUtil.checkCost(user, cost1);
if (checkCost1) {
ItemUtil.itemCost(user, cost1, BIReason.OPEN_HONGMENG_GRAID, graidId);
} else {
Map<Integer, Integer> cost2 = new HashMap<>(1);
cost2.put(hongmeng.getMoneyPrice()[0], hongmeng.getMoneyPrice()[1]);
boolean checkCost2 = ItemUtil.checkCost(user, cost2);
if (!checkCost2) {
LOGGER.info("openResonance uid=>{} cost item not enough=>{}", user.getId(), graidId);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
ItemUtil.itemCost(user, cost2, BIReason.OPEN_HONGMENG_GRAID, graidId);
}
resonances.put(graidId, "");
heroManager.setResonances(resonances);
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null);
}
/**
*
* @param session
* @param messageType
* @param heroId id
* @param index
*/
public void resonance(ISession session, MessageTypeProto.MessageType messageType, String heroId, int index) throws Exception {
User user = UserManager.getUser(session.getUid());
HeroManager heroManager = user.getHeroManager();
Hero hero = heroManager.getHeroMap().get(heroId);
if (hero == null) {
LOGGER.info("resonance uid=>{} no the heroId=>{}", user.getId(), heroId);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
if (heroManager.getHongmengGuard().contains(heroId)) {
LOGGER.info("resonance uid=>{} the heroId=>{} is HongmengGuard", user.getId(), heroId);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
Map<Integer, String> resonances = heroManager.getResonances();
String resonanceInfo = resonances.get(index);
if (resonanceInfo == null || !resonanceInfo.isEmpty()) {
LOGGER.info("resonance uid=>{} the index not open=>{}", user.getId(), index);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
Map<Integer, Long> resonancesTime = heroManager.getResonancesTime();
if (resonancesTime.get(index) != null && resonancesTime.get(index) > TimeUtils.now()) {
LOGGER.info("resonance uid=>{} time =>{}", user.getId(), resonancesTime.get(index));
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
// 添加到共鸣区
heroManager.updateResonances(index, heroId);
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null);
}
/**
*
* @param session
* @param messageType
* @param index
* @throws Exception
*/
public void unLoadResonance(ISession session, MessageTypeProto.MessageType messageType, int index) throws Exception{
User user = UserManager.getUser(session.getUid());
HeroManager heroManager = user.getHeroManager();
Map<Integer, String> resonances = heroManager.getResonances();
String resonanceInfo = resonances.get(index);
if (resonanceInfo == null || resonanceInfo.isEmpty()) {
LOGGER.info("unLoadResonance uid=>{} the index not open=>{}", user.getId(), index);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
Hero hero = heroManager.getHero(resonanceInfo);
if (hero == null) {
LOGGER.info("unLoadResonance uid=>{} cur hero is null {}", user.getId(), resonanceInfo);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
heroManager.updateResonances(index, "");
heroManager.updateResonancesTime(index, TimeUtils.now() + SSpecialConfig.getIntegerValue(SSpecialConfig.HONGMENG_LATTICE_WAIT_TIME) * 1000);
heroManager.updateResonances(index, resonanceInfo);
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null);
}
/**
*
* @param session
* @param messageType
* @param index
* @throws Exception
*/
public void cleanTime(ISession session, MessageTypeProto.MessageType messageType, int index) throws Exception {
User user = UserManager.getUser(session.getUid());
HeroManager heroManager = user.getHeroManager();
Map<Integer, String> resonances = heroManager.getResonances();
String resonanceInfo = resonances.get(index);
if (resonanceInfo == null) {
LOGGER.info("cleanTime uid=>{} the index not open=>{}", user.getId(), index);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
Map<Integer, Long> resonancesTime = heroManager.getResonancesTime();
Long unloadTime = resonancesTime.get(index);
if (unloadTime == null || unloadTime <= TimeUtils.now()) {
LOGGER.info("cleanTime uid=>{} time =>{}", user.getId(), unloadTime);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
String[] stringValue = SSpecialConfig.getStringValue(SSpecialConfig.HONGMENG_LATTICE_PRICE).split("#");
long time = unloadTime - TimeUtils.now();
int count = (int) (time / 1000 * Integer.parseInt(stringValue[0]));
Map<Integer, Integer> cost = new HashMap<>(1);
cost.put(Integer.parseInt(stringValue[1]), count);
boolean checkCost = ItemUtil.checkCost(user, cost);
if (!checkCost) {
LOGGER.info("cleanTime uid=>{} item not enough =>{}", user.getId(), unloadTime);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
ItemUtil.itemCost(user, cost, BIReason.CLEAR_HONGMENG_GRAID, index);
heroManager.updateResonancesTime(index, 0L);
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null);
}
/**
* 鸿
* @param session
* @param messageType
* @throws Exception
*/
public void updateHongmengTablet(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
User user = UserManager.getUser(session.getUid());
HeroManager heroManager = user.getHeroManager();
if (heroManager.getHongmengTablet() == 0) {
LOGGER.info("updateHongmengTablet uid=>{} HongmengTablet not open=>{}", user.getId(), 0);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
String[] split = SSpecialConfig.getStringValue(SSpecialConfig.HONGMENG_UPGRADE_LIMIT).split("#");
int maxLevel = heroManager.getHongmengMaxLevel().size() * SSpecialConfig.getIntegerValue(SSpecialConfig.HONGMENG_ONEHERO_OPENLEVEL) + Integer.parseInt(split[0]);
if (heroManager.getHongmengTablet() >= maxLevel) {
LOGGER.info("updateHongmengTablet uid=>{} curLevel={} maxLevel =>{}", user.getId(), heroManager.getHongmengTablet(), maxLevel);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
int nextLevel = heroManager.getHongmengTablet() + 1;
SHongmengUP hongmengUP = SHongmengUP.hongmengUPLevels.get(nextLevel);
if (hongmengUP == null) {
LOGGER.info("updateHongmengTablet uid=>{} curLevel={} maxLevel =>{} nextLevel=>{}", user.getId(), heroManager.getHongmengTablet(), maxLevel, nextLevel);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
int[][] levelUp = hongmengUP.getLevelUp();
boolean b = ItemUtil.itemCost(user, levelUp, BIReason.HONGMENG_UPGRIDE, nextLevel);
if (!b) {
LOGGER.info("updateHongmengTablet uid=>{} nextLevel=>{} need item not enough", user.getId(), nextLevel);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
heroManager.setHongmengTablet(nextLevel);
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null);
}
}

View File

@ -0,0 +1,23 @@
package com.ljsd.jieling.logic.hero;
/**
* 鸿
*/
public enum HongMengAttributeEnum {
LEVEL(1),
EQUIP(2),
SOUL_EQUIP(3), // 魂宝
SPIRIT_EQUIP(4),// 灵宝
MAGIC_WEAPON(5), // 法宝
;
private int propertyId;
HongMengAttributeEnum(int propertyId) {
this.propertyId = propertyId;
}
public int getPropertyId() {
return propertyId;
}
}

View File

@ -0,0 +1,40 @@
package config;
import manager.STableManager;
import manager.Table;
import java.util.Map;
@Table(name = "Hongmeng")
public class SHongmeng implements BaseConfig{
public static Map<Integer, SHongmeng> hongmengs;
private int id;
private int[] propPrice;
private int[] moneyPrice;
@Override
public void init() throws Exception {
hongmengs = STableManager.getConfig(SHongmeng.class);
}
public SHongmeng getHongmengById(int id){
return hongmengs.get(id);
}
public int getId() {
return id;
}
public int[] getPropPrice() {
return propPrice;
}
public int[] getMoneyPrice() {
return moneyPrice;
}
}

View File

@ -0,0 +1,44 @@
package config;
import manager.STableManager;
import manager.Table;
import java.util.HashMap;
import java.util.Map;
@Table(name = "HongmengUP")
public class SHongmengUP implements BaseConfig{
public static Map<Integer, SHongmengUP> hongmengUPs;
public static Map<Integer, SHongmengUP> hongmengUPLevels;
private int id;
private int hongmengLevel;
private int[][] levelUp;
@Override
public void init() throws Exception {
hongmengUPs = STableManager.getConfig(SHongmengUP.class);
hongmengUPLevels = new HashMap<>();
for (SHongmengUP hongmengUP : hongmengUPs.values()) {
hongmengUPLevels.put(hongmengUP.getHongmengLevel(), hongmengUP);
}
}
public int getId() {
return id;
}
public int getHongmengLevel() {
return hongmengLevel;
}
public int[][] getLevelUp() {
return levelUp;
}
}

View File

@ -69,6 +69,11 @@ public class SSpecialConfig implements BaseConfig {
public static final String GUILD_WAR_ISOPEN = "Guild_war_isopen";//老公会战是否开启
public static final String LUCKYTURNDAILYLIMIT = "LuckyTurnDailyLimit";//幸运探宝每日上限
public static final String HONGMENG_OPENLEVEL = "Hongmeng_OpenLevel";//鸿蒙阵开启等级
public static final String HONGMENG_LATTICE_WAIT_TIME = "Hongmeng_Lattice_Waitingtime";//鸿蒙阵每个格子冷却时间s
public static final String HONGMENG_LATTICE_PRICE = "Hongmeng_Lattice_Price";//鸿蒙阵格子刷新价格s
public static final String HONGMENG_UPGRADE_LIMIT = "Hongmeng_upgrade_limit";//鸿蒙阵升级开启限制
public static final String HONGMENG_ONEHERO_OPENLEVEL = "Hongmeng_Onehero_OpenLevel";//鸿蒙阵每个觉醒神将提升的等级
public static final String REPLACE_ITEM_ID = "replace_item_id";//置换玉道具ID
public static final String REPLACE_COST = "replace_cost";//置换玉消耗