特训道具加速
parent
99136d3c90
commit
ccb04c698f
|
@ -470,4 +470,6 @@ public interface BIReason {
|
||||||
int EVERYDAY_DISCOUNT_GET_MISSION_COUNT = 1355;//天天折扣获得档位次数
|
int EVERYDAY_DISCOUNT_GET_MISSION_COUNT = 1355;//天天折扣获得档位次数
|
||||||
int EVERYDAY_DISCOUNT_COST_MISSION_COUNT = 1356;//天天折扣消耗档位次数
|
int EVERYDAY_DISCOUNT_COST_MISSION_COUNT = 1356;//天天折扣消耗档位次数
|
||||||
int EVERYDAY_DISCOUNT_CLEAN_MISSION_COUNT = 1357;//天天折扣清零次数
|
int EVERYDAY_DISCOUNT_CLEAN_MISSION_COUNT = 1357;//天天折扣清零次数
|
||||||
|
|
||||||
|
int TRAINGING_SPEED_ITEM_COST = 1358;//特训加速道具消耗
|
||||||
}
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.ljsd.jieling.handler.training;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
|
import com.ljsd.jieling.logic.hero.TrainingLogic;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import rpc.protocols.HeroInfoProto;
|
||||||
|
import rpc.protocols.MessageTypeProto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hj
|
||||||
|
* 特训道具加速
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class TrainingPropSpeedHandler extends BaseHandler<HeroInfoProto.TrainingPropSpeedRequest> {
|
||||||
|
@Override
|
||||||
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
|
return MessageTypeProto.MessageType.TrainingPropSpeedRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processWithProto(ISession iSession, HeroInfoProto.TrainingPropSpeedRequest proto) throws Exception {
|
||||||
|
TrainingLogic.getInstance().trainingPropSpeed(iSession, proto);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package com.ljsd.jieling.logic.hero;
|
||||||
|
|
||||||
import com.ljsd.jieling.exception.ErrorCode;
|
import com.ljsd.jieling.exception.ErrorCode;
|
||||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||||
|
import com.ljsd.jieling.exception.ErrorTableException;
|
||||||
import com.ljsd.jieling.globals.BIReason;
|
import com.ljsd.jieling.globals.BIReason;
|
||||||
import com.ljsd.jieling.globals.GlobalItemType;
|
import com.ljsd.jieling.globals.GlobalItemType;
|
||||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||||
|
@ -13,12 +14,14 @@ import com.ljsd.jieling.network.session.ISession;
|
||||||
import com.ljsd.jieling.util.CBean2Proto;
|
import com.ljsd.jieling.util.CBean2Proto;
|
||||||
import com.ljsd.jieling.util.ItemUtil;
|
import com.ljsd.jieling.util.ItemUtil;
|
||||||
import com.ljsd.jieling.util.MessageUtil;
|
import com.ljsd.jieling.util.MessageUtil;
|
||||||
|
import com.ljsd.jieling.util.ToolsUtil;
|
||||||
import config.*;
|
import config.*;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import rpc.protocols.CommonProto;
|
import rpc.protocols.CommonProto;
|
||||||
import rpc.protocols.HeroInfoProto;
|
import rpc.protocols.HeroInfoProto;
|
||||||
import rpc.protocols.MessageTypeProto;
|
import rpc.protocols.MessageTypeProto;
|
||||||
|
import util.StringUtil;
|
||||||
import util.TimeUtils;
|
import util.TimeUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -113,7 +116,7 @@ public class TrainingLogic {
|
||||||
int archId = proto.getArchId();
|
int archId = proto.getArchId();
|
||||||
TrainingArchitecture architecture = getTrainingArchitecture(user, archId);
|
TrainingArchitecture architecture = getTrainingArchitecture(user, archId);
|
||||||
if (architecture == null){
|
if (architecture == null){
|
||||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE, "建筑未解锁!");
|
throw new ErrorTableException(190);//建筑未解锁
|
||||||
}
|
}
|
||||||
|
|
||||||
STrainBuild trainBuild = STrainBuild.getMap().get(archId);
|
STrainBuild trainBuild = STrainBuild.getMap().get(archId);
|
||||||
|
@ -187,7 +190,7 @@ public class TrainingLogic {
|
||||||
|
|
||||||
TrainingArchitecture architecture = getTrainingArchitecture(user, architectureId);
|
TrainingArchitecture architecture = getTrainingArchitecture(user, architectureId);
|
||||||
if (architecture == null){
|
if (architecture == null){
|
||||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE, "建筑未解锁!");
|
throw new ErrorTableException(190);//建筑未解锁
|
||||||
}
|
}
|
||||||
Hero hero = user.getHeroManager().getHero(heroId);
|
Hero hero = user.getHeroManager().getHero(heroId);
|
||||||
Set<Integer> heroIds = STrain.getTrainByHeroMap().keySet();
|
Set<Integer> heroIds = STrain.getTrainByHeroMap().keySet();
|
||||||
|
@ -243,6 +246,65 @@ public class TrainingLogic {
|
||||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.TrainingResponse_VALUE, builder.build(), true);
|
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.TrainingResponse_VALUE, builder.build(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 特训道具加速
|
||||||
|
*/
|
||||||
|
public void trainingPropSpeed(ISession iSession, HeroInfoProto.TrainingPropSpeedRequest proto) throws Exception {
|
||||||
|
User user = UserManager.getUser(iSession.getUid());
|
||||||
|
int archId = proto.getArchId();
|
||||||
|
int itemId = proto.getItemId();
|
||||||
|
int num = proto.getNum();
|
||||||
|
|
||||||
|
TrainingArchitecture architecture = getTrainingArchitecture(user, archId);
|
||||||
|
if (architecture == null){
|
||||||
|
throw new ErrorTableException(190);//建筑未解锁
|
||||||
|
}
|
||||||
|
if (StringUtil.isEmpty(architecture.getHeroId())){
|
||||||
|
throw new ErrorTableException(191);//特训建筑中没有英雄在特训
|
||||||
|
}
|
||||||
|
STrainBuild trainBuild = STrainBuild.getMap().get(archId);
|
||||||
|
STrainBuildLevel buildLevel = STrainBuildLevel.getPoolMap().get(trainBuild.getLvupCostPool()).get(architecture.getLv());
|
||||||
|
if (buildLevel == null || buildLevel.getCost() == null){
|
||||||
|
throw new ErrorCodeException(ErrorCode.CFG_NULL, "未找到对应等级的建筑!");
|
||||||
|
}
|
||||||
|
Map<Integer, Long> selected = ToolsUtil.selectCostItem(buildLevel.getCost());
|
||||||
|
if (!selected.containsKey(itemId)){
|
||||||
|
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);//物品不足
|
||||||
|
}
|
||||||
|
HeroManager heroManager = user.getHeroManager();
|
||||||
|
Hero hero = heroManager.getHero(architecture.getHeroId());
|
||||||
|
if (hero == null){
|
||||||
|
throw new ErrorCodeException(ErrorCode.ITEM_DECOMPOSE_NO_HERO);//英雄不存在
|
||||||
|
}
|
||||||
|
boolean checkCost = ItemUtil.checkCost(user, new int[][]{{itemId, num}});
|
||||||
|
if (!checkCost){
|
||||||
|
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);//物品不足
|
||||||
|
}
|
||||||
|
Training training = hero.getTraining();
|
||||||
|
int gain = buildLevel.getGain();
|
||||||
|
int exp = (int) (selected.get(itemId) * gain);
|
||||||
|
// 攻击
|
||||||
|
if (buildLevel.getPosition() == 1){
|
||||||
|
training.addAttackExp(exp);
|
||||||
|
}
|
||||||
|
// 防御
|
||||||
|
if (buildLevel.getPosition() == 2){
|
||||||
|
training.addDefenseExp(exp);
|
||||||
|
}
|
||||||
|
// 生命
|
||||||
|
if (buildLevel.getPosition() == 3){
|
||||||
|
training.addHpExp(exp);
|
||||||
|
}
|
||||||
|
hero.setTraining(training);
|
||||||
|
ItemUtil.itemCost(user, new int[][]{{itemId, num}}, BIReason.TRAINGING_SPEED_ITEM_COST, 1);
|
||||||
|
|
||||||
|
CommonProto.HeroTraining trainingProto = CBean2Proto.getTrainingProto(hero);
|
||||||
|
CommonProto.TrainingArchitectureInfo architectureProto = CBean2Proto.getTrainingArchitectureProto(architecture);
|
||||||
|
HeroInfoProto.TrainingResponse.Builder builder = HeroInfoProto.TrainingResponse.newBuilder();
|
||||||
|
builder.setTraining(trainingProto).setInfo(architectureProto);
|
||||||
|
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.TrainingPropSpeedResponse_VALUE, builder.build(), true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 特训解锁技能
|
* 特训解锁技能
|
||||||
* 消耗 主角礼物,变身卡,灵兽,神兵,英雄
|
* 消耗 主角礼物,变身卡,灵兽,神兵,英雄
|
||||||
|
|
|
@ -229,4 +229,20 @@ public class ToolsUtil {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Map<Integer, Long> selectCostItem(int[][] costItems) {
|
||||||
|
HashMap<Integer, Long> map = new HashMap<>();
|
||||||
|
if (costItems == null){
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
for (int[] costItem : costItems){
|
||||||
|
int itemId = costItem[0];
|
||||||
|
int itemNum = costItem[1];
|
||||||
|
if (itemId == 0 || itemNum == 0){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
map.put(itemId, map.getOrDefault(itemId, 0L) + itemNum);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ public class STrainBuildLevel implements BaseConfig {
|
||||||
|
|
||||||
private int time;
|
private int time;
|
||||||
|
|
||||||
|
private int[][] speedUp;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
|
@ -84,5 +85,7 @@ public class STrainBuildLevel implements BaseConfig {
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int[][] getSpeedUp() {
|
||||||
|
return speedUp;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue