灵兽放生,涅槃
parent
c78f778881
commit
f5427e27a7
|
@ -150,6 +150,9 @@ public interface BIReason {
|
|||
int JOURNEY_COMMON_REWARD = 83;//逍遥游基础奖励
|
||||
int JOURNEY_FIGHT_REWARD = 84;//逍遥游击杀boss奖励
|
||||
int JOURNEY_RANDOM_REWARD = 85;//逍遥游转盘奖励
|
||||
int SPECIAL_MONSTER_REWARD = 86;//灵兽涅槃获得
|
||||
int SPECIAL_FREE_PIECE_REWARD = 87;//灵兽放生获得
|
||||
|
||||
|
||||
int ADVENTURE_UPLEVEL_CONSUME = 1000;//秘境升级
|
||||
int SECRETBOX_CONSUME = 1001;//秘盒抽卡
|
||||
|
@ -271,7 +274,12 @@ public interface BIReason {
|
|||
int GUILD_CHALLENGE_BUFF_BUY_CONSUME = 1065;//公会副本购买buff
|
||||
int JOURNEY_FIGHT_CONSUME = 1066;//逍遥游攻击boss消耗
|
||||
int JOURNEY_DO_CONSUME = 1067;//逍遥游摇骰子消耗
|
||||
int SPECIAL_LEVEL_UP_CONSUME = 1068;//灵兽升级消耗
|
||||
|
||||
int SPECIAL_STAR_UP_CONSUME = 1069;//灵兽升星消耗;
|
||||
|
||||
int SPECIAL_BACK_CONSUME = 1070;//灵兽涅槃消耗
|
||||
|
||||
int SPECIAL_FREE_PIECE_CONSUME = 1070;//灵兽放生碎片消耗
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.ljsd.jieling.handler.pokeemon;
|
||||
package com.ljsd.jieling.handler.pokemon;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
|
@ -1,4 +1,4 @@
|
|||
package com.ljsd.jieling.handler.pokeemon;
|
||||
package com.ljsd.jieling.handler.pokemon;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
|
@ -1,25 +1,25 @@
|
|||
package com.ljsd.jieling.handler.pokeemon;
|
||||
package com.ljsd.jieling.handler.pokemon;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.HeroInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class PokemonAdvancedHandler extends BaseHandler {
|
||||
public class PokemonAdvancedHandler extends BaseHandler<HeroInfoProto.PokemonAdvancedRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.POKEMON_ADVANCED_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
byte[] bytes = netData.parseClientProtoNetData();
|
||||
HeroInfoProto.PokemonAdvancedRequest pokemonAdvancedRequest = HeroInfoProto.PokemonAdvancedRequest.parseFrom(bytes);
|
||||
int pokemonId = pokemonAdvancedRequest.getPokemonId();
|
||||
HeroLogic.getInstance().pokemonAdvanced(iSession,pokemonId);
|
||||
public void processWithProto(ISession iSession, HeroInfoProto.PokemonAdvancedRequest proto) throws Exception {
|
||||
String pokemonId = proto.getPokemonId();
|
||||
List<String> consumePokemonIdsList = proto.getConsumePokemonIdsList();
|
||||
HeroLogic.getInstance().pokemonAdvanced(iSession,pokemonId,consumePokemonIdsList);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.handler.pokemon;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/10/22
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class PokemonBackHandler extends BaseHandler<HeroInfoProto.PokemonBackRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.POKEMON_BACK_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, HeroInfoProto.PokemonBackRequest proto) throws Exception {
|
||||
HeroLogic.getInstance().pokemonBack(iSession,proto.getPokemonId(),MessageTypeProto.MessageType.POKEMON_BACK_RESPONSE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.handler.pokemon;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/10/22
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class PokemonFreeHandler extends BaseHandler<HeroInfoProto.PokemonFreeRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.POKEMON_FREE_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, HeroInfoProto.PokemonFreeRequest proto) throws Exception {
|
||||
HeroLogic.getInstance().pokemonFree(iSession,proto.getPokemonIdList(),proto.getPieceId(),proto.getPieceNum(), MessageTypeProto.MessageType.POKEMON_FREE_RESPONSE);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
package com.ljsd.jieling.handler.pokeemon;
|
||||
package com.ljsd.jieling.handler.pokemon;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.HeroInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
|
@ -22,12 +22,6 @@ public class PokemonManager extends MongoBase {
|
|||
updateString("pokemonMap." + pokemon.getId(), pokemon);
|
||||
}
|
||||
|
||||
// public void addRingFirePokemon(Pokemon pokemon) throws Exception {
|
||||
// pokemon.init(this.getRootId(),getMongoKey() + ".ringFireMap." + pokemon.getId());
|
||||
// updateString("ringFireMap." + pokemon.getId(), pokemon);
|
||||
// ringFireMap.put(pokemon.getId(),pokemon);
|
||||
// }
|
||||
|
||||
public void updatePokemonLevel(String id,int level){
|
||||
pokemonMap.get(id).setLevel(level);
|
||||
updateString("pokemonMap." + id+".level", level);
|
||||
|
@ -47,7 +41,15 @@ public class PokemonManager extends MongoBase {
|
|||
return pokemonMap;
|
||||
}
|
||||
|
||||
// public Map<Integer, Pokemon> getRingFireMap() {
|
||||
// return ringFireMap;
|
||||
// }
|
||||
public void removePokemon(String pokemonId){
|
||||
pokemonMap.remove(pokemonId);
|
||||
removeString("pokemonMap."+pokemonId);
|
||||
}
|
||||
public void updatePokemonStar(String id,int star){
|
||||
pokemonMap.get(id).setStar(star);
|
||||
updateString("pokemonMap." + id+".star", star);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2048,7 +2048,7 @@ public class HeroLogic{
|
|||
}
|
||||
|
||||
/**
|
||||
* 英雄合成
|
||||
* 英雄,灵兽合成
|
||||
* @param iSession
|
||||
* @param item
|
||||
*/
|
||||
|
@ -2082,7 +2082,9 @@ public class HeroLogic{
|
|||
.newBuilder()
|
||||
.setDrop(drop)
|
||||
.build();
|
||||
user.getUserMissionManager().onGameEvent(user,GameEvent.COMPOS_HERO,drop.getHero(0).getHeroId(),composeNum);
|
||||
if(!drop.getHeroList().isEmpty()){
|
||||
user.getUserMissionManager().onGameEvent(user,GameEvent.COMPOS_HERO,drop.getHero(0).getHeroId(),composeNum);
|
||||
}
|
||||
MessageUtil.sendMessage(iSession,1,msgId,heroComposeResponse,true); }
|
||||
|
||||
public String getQuality(int natural) {
|
||||
|
@ -2159,6 +2161,7 @@ public class HeroLogic{
|
|||
|
||||
Map<Integer, SSpiritAnimalLevel> levelMap = SSpiritAnimalLevel.configByQualityAndLevel.get(3);
|
||||
Map<Integer,Integer> costMap = new HashMap<>();
|
||||
int finalLevel = pokemon.getLevel();
|
||||
for(int i = pokemon.getLevel();i<level;i++){
|
||||
if(!levelMap.containsKey(i)){
|
||||
continue;
|
||||
|
@ -2175,107 +2178,218 @@ public class HeroLogic{
|
|||
}
|
||||
boolean b = ItemUtil.checkCost(user, costMap);
|
||||
if(!b){
|
||||
finalLevel = i;
|
||||
break;
|
||||
}
|
||||
finalLevel = i+1;
|
||||
}
|
||||
|
||||
|
||||
pokemonManager.updatePokemonLevel(pokemonId,level);
|
||||
|
||||
|
||||
ItemUtil.itemCost(user,costMap,BIReason.SPECIAL_LEVEL_UP_CONSUME,1);
|
||||
pokemonManager.updatePokemonLevel(pokemonId,finalLevel);
|
||||
|
||||
HeroInfoProto.PokenmonUpLevelResponse response = HeroInfoProto.PokenmonUpLevelResponse.newBuilder().setLevel(finalLevel).build();
|
||||
//发送成功消息
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response,true);
|
||||
// user.getUserMissionManager().onGameEvent(user,GameEvent.POKEMON_UPLEVEL,pokemonId);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
public void pokemonAdvanced(ISession session,int pokemonId) throws Exception {
|
||||
// int uid = session.getUid();
|
||||
// User user = UserManager.getUser(uid);
|
||||
// PokemonManager pokemonManager = user.getPokemonManager();
|
||||
// Pokemon pokemon = pokemonManager.getPokemonMap().get(pokemonId);
|
||||
// if(pokemon == null){
|
||||
// throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
// }
|
||||
// SDifferDemonsConfig sDifferDemonsConfig = SDifferDemonsConfig.getsDifferDemonsConfigByPokenID(pokemonId);
|
||||
// int[] comonpentList = sDifferDemonsConfig.getComonpentList();
|
||||
// Map<Integer, Integer> comonpentsLevelMap = pokemon.getComonpentsLevelMap();
|
||||
// SDifferDemonsStageConfig sDifferDemonsStageConfig = SDifferDemonsStageConfig.getsDifferDemonsStageConfigMap(pokemonId*100 + pokemon.getAllStage() + 1);
|
||||
// int comonpentPreStage = sDifferDemonsStageConfig.getComonpentPreStage();
|
||||
//
|
||||
// boolean isEnough = true;
|
||||
// for(int i=0;i<comonpentList.length;i++){
|
||||
// if(!comonpentsLevelMap.containsKey(comonpentList[i])){
|
||||
// isEnough =false;
|
||||
// break;
|
||||
// }
|
||||
// if(comonpentsLevelMap.get(comonpentList[i]) < comonpentPreStage){
|
||||
// isEnough =false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// int[][] cost = sDifferDemonsStageConfig.getCost();
|
||||
//
|
||||
// if(!isEnough){
|
||||
// throw new ErrorCodeException(ErrorCode.newDefineCode("not tryMatch"));
|
||||
// }
|
||||
// isEnough = ItemUtil.itemCost(user,cost,BIReason.POKEMON_ADVANCE_CONSUME,pokemonId);
|
||||
// if(!isEnough){
|
||||
// throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// pokemon.setAllStage(pokemon.getAllStage()+1);
|
||||
// if(pokemon.getAllStage() == 1){
|
||||
// user.getUserMissionManager().onGameEvent(user,GameEvent.POKEMON_ADVANCED,pokemonId);
|
||||
// }
|
||||
//
|
||||
// //发送成功消息
|
||||
// MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.POKEMON_ADVANCED_RESPONSE_VALUE,null,true);
|
||||
// String message=null;
|
||||
// if(pokemon.getAllStage()==1){
|
||||
// message = SErrorCodeEerverConfig.getI18NMessage("lamp_activate_differ_content_"+sDifferDemonsConfig.getQuality(), new Object[]{user.getPlayerInfoManager().getNickName(),sDifferDemonsConfig.getName() });
|
||||
//
|
||||
// }else if(pokemon.getAllStage()>=SSpecialConfig.getIntegerValue(SSpecialConfig.lamp_rankup_differ_content_parm)){
|
||||
// message = SErrorCodeEerverConfig.getI18NMessage("lamp_rankup_differ_content_"+sDifferDemonsConfig.getQuality(), new Object[]{user.getPlayerInfoManager().getNickName(), sDifferDemonsConfig.getName(),pokemon.getAllStage()});
|
||||
// }
|
||||
// if(message!=null){
|
||||
// ChatLogic.getInstance().sendSysChatMessage(message,Global.DILIGENT,sDifferDemonsConfig.getId(),0,0,0,0,0);
|
||||
// }
|
||||
}
|
||||
/**
|
||||
* 灵兽升星
|
||||
* @param session
|
||||
* @param pokemonId
|
||||
* @param consumePokemonIdsList
|
||||
* @throws Exception
|
||||
*/
|
||||
public void pokemonAdvanced(ISession session,String pokemonId,List<String> consumePokemonIdsList) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
PokemonManager pokemonManager = user.getPokemonManager();
|
||||
Pokemon pokemon = pokemonManager.getPokemonMap().get(pokemonId);
|
||||
if(pokemon == null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
Map<Integer, SSpiritAnimalStar> configMap = SSpiritAnimalStar.configByQualityAndStar.get(3);
|
||||
|
||||
|
||||
|
||||
|
||||
private boolean checkPokemonComonpent(int pokemonId, int comonpentId, int oldLevel,User user) throws Exception {
|
||||
SDifferDemonsConfig sDifferDemonsConfig = SDifferDemonsConfig.getsDifferDemonsConfigByPokenID(pokemonId);
|
||||
int[] comonpentList = sDifferDemonsConfig.getComonpentList();
|
||||
boolean isHave = false;
|
||||
for(int i=0;i<comonpentList.length;i++){
|
||||
if( comonpentList[i] == comonpentId){
|
||||
isHave = true;
|
||||
break;
|
||||
if(!configMap.containsKey(pokemon.getStar())){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
SSpiritAnimalStar config = configMap.get(pokemon.getStar());
|
||||
if(config.getConsumeItemNum()!=consumePokemonIdsList.size()){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
for(String consume:consumePokemonIdsList){
|
||||
Pokemon consumePokemon = pokemonManager.getPokemonMap().get(consume);
|
||||
if(consumePokemon==null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
if(consumePokemon.getTmpId()!=pokemon.getTmpId()){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
if(consumePokemon.getLevel()!=1||consumePokemon.getStar()!=0){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
}
|
||||
if(!isHave){
|
||||
return true;
|
||||
int[][] consumeRes = config.getConsumeRes();
|
||||
boolean itemCost = ItemUtil.itemCost(user, consumeRes, BIReason.SPECIAL_STAR_UP_CONSUME, 1);
|
||||
if(!itemCost){
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
for(String consume:consumePokemonIdsList) {
|
||||
pokemonManager.removePokemon(consume);
|
||||
}
|
||||
pokemonManager.updatePokemonStar(pokemonId,pokemon.getStar()+1);
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.POKEMON_ADVANCED_RESPONSE_VALUE,null,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 灵兽涅槃
|
||||
* @param session
|
||||
* @param pokemonId
|
||||
* @param level
|
||||
* @param messageType
|
||||
* @throws Exception
|
||||
*/
|
||||
public void pokemonBack(ISession session, String pokemonId, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
PokemonManager pokemonManager = user.getPokemonManager();
|
||||
Pokemon pokemon = pokemonManager.getPokemonMap().get(pokemonId);
|
||||
if(pokemon == null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
if(pokemon.getLevel()==1&&pokemon.getStar()==0){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
|
||||
Map<Integer, SDifferDemonsComonpentsConfig> sDifferDemonsComonpentsConfigMap = SDifferDemonsComonpentsConfig.getsDifferDemonsComonpentsConfigMap(comonpentId);
|
||||
if(!sDifferDemonsComonpentsConfigMap.containsKey(oldLevel) || !sDifferDemonsComonpentsConfigMap.containsKey(oldLevel+1)){
|
||||
LOGGER.info("the pokenId={},the comId={},sDifferDemonsConfig={},the oldLevel={}",pokemonId,comonpentId,oldLevel);
|
||||
return true;
|
||||
int tmpId = pokemon.getTmpId();
|
||||
SSpiritAnimal animalConfig = STableManager.getConfig(SSpiritAnimal.class).get(tmpId);
|
||||
Map<Integer,Integer> costMap = new HashMap<>();
|
||||
costMap.put(animalConfig.getReturnCost()[0],animalConfig.getReturnCost()[1]);
|
||||
if(ItemUtil.checkCost(user,costMap)){
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
SDifferDemonsComonpentsConfig sDifferDemonsComonpentsConfig = sDifferDemonsComonpentsConfigMap.get(oldLevel);
|
||||
int[][] cost = sDifferDemonsComonpentsConfig.getCost();
|
||||
boolean enoughCost = ItemUtil.itemCost(user, cost,BIReason.POKEMON_UPLEVEL_CONSUME,pokemonId);
|
||||
if(!enoughCost){
|
||||
LOGGER.info("the pokenId={},the comId={},sDifferDemonsConfig={}",pokemonId,comonpentId,sDifferDemonsComonpentsConfig.getId());
|
||||
return true;
|
||||
Map<Integer,Integer> returnMap = new HashMap<>();
|
||||
|
||||
getPokemonReturnReward(pokemon,returnMap);
|
||||
|
||||
//本体返还
|
||||
SSpiritAnimalStar starConfig = SSpiritAnimalStar.configByQualityAndStar.get(animalConfig.getQuality()).get(pokemon.getStar());
|
||||
int sumItemNum = starConfig.getSumItemNum();
|
||||
if(sumItemNum!=0){
|
||||
returnMap.put(tmpId,returnMap.getOrDefault(tmpId,0)+sumItemNum);
|
||||
}
|
||||
ItemUtil.itemCost(user,costMap,BIReason.SPECIAL_BACK_CONSUME,1);
|
||||
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, ItemUtil.mapToArray(returnMap), BIReason.SPECIAL_MONSTER_REWARD);
|
||||
|
||||
HeroInfoProto.PokemonBackResponse response = HeroInfoProto.PokemonBackResponse.newBuilder().setDrop(drop).build();
|
||||
|
||||
MessageUtil.sendMessage(session,1, messageType.getNumber(),response,true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 灵兽放生
|
||||
* @param session
|
||||
* @param pokemonIds
|
||||
* @param pieceId
|
||||
* @param pieceAmount
|
||||
* @param messageType
|
||||
* @throws Exception
|
||||
*/
|
||||
public void pokemonFree(ISession session, List<String> pokemonIds,int pieceId,int pieceAmount, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
PokemonManager pokemonManager = user.getPokemonManager();
|
||||
if(!pokemonIds.isEmpty()){
|
||||
if(pieceId!=0||pieceAmount!=0){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
}else{
|
||||
if(pieceId==0||pieceAmount==0){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
}
|
||||
Map<Integer,Integer> returnMap = new HashMap<>();
|
||||
|
||||
if(!pokemonIds.isEmpty()){
|
||||
|
||||
for(String pokemonId:pokemonIds){
|
||||
Pokemon pokemon = pokemonManager.getPokemonMap().get(pokemonId);
|
||||
|
||||
if(pokemon == null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
|
||||
getPokemonReturnReward(pokemon,returnMap);
|
||||
SSpiritAnimal animalConfig = STableManager.getConfig(SSpiritAnimal.class).get(pokemon.getTmpId());
|
||||
|
||||
SSpiritAnimalStar starConfig = SSpiritAnimalStar.configByQualityAndStar.get(animalConfig.getQuality()).get(pokemon.getStar());
|
||||
|
||||
int sumItemNum = starConfig.getSumItemNum()+1;
|
||||
|
||||
int[] coinReturn = animalConfig.getCoinReturn();
|
||||
|
||||
returnMap.put(coinReturn[0],returnMap.getOrDefault(coinReturn[0],0)+coinReturn[1]*sumItemNum);
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
SSpiritAnimal animal = SSpiritAnimal.pieceConfig.get(pieceId);
|
||||
Map<Integer,Integer> costMap = new HashMap<>();
|
||||
if(animal==null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
boolean checkCost = ItemUtil.checkCost(user, costMap);
|
||||
if(!checkCost){
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
int[] piecesCoinReturn = animal.getPiecesCoinReturn();
|
||||
returnMap.put(piecesCoinReturn[0],returnMap.getOrDefault(piecesCoinReturn[0],0)+piecesCoinReturn[1]*pieceAmount);
|
||||
ItemUtil.itemCost(user,costMap,BIReason.SPECIAL_FREE_PIECE_CONSUME,1);
|
||||
}
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, ItemUtil.mapToArray(returnMap), BIReason.SPECIAL_FREE_PIECE_REWARD);
|
||||
|
||||
HeroInfoProto.PokemonFreeResponse response = HeroInfoProto.PokemonFreeResponse.newBuilder().setDrop(drop).build();
|
||||
|
||||
MessageUtil.sendMessage(session,1, messageType.getNumber(),response,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 等级和星级返还 不包括本体返还
|
||||
* @param pokemon
|
||||
* @param returnMap
|
||||
* @throws ErrorCodeException
|
||||
*/
|
||||
private void getPokemonReturnReward(Pokemon pokemon,Map<Integer,Integer> returnMap) throws ErrorCodeException {
|
||||
SSpiritAnimal animalConfig = STableManager.getConfig(SSpiritAnimal.class).get(pokemon.getTmpId());
|
||||
|
||||
SSpiritAnimalLevel levelConfig = SSpiritAnimalLevel.configByQualityAndLevel.get(animalConfig.getQuality()).get(pokemon.getLevel());
|
||||
if(levelConfig==null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
SSpiritAnimalStar starConfig = SSpiritAnimalStar.configByQualityAndStar.get(animalConfig.getQuality()).get(pokemon.getStar());
|
||||
|
||||
if(starConfig==null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
|
||||
int[][] sumConsumeLevel = levelConfig.getSumConsume();
|
||||
if(pokemon.getLevel()!=1&&sumConsumeLevel!=null&&sumConsumeLevel.length>0&&sumConsumeLevel[0].length>0){
|
||||
for(int[] consume:sumConsumeLevel){
|
||||
returnMap.put(consume[0],returnMap.getOrDefault(consume[0],0)+consume[1]);
|
||||
}
|
||||
}
|
||||
|
||||
int[][] sumConsumeStar = starConfig.getSumConsume();
|
||||
if(pokemon.getStar()!=0&&sumConsumeStar!=null&&sumConsumeStar.length>0&&sumConsumeStar[0].length>0){
|
||||
for(int[] consume:sumConsumeStar){
|
||||
returnMap.put(consume[0],returnMap.getOrDefault(consume[0],0)+consume[1]);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO isMyself ???
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="SpiritAnimal")
|
||||
public class SSpiritAnimal implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int piecesId;
|
||||
|
||||
private int piecesCount;
|
||||
|
||||
private int quality;
|
||||
|
||||
private int maxStar;
|
||||
|
||||
private int canChange;
|
||||
|
||||
private float hp;
|
||||
|
||||
private float attack;
|
||||
|
||||
private float physicalDefence;
|
||||
|
||||
private float magicDefence;
|
||||
|
||||
private int[][] skillArray;
|
||||
|
||||
private int[] coinReturn;
|
||||
|
||||
private int[] piecesCoinReturn;
|
||||
|
||||
private int maxLevel;
|
||||
|
||||
private int inVersion;
|
||||
|
||||
private int[] returnCost;
|
||||
|
||||
public static Map<Integer,SSpiritAnimal> pieceConfig;
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
Map<Integer, SSpiritAnimal> config = STableManager.getConfig(SSpiritAnimal.class);
|
||||
Map<Integer,SSpiritAnimal> pieceConfigTemp = new HashMap<>();
|
||||
for(Map.Entry<Integer,SSpiritAnimal> entry :config.entrySet()){
|
||||
pieceConfigTemp.put(entry.getValue().getPiecesId(),entry.getValue());
|
||||
}
|
||||
pieceConfig = pieceConfigTemp;
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getPiecesId() {
|
||||
return piecesId;
|
||||
}
|
||||
|
||||
public int getPiecesCount() {
|
||||
return piecesCount;
|
||||
}
|
||||
|
||||
public int getQuality() {
|
||||
return quality;
|
||||
}
|
||||
|
||||
public int getMaxStar() {
|
||||
return maxStar;
|
||||
}
|
||||
|
||||
public int getCanChange() {
|
||||
return canChange;
|
||||
}
|
||||
|
||||
public float getHp() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
public float getAttack() {
|
||||
return attack;
|
||||
}
|
||||
|
||||
public float getPhysicalDefence() {
|
||||
return physicalDefence;
|
||||
}
|
||||
|
||||
public float getMagicDefence() {
|
||||
return magicDefence;
|
||||
}
|
||||
|
||||
public int[][] getSkillArray() {
|
||||
return skillArray;
|
||||
}
|
||||
|
||||
public int[] getCoinReturn() {
|
||||
return coinReturn;
|
||||
}
|
||||
|
||||
public int[] getPiecesCoinReturn() {
|
||||
return piecesCoinReturn;
|
||||
}
|
||||
|
||||
public int getMaxLevel() {
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
public int getInVersion() {
|
||||
return inVersion;
|
||||
}
|
||||
|
||||
public int[] getReturnCost() {
|
||||
return returnCost;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package config;
|
|||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="SpiritAnimalStar")
|
||||
|
@ -14,18 +15,27 @@ public class SSpiritAnimalStar implements BaseConfig {
|
|||
|
||||
private int quality;
|
||||
|
||||
private int[][] starPara;
|
||||
private int starPara;
|
||||
|
||||
private int consumeItemNum;
|
||||
|
||||
private int consumeRes;
|
||||
private int[][] consumeRes;
|
||||
|
||||
private int sumConsume;
|
||||
private int[][] sumConsume;
|
||||
|
||||
|
||||
@Override
|
||||
private int sumItemNum;
|
||||
|
||||
public static Map<Integer,Map<Integer,SSpiritAnimalStar>> configByQualityAndStar;
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
Map<Integer,Map<Integer,SSpiritAnimalStar>> tempConfigByQualityAndStar = new HashMap<>();
|
||||
Map<Integer, SSpiritAnimalStar> config = STableManager.getConfig(SSpiritAnimalStar.class);
|
||||
for(Map.Entry<Integer,SSpiritAnimalStar> entry:config.entrySet()){
|
||||
SSpiritAnimalStar value = entry.getValue();
|
||||
tempConfigByQualityAndStar.computeIfAbsent(value.getQuality(),n->new HashMap<>()).put(value.getStar(),value);
|
||||
}
|
||||
configByQualityAndStar = tempConfigByQualityAndStar;
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,7 +51,7 @@ public class SSpiritAnimalStar implements BaseConfig {
|
|||
return quality;
|
||||
}
|
||||
|
||||
public int[][] getStarPara() {
|
||||
public int getStarPara() {
|
||||
return starPara;
|
||||
}
|
||||
|
||||
|
@ -49,13 +59,15 @@ public class SSpiritAnimalStar implements BaseConfig {
|
|||
return consumeItemNum;
|
||||
}
|
||||
|
||||
public int getConsumeRes() {
|
||||
public int[][] getConsumeRes() {
|
||||
return consumeRes;
|
||||
}
|
||||
|
||||
public int getSumConsume() {
|
||||
public int[][] getSumConsume() {
|
||||
return sumConsume;
|
||||
}
|
||||
|
||||
|
||||
public int getSumItemNum() {
|
||||
return sumItemNum;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue