神将置换
parent
2ebfee79bd
commit
99779a39e1
|
@ -428,4 +428,5 @@ public interface BIReason {
|
|||
int GM_ROOT_REMOVE_ITEM = 1320;//GM后台删除玩家道具
|
||||
int UP_FAXIANG_EQUIP_LV_COST = 1321;//法相升级消耗
|
||||
int UP_FAXIANG_EQUIP_STAR_COST = 1322;//法相升星消耗
|
||||
int HERO_CHANGE_COST = 1323;//神将置换消耗
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
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 rpc.protocols.HeroInfoProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
|
||||
public class HeroChangeHandler extends BaseHandler<HeroInfoProto.HeroChangeRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.HERO_CHANGE_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, HeroInfoProto.HeroChangeRequest proto) throws Exception {
|
||||
HeroLogic.getInstance().heroChange(iSession,proto.getHeroID1(),proto.getHeroID2(),proto.getItemID());
|
||||
}
|
||||
}
|
|
@ -47,6 +47,7 @@ public class Hero extends MongoBase implements Comparable<Hero>,Cloneable {
|
|||
|
||||
private int speed;
|
||||
|
||||
// 法宝等级
|
||||
private int especialEquipLevel;
|
||||
|
||||
private int isLock;
|
||||
|
|
|
@ -2239,7 +2239,8 @@ public class HeroLogic {
|
|||
|
||||
// 好感度技能
|
||||
SLikeAbilityConfig abilityConfig = SLikeAbilityConfig.allLikeAbilityConfigMap.get(heroVo.getLikeLv());
|
||||
if (abilityConfig != null && abilityConfig.getSkill() != null && abilityConfig.getSkill().length > 0){
|
||||
if (abilityConfig != null && abilityConfig.getSkill() != null) {
|
||||
abilityConfig.getSkill();
|
||||
for (int skill : abilityConfig.getSkill()) {
|
||||
skillList.add(skill);
|
||||
}
|
||||
|
@ -2248,11 +2249,68 @@ public class HeroLogic {
|
|||
return skillList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 神将置换
|
||||
*/
|
||||
public void heroChange(ISession iSession, String heroID1, String heroID2, int itemId) throws Exception {
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
SHeroChange change = SHeroChange.map.get(itemId);
|
||||
if (change == null){
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL,"道具不存在:"+itemId);
|
||||
}
|
||||
HeroManager heroManager = user.getHeroManager();
|
||||
Hero hero1 = heroManager.getHero(heroID1);
|
||||
Hero hero2 = heroManager.getHero(heroID2);
|
||||
if (hero1 == null || hero2 == null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE,"英雄不存在");
|
||||
}
|
||||
LOGGER.info("神将置换信息,uid:{}, heroT1:{}, heroT2:{}, itemId:{}",iSession.getUid(),hero1.getTemplateId(),hero2.getTemplateId(),itemId);
|
||||
List<Integer> pool = Arrays.stream(change.getHeroPool()).boxed().collect(Collectors.toList());
|
||||
if (!pool.contains(hero1.getTemplateId()) || !pool.contains(hero2.getTemplateId())){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE,"对应英雄不在道具得使用范围内");
|
||||
}
|
||||
|
||||
int[][] item = {{itemId, 1}};
|
||||
boolean cost = ItemUtil.checkCostLong(user, item,1);
|
||||
if (!cost){
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
int level = hero1.getOriginalLevel();
|
||||
int breakthroughId = hero1.getBreakId();
|
||||
int star = hero1.getStar();
|
||||
int starBreakthroughId = hero1.getStarBreakId();
|
||||
int especialEquipLv = hero1.getEspecialEquipLevel();
|
||||
|
||||
hero1.setLevel(hero2.getOriginalLevel());
|
||||
hero1.setBreakId(hero2.getBreakId());
|
||||
hero1.setStar(hero2.getStar());
|
||||
hero1.setStarBreakId(hero2.getStarBreakId());
|
||||
hero1.setEspecialEquipLevel(especialEquipLv);
|
||||
|
||||
hero2.setLevel(level);
|
||||
hero2.setBreakId(breakthroughId);
|
||||
hero2.setStar(star);
|
||||
hero2.setStarBreakId(starBreakthroughId);
|
||||
hero2.setEspecialEquipLevel(especialEquipLv);
|
||||
|
||||
// 更新鸿蒙阵
|
||||
addOrUpdateHongmeng(iSession);
|
||||
// 战力变化
|
||||
Poster.getPoster().dispatchEvent(new SaveHeroForceEvent(user.getId(),""));
|
||||
// 消耗道具
|
||||
ItemUtil.itemCost(user,item,BIReason.HERO_CHANGE_COST,0);
|
||||
|
||||
CommonProto.Hero heroProto1 = CBean2Proto.getHero(hero1, heroManager);
|
||||
CommonProto.Hero heroProto2 = CBean2Proto.getHero(hero2, heroManager);
|
||||
HeroInfoProto.HeroChangeResponse.Builder builder = HeroInfoProto.HeroChangeResponse.newBuilder();
|
||||
builder.addHeros(heroProto1);
|
||||
builder.addHeros(heroProto2);
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.HERO_CHANGE_RESPONSE_VALUE, builder.build(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本服玩家使用
|
||||
* @param user
|
||||
* @param hero
|
||||
* @return
|
||||
*/
|
||||
public List<Integer> getHeroSkillList(User user, Hero hero) {
|
||||
HeroVo heroVo = HeroVo.createHeroVo(user, hero);
|
||||
|
@ -2261,10 +2319,6 @@ public class HeroLogic {
|
|||
|
||||
/**
|
||||
* 获取紫府神印技能
|
||||
*
|
||||
* @param sealId
|
||||
* @param propertyId
|
||||
* @param skillList
|
||||
*/
|
||||
private void getPurpleMansionSealSkill(int sealId, int propertyId, List<Integer> skillList) {
|
||||
SXiuXianSkill xianSkill = STableManager.getConfig(SXiuXianSkill.class).get(sealId);
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="HeroChange")
|
||||
public class SHeroChange implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private String itemName;
|
||||
|
||||
private int[] heroPool;
|
||||
|
||||
public static Map<Integer, SHeroChange> map;
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
map = STableManager.getConfig(SHeroChange.class);
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getItemName() {
|
||||
return itemName;
|
||||
}
|
||||
|
||||
public int[] getHeroPool() {
|
||||
return heroPool;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue