修改灵兽

back_recharge
lvxinran 2020-10-19 19:58:52 +08:00
parent 42c7e31723
commit 1c0cbabcad
4 changed files with 30 additions and 38 deletions

View File

@ -9,18 +9,14 @@ import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class PokemonComonpentLevelupHandler extends BaseHandler {
public class PokemonLevelupHandler extends BaseHandler<HeroInfoProto.PokenmonUpLevelRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.POKEMON_COMONPENT_LEVELUP_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
byte[] bytes = netData.parseClientProtoNetData();
HeroInfoProto.PokenmonUpLevelRequest pokenmonUpLevelRequest = HeroInfoProto.PokenmonUpLevelRequest.parseFrom(bytes);
int comonpentId = pokenmonUpLevelRequest.getComonpentId();
int pokemonId = pokenmonUpLevelRequest.getPokemonId();
HeroLogic.getInstance().pokenmonUpLevel(iSession,pokemonId,comonpentId);
public void processWithProto(ISession iSession, HeroInfoProto.PokenmonUpLevelRequest proto) throws Exception {
HeroLogic.getInstance().pokemonUpLevel(iSession,proto.getPokemonId(),proto.getLevel(), MessageTypeProto.MessageType.POKEMON_COMONPENT_LEVELUP_RESPONSE);
}
}

View File

@ -25,6 +25,12 @@ public class PokemonManager extends MongoBase {
// ringFireMap.put(pokemon.getId(),pokemon);
// }
public void updatePokemonLevel(String id,int level){
pokemonMap.get(id).setLevel(level);
updateString("pokemonMap." + id+".level", level);
}
public Map<String, Pokemon> getPokemonMap() {
return pokemonMap;

View File

@ -2125,7 +2125,7 @@ public class HeroLogic{
User user = UserManager.getUser(uid);
PokemonManager pokemonManager = user.getPokemonManager();
//todo 灵兽
// Map<Integer, Pokemon> pokemonMap = pokemonManager.getPokemonMap();
Map<String, Pokemon> pokemonMap = pokemonManager.getPokemonMap();
//
// //TODO 测试
// if(pokemonMap.isEmpty()){
@ -2133,45 +2133,33 @@ public class HeroLogic{
// pokemonManager.addPokemon(new Pokemon(sDifferDemonsConfig.getId()));
// }
// }
// List<CommonProto.PokemonInfo> pokemonInfoList = new ArrayList<>();
List<CommonProto.PokemonInfo> pokemonInfoList = new ArrayList<>();
//
// for(Pokemon pokemon : pokemonMap.values()){
// pokemonInfoList.add(CBean2Proto.getPokemon(pokemon));
// }
for(Pokemon pokemon : pokemonMap.values()){
pokemonInfoList.add(CBean2Proto.getPokemon(pokemon));
}
// HeroInfoProto.GetAllPokemonResponse build = HeroInfoProto.GetAllPokemonResponse.newBuilder().addAllPokemonInfo(pokemonInfoList).build();
MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.GET_ALL_POKEMON_RESPONSE_VALUE,null,true);
HeroInfoProto.GetAllPokemonResponse build = HeroInfoProto.GetAllPokemonResponse.newBuilder().addAllPokemonInfo(pokemonInfoList).build();
MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.GET_ALL_POKEMON_RESPONSE_VALUE,build,true);
}
//异妖相关 组件放置升级
public void pokenmonUpLevel(ISession session,int pokemonId,int comonpentId) throws Exception {
public void pokemonUpLevel(ISession session, String pokemonId, int level, MessageTypeProto.MessageType messageType) throws Exception {
//todo 灵兽
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);
// }
// Integer oldLevel = pokemon.getComonpentsLevelMap().get(comonpentId);
// if( null == oldLevel){
// //消耗组件
// boolean enough = ItemUtil.itemCost(user, new int[][]{{comonpentId, 1}},BIReason.POKEMON_LOAD_CONSUME,pokemonId);
// if(!enough){
// throw new ErrorCodeException(ErrorCode.newDefineCode("not enough"));
// }
// pokemon.upOrActiveComonpent(comonpentId);
// MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.POKEMON_COMONPENT_LEVELUP_RESPONSE_VALUE,null,true);
// user.getUserMissionManager().onGameEvent(user,GameEvent.POKEMON_UPLEVEL,pokemonId);
// return;
// }
// if (checkPokemonComonpent(pokemonId, comonpentId,oldLevel, user)){
// throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
// }
// pokemon.upOrActiveComonpent(comonpentId);
User user = UserManager.getUser(uid);
PokemonManager pokemonManager = user.getPokemonManager();
if(!pokemonManager.getPokemonMap().containsKey(pokemonId)){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
Pokemon pokemon = pokemonManager.getPokemonMap().get(pokemonId);
pokemonManager.updatePokemonLevel(pokemonId,level);
//发送成功消息
MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.POKEMON_COMONPENT_LEVELUP_RESPONSE_VALUE,null,true);
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
// user.getUserMissionManager().onGameEvent(user,GameEvent.POKEMON_UPLEVEL,pokemonId);
}

View File

@ -20,6 +20,8 @@ public class SSpiritAnimalLevel implements BaseConfig {
private int[][] sumConsume;
public static Map<Integer,Map<Integer,SSpiritAnimalLevel>> configByQualityAndLevel;
@Override
public void init() throws Exception {