鸿蒙阵1.2

back_recharge
duhui 2020-12-28 09:41:49 +08:00
parent 3834f8321f
commit 73cc224b50
4 changed files with 87 additions and 51 deletions

View File

@ -50,6 +50,8 @@ public class UseAndPriceItemHandler extends BaseHandler<PlayerInfoProto.UseAndPr
}
CommonProto.Drop.Builder baseBuilder =ItemLogic.getInstance().decomposeHero(iSession,heroIdsList,null, MessageTypeProto.MessageType.USER_AND_PRICE_ITEM_RESPONSE_VALUE);
ItemLogic.sendUseAndPriceItemMessage(iSession, MessageTypeProto.MessageType.USER_AND_PRICE_ITEM_RESPONSE_VALUE, baseBuilder);
//鸿蒙阵
HeroLogic.getInstance().addOrUpdateHongmeng(iSession);
}else if(type==4){//分解宝器
ItemLogic.getInstance().decomposeJewel(iSession,equipIdsList);
}else if(type==6){

View File

@ -7,6 +7,7 @@ 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 config.SSpecialConfig;
import org.springframework.stereotype.Component;
@Component
@ -22,7 +23,7 @@ public class HongmengResonanceRequestHandler extends BaseHandler<HeroInfoProto.R
if (proto.getType() == 1) {
HeroLogic.getInstance().resonance(session, MessageTypeProto.MessageType.HONGMENG_RESONANCE_RESPONSE, proto.getHeroId(), proto.getGridId());
} else if (proto.getType() == 2){
HeroLogic.getInstance().unLoadResonance(session, MessageTypeProto.MessageType.HONGMENG_RESONANCE_RESPONSE, proto.getGridId());
HeroLogic.getInstance().unLoadResonance(session, MessageTypeProto.MessageType.HONGMENG_RESONANCE_RESPONSE, proto.getGridId(), SSpecialConfig.getIntegerValue(SSpecialConfig.HONGMENG_LATTICE_WAIT_TIME));
}
else if (proto.getType() == 3){
HeroLogic.getInstance().unLoadHongmengTableHero(session, MessageTypeProto.MessageType.HONGMENG_RESONANCE_RESPONSE, proto.getGridId());

View File

@ -1061,9 +1061,10 @@ public class HeroLogic{
// recyleHeroBySystem(user,removeHeroIds);
rankUpHeroExecute(targetHero);
Poster.getPoster().dispatchEvent(new HeroUpStarEvent(user.getId(),targetHero.getTemplateId(),targetHero.getStar()));
if(targetHero.getStar()>=5&&targetHero.getStar()!=15){
if(SItem.getsItemMap().get(scHero.getId()).getQuantity()>=5)
Poster.getPoster().dispatchEvent(new HeroFiveStarGetEvent(user.getId(),targetHero.getStar()));
if (targetHero.getStar()>=5&&targetHero.getStar()!=15){
if (SItem.getsItemMap().get(scHero.getId()).getQuantity()>=5) {
Poster.getPoster().dispatchEvent(new HeroFiveStarGetEvent(user.getId(), targetHero.getStar()));
}
}
// if(targetHero.getStar()==5){
@ -3437,7 +3438,7 @@ public class HeroLogic{
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
}
// ================共鸣、鸿蒙碑=========
// ================================共鸣、鸿蒙碑========================= //
/**
* 鸿
@ -3455,12 +3456,12 @@ public class HeroLogic{
List<HeroInfoProto.HongmengHeroInfo> hongmengHeroInfos = new ArrayList<>();
Map<Integer, String> resonances = heroManager.getResonances();
Map<Integer, Long> resonancesTime = heroManager.getResonancesTime();
long now = TimeUtils.now();
long now = TimeUtils.now()/1000;
for (Map.Entry<Integer, String> entry : resonances.entrySet()) {
HeroInfoProto.HongmengHeroInfo hongmengHeroInfo = HeroInfoProto.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)
.setTime(resonancesTime.containsKey(entry.getKey()) ? (resonancesTime.get(entry.getKey()) - now < 0 ? 0 : (resonancesTime.get(entry.getKey()) - now)) : 0)
.build();
hongmengHeroInfos.add(hongmengHeroInfo);
}
@ -3471,7 +3472,7 @@ public class HeroLogic{
HeroInfoProto.HongmengHeroInfo hongmengHeroInfo = HeroInfoProto.HongmengHeroInfo.newBuilder()
.setGridId(entry.getKey())
.setHeroId(entry.getValue())
.setTime(hongmengGuardTime.containsKey(entry.getKey()) ? (hongmengGuardTime.get(entry.getKey()) - now < 0 ? 0 : (hongmengGuardTime.get(entry.getKey()) - now) / 1000) : 0)
.setTime(hongmengGuardTime.containsKey(entry.getKey()) ? (hongmengGuardTime.get(entry.getKey()) - now < 0 ? 0 : (hongmengGuardTime.get(entry.getKey()) - now)) : 0)
.build();
hongmengGuardsProto.add(hongmengHeroInfo);
}
@ -3523,7 +3524,15 @@ public class HeroLogic{
return Integer.compare(hero2.getStar(), hero1.getStar());
}
});
Map<Integer, String> hongmengs = new HashMap<>();
heroes.forEach((item)->{
System.out.println("hero========================:"+item.getId());
});
// 限制表 鸿蒙守卫数量#鸿蒙碑使者等级
String[] openLevel = SSpecialConfig.getStringValue(SSpecialConfig.HONGMENG_UPGRADE_LIMIT).split("#");
Map<Integer, String> hongmengs = new HashMap<>(Integer.parseInt(openLevel[0]));
int defaultValue = 1000;
// 只要任意鸿蒙守卫中有未穿戴装备的部位,就不会触发装备共鸣,共鸣区域放入神将时不再自动卸下装备 -1:不用卸下装备,其他表示装备星级
HongMengAddAttribute hongMengAddAttributeEquip = new HongMengAddAttribute(0, defaultValue);
@ -3540,16 +3549,20 @@ public class HeroLogic{
// 是否开启鸿蒙碑
int tablet = 1;
// 共鸣英雄池
Collection<String> values2 = heroManager.getResonances().values();
// 限制表 鸿蒙守卫数量#鸿蒙碑使者等级
String[] openLevel = SSpecialConfig.getStringValue(SSpecialConfig.HONGMENG_UPGRADE_LIMIT).split("#");
Map<Integer, String> resonances = heroManager.getResonances();
int key = 1;
for (int i = 0; i < heroes.size(); i++) {
Hero hero = heroes.get(i);
if (values2.contains(hero.getId())) {
continue;
}
resonances.forEach((k,v)->{
if (v.equals(hero.getId())){
try {
// 共鸣格子更新
unLoadResonance(session, MessageTypeProto.MessageType.HONGMENG_RESONANCE_RESPONSE, k, 0);
} catch (Exception e) {
e.printStackTrace();
}
}
});
// 是否开启鸿蒙碑
if (hero.getOriginalLevel() < Integer.parseInt(openLevel[1])) {
tablet = 0;
@ -3561,6 +3574,13 @@ public class HeroLogic{
break;
}
}
// 不够6个无法开启鸿蒙阵
/*if (hongmengs.size() < Integer.parseInt(openLevel[0])) {
return;
}*/
// 更新鸿蒙使者
heroManager.setHongmengGuards(hongmengs);
// 守卫/使者英雄池
Map<Integer, String> guards = heroManager.getHongmengGuards();
// 英雄装备
@ -3579,13 +3599,7 @@ public class HeroLogic{
especialAdd(especialEquipLevel, hero);
}
// 不够6个无法开启鸿蒙阵
/*if (hongmengs.size() < Integer.parseInt(openLevel[0])) {
return;
}*/
// 第一个格子免费开启
Map<Integer, String> resonances = heroManager.getResonances();
if (!resonances.containsKey(1)) {
resonances.put(1, "");
heroManager.setResonances(resonances);
@ -3593,19 +3607,19 @@ public class HeroLogic{
// 计算共鸣属性
Map<HongMengAttributeEnum, HongMengAddAttribute> resonanceAddition = heroManager.getResonanceAddition();
resonanceAddition.clear();
if (resonanceLevel.value == defaultValue) {
if (resonanceLevel.value == defaultValue || hongmengs.size() < Integer.parseInt(openLevel[0])) {
resonanceLevel.value = 0;
}
if (hongMengAddAttributeEquip.value == defaultValue) {
if (hongMengAddAttributeEquip.value == defaultValue || hongmengs.size() < Integer.parseInt(openLevel[0])) {
hongMengAddAttributeEquip.value = 0;
}
if (soulEquip.value == defaultValue) {
if (soulEquip.value == defaultValue || hongmengs.size() < Integer.parseInt(openLevel[0])) {
soulEquip.value = 0;
}
if (spiritEquip.value == defaultValue) {
if (spiritEquip.value == defaultValue || hongmengs.size() < Integer.parseInt(openLevel[0])) {
spiritEquip.value = 0;
}
if (especialEquipLevel.value == defaultValue) {
if (especialEquipLevel.value == defaultValue || hongmengs.size() < Integer.parseInt(openLevel[0])) {
especialEquipLevel.value = 0;
}
resonanceAddition.put(HongMengAttributeEnum.LEVEL, resonanceLevel);
@ -3626,7 +3640,8 @@ public class HeroLogic{
hero.setLevel(user, 1);
}
}
long now = TimeUtils.now();
long now = TimeUtils.now()/1000;
// 鸿蒙守卫
List<HeroInfoProto.HongmengHeroInfo> hongmengGuardsProto = new ArrayList<>();
Map<Integer, String> hongmengGuards = heroManager.getHongmengGuards();
Map<Integer, Long> hongmengGuardTime = heroManager.getHongmengGuardTime();
@ -3634,10 +3649,11 @@ public class HeroLogic{
HeroInfoProto.HongmengHeroInfo hongmengHeroInfo = HeroInfoProto.HongmengHeroInfo.newBuilder()
.setGridId(entry.getKey())
.setHeroId(entry.getValue())
.setTime(hongmengGuardTime.containsKey(entry.getKey()) ? (hongmengGuardTime.get(entry.getKey()) - now < 0 ? 0 : (hongmengGuardTime.get(entry.getKey()) - now) / 1000) : 0)
.setTime(hongmengGuardTime.containsKey(entry.getKey()) ? (hongmengGuardTime.get(entry.getKey()) - now < 0 ? 0 : (hongmengGuardTime.get(entry.getKey()) - now)) : 0)
.build();
hongmengGuardsProto.add(hongmengHeroInfo);
}
// 共鸣属性
List<HeroInfoProto.HongmengAddition> hongmengAdditions = new ArrayList<>();
for (Map.Entry<HongMengAttributeEnum, HongMengAddAttribute> entry : resonanceAddition.entrySet()) {
HeroInfoProto.HongmengAddition hongmengAddition = HeroInfoProto.HongmengAddition
@ -3648,9 +3664,22 @@ public class HeroLogic{
.build();
hongmengAdditions.add(hongmengAddition);
}
// 共鸣使者
List<HeroInfoProto.HongmengHeroInfo> hongmengResonancesProto = new ArrayList<>();
Map<Integer, String> hongmengResonances = heroManager.getResonances();
Map<Integer, Long> hongmengResonanceTime = heroManager.getResonancesTime();
for (Map.Entry<Integer, String> entry : hongmengResonances.entrySet()) {
HeroInfoProto.HongmengHeroInfo hongmengHeroInfo = HeroInfoProto.HongmengHeroInfo.newBuilder()
.setGridId(entry.getKey())
.setHeroId(entry.getValue())
.setTime(hongmengResonanceTime.containsKey(entry.getKey()) ? (hongmengResonanceTime.get(entry.getKey()) - now < 0 ? 0 : (hongmengResonanceTime.get(entry.getKey()) - now)) : 0)
.build();
hongmengResonancesProto.add(hongmengHeroInfo);
}
HeroInfoProto.HongmengInfoIndication hongmengInfoIndication = HeroInfoProto.HongmengInfoIndication.newBuilder()
.addAllHongmengGuards(hongmengGuardsProto)
.addAllHongmengAdditions(hongmengAdditions)
.addAllHongmengResonacnes(hongmengResonancesProto)
.build();
MessageUtil.sendIndicationMessage(session,1,MessageTypeProto.MessageType.HONGMENG_INFO_INDICATION.getNumber(),hongmengInfoIndication,true);
@ -3674,6 +3703,11 @@ public class HeroLogic{
* @param hero
*/
public void especialAdd(HongMengAddAttribute especialEquipLevel, Hero hero) {
if (hero.getEspecialEquipLevel() <= 1){
especialEquipLevel.value = -1;
especialEquipLevel.heroTid = 0;
return;
}
if (hero.getEspecialEquipLevel() < especialEquipLevel.value) {
especialEquipLevel.value = hero.getEspecialEquipLevel();
especialEquipLevel.heroTid = hero.getTemplateId();
@ -3689,18 +3723,19 @@ public class HeroLogic{
*/
public void soulOrSpirit(HongMengAddAttribute soulEquip, HongMengAddAttribute spiritEquip, Map<String, PropertyItem> equipMap, Hero hero) {
if (hero.getJewelInfo().isEmpty()) {
soulEquip.value = 0;
spiritEquip.value = 0;
soulEquip.value = -1;
spiritEquip.value = -1;
soulEquip.heroTid = 0;
spiritEquip.heroTid = 0;
} else {
for (String jewel : hero.getJewelInfo()) {
PropertyItem propertyItem = equipMap.get(jewel);
if (propertyItem == null) {
soulEquip.value = 0;
soulEquip.value = -1;
soulEquip.heroTid = 0;
spiritEquip.value = 0;
spiritEquip.value = -1;
spiritEquip.heroTid = 0;
break;
} else {
SJewelConfig config = STableManager.getConfig(SJewelConfig.class).get(propertyItem.getEquipId());
if (config == null) {
@ -3811,7 +3846,7 @@ public class HeroLogic{
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
Map<Integer, Long> resonancesTime = heroManager.getResonancesTime();
if (resonancesTime.get(index) != null && resonancesTime.get(index) > TimeUtils.now()) {
if (resonancesTime.get(index) != null && resonancesTime.get(index) > TimeUtils.now()/1000) {
LOGGER.info("resonance uid=>{} time =>{}", user.getId(), resonancesTime.get(index));
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
@ -3832,9 +3867,10 @@ public class HeroLogic{
* @param session
* @param messageType
* @param index
* @param time
* @throws Exception
*/
public void unLoadResonance(ISession session, MessageTypeProto.MessageType messageType, int index) throws Exception{
public void unLoadResonance(ISession session, MessageTypeProto.MessageType messageType, int index, int time) throws Exception{
User user = UserManager.getUser(session.getUid());
HeroManager heroManager = user.getHeroManager();
Map<Integer, String> resonances = heroManager.getResonances();
@ -3848,12 +3884,11 @@ public class HeroLogic{
LOGGER.info("unLoadResonance uid=>{} cur hero is null {}", user.getId(), heroId);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
heroManager.updateResonances(index, "");
heroManager.updateResonancesTime(index, TimeUtils.now() + SSpecialConfig.getIntegerValue(SSpecialConfig.HONGMENG_LATTICE_WAIT_TIME) * 1000);
HeroInfoProto.ResonanceResponse resonanceResponse = HeroInfoProto.ResonanceResponse
.newBuilder()
.setLeftTime(SSpecialConfig.getIntegerValue(SSpecialConfig.HONGMENG_LATTICE_WAIT_TIME))
.build();
heroManager.updateResonancesTime(index, TimeUtils.now()/1000 + time);
HeroInfoProto.ResonanceResponse resonanceResponse = HeroInfoProto.ResonanceResponse.newBuilder().setLeftTime(time).build();
MessageUtil.sendMessage(session, 1, messageType.getNumber(), resonanceResponse);
}
@ -3867,6 +3902,7 @@ public class HeroLogic{
public void cleanTime(ISession session, MessageTypeProto.MessageType messageType, int index, int type) throws Exception {
User user = UserManager.getUser(session.getUid());
HeroManager heroManager = user.getHeroManager();
long now = TimeUtils.now()/1000;
if (type == 1) {
Map<Integer, String> resonances = heroManager.getResonances();
String resonanceInfo = resonances.get(index);
@ -3876,12 +3912,12 @@ public class HeroLogic{
}
Map<Integer, Long> resonancesTime = heroManager.getResonancesTime();
Long unloadTime = resonancesTime.get(index);
if (unloadTime == null || unloadTime <= TimeUtils.now()) {
if (unloadTime == null || unloadTime <= 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())/1000;
long time = (unloadTime - now);
int count = (int) (time / Integer.parseInt(stringValue[0]) *Integer.parseInt(stringValue[2]) );
Map<Integer, Integer> cost = new HashMap<>(1);
cost.put(Integer.parseInt(stringValue[1]), count);
@ -3891,7 +3927,7 @@ public class HeroLogic{
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
ItemUtil.itemCost(user, cost, BIReason.CLEAR_HONGMENG_GRAID, index);
heroManager.updateResonancesTime(index, 0L);
heroManager.updateResonancesTime(index, 0);
} else {
if (heroManager.getHongmengTablet() == 0) {
LOGGER.info("cleanTime uid=>{} the HongmengTablet not open=>{}", user.getId(), index);
@ -3905,13 +3941,13 @@ public class HeroLogic{
}
Map<Integer, Long> hongmengGuardTime = heroManager.getHongmengGuardTime();
Long unloadTime = hongmengGuardTime.get(index);
if (unloadTime == null || unloadTime <= TimeUtils.now()) {
if (unloadTime == null || unloadTime <= 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]));
long time = unloadTime - now;
int count = (int) (time * Integer.parseInt(stringValue[0]));
Map<Integer, Integer> cost = new HashMap<>(1);
cost.put(Integer.parseInt(stringValue[1]), count);
boolean checkCost = ItemUtil.checkCost(user, cost);
@ -3995,7 +4031,7 @@ public class HeroLogic{
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
Map<Integer, Long> resonancesTime = heroManager.getHongmengGuardTime();
if (resonancesTime.get(index) != null && resonancesTime.get(index) > TimeUtils.now()) {
if (resonancesTime.get(index) != null && resonancesTime.get(index) > TimeUtils.now()/1000) {
LOGGER.info("addHongmengTableHero uid=>{} time =>{}", user.getId(), resonancesTime.get(index));
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
@ -4031,7 +4067,7 @@ public class HeroLogic{
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
}
heroManager.updateHongmengGuards(index, "");
heroManager.updateHongmengGuardTime(index, TimeUtils.now() + SSpecialConfig.getIntegerValue(SSpecialConfig.HONGMENG_LATTICE_WAIT_TIME) * 1000);
heroManager.updateHongmengGuardTime(index, TimeUtils.now()/1000 + SSpecialConfig.getIntegerValue(SSpecialConfig.HONGMENG_LATTICE_WAIT_TIME));
HeroInfoProto.ResonanceResponse resonanceResponse = HeroInfoProto.ResonanceResponse
.newBuilder()
.setLeftTime(SSpecialConfig.getIntegerValue(SSpecialConfig.HONGMENG_LATTICE_WAIT_TIME))

View File

@ -544,9 +544,6 @@ public class ItemLogic {
ReportUtil.onReportEvent(user, ReportEventEnum.SEND_HERO.getType(),heroIdReport,heroLevelReport,heroStarReport,new ArrayList<>(baseItemMap.keySet()),new ArrayList<>(baseItemMap.values()));
}
//鸿蒙阵
HeroLogic.getInstance().addOrUpdateHongmeng(iSession);
return ItemUtil.drop(user,itemReturnPercent(itemArray,rankUpReturnPercent),reson);
}