灵兽上阵
parent
871ba646e0
commit
c8622ee56d
|
@ -36,6 +36,7 @@ import com.ljsd.jieling.protocols.MessageTypeProto;
|
|||
import com.ljsd.jieling.util.*;
|
||||
import config.*;
|
||||
import manager.STableManager;
|
||||
import org.luaj.vm2.ast.Str;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import util.MathUtils;
|
||||
|
@ -688,40 +689,6 @@ public class HeroLogic{
|
|||
MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.TEAM_POS_SAVE_RESPONSE_VALUE,null,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存异妖阵容
|
||||
* @param session
|
||||
* @param teamPokemonInfos
|
||||
*/
|
||||
public void savePokemonTeam(ISession session, List<CommonProto.TeamPokemonInfo> teamPokemonInfos) throws Exception {
|
||||
if (teamPokemonInfos == null) {
|
||||
LOGGER.info("savePokemonTeam uid=>{} , teamPokemonInfos isEmpty", session.getUid());
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("Pokemon null"));
|
||||
}
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
int level = user.getPlayerInfoManager().getLevel();
|
||||
int openCount = 0;
|
||||
for (int sprintLevel : SSpiritAnimalSetting.sSpiritAnimalSetting.getBlockUnlockLevel()) {
|
||||
if (level >= sprintLevel) {
|
||||
openCount++;
|
||||
}
|
||||
}
|
||||
if (teamPokemonInfos.size() > openCount) {
|
||||
LOGGER.info("savePokemonTeam uid=>{} , count is wrong ", session.getUid());
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("count is wrong : " + openCount));
|
||||
}
|
||||
Map<String, Pokemon> pokemonMap = user.getPokemonManager().getPokemonMap();
|
||||
Map<Integer, String> pokemonTeamMap = new HashMap<>();
|
||||
for (CommonProto.TeamPokemonInfo teamPokemonInfo : teamPokemonInfos) {
|
||||
if (!pokemonMap.containsKey(teamPokemonInfo.getPokemonId())) {
|
||||
LOGGER.info("savePokemonTeam uid=>{} , pokemon non-existent id=>{}", user.getId(), teamPokemonInfo.getPokemonId());
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("Pokemon null"));
|
||||
}
|
||||
pokemonTeamMap.put(teamPokemonInfo.getPosition(), teamPokemonInfo.getPokemonId());
|
||||
}
|
||||
user.getPokemonManager().updatePokemonTeamMap(pokemonTeamMap);
|
||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.POKEMON_REPLACE_RESPONSE.getNumber(), null);
|
||||
}
|
||||
|
||||
public String checkTeamPos(User user, int teamId,List<CommonProto.TeamHeroInfo> heroIds){
|
||||
if(heroIds ==null || heroIds.isEmpty()){
|
||||
|
@ -2111,59 +2078,6 @@ public class HeroLogic{
|
|||
return quality;
|
||||
}
|
||||
|
||||
public void getAllPokemon(ISession iSession) throws Exception {
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
PokemonManager pokemonManager = user.getPokemonManager();
|
||||
//todo 灵兽
|
||||
Map<String, Pokemon> pokemonMap = pokemonManager.getPokemonMap();
|
||||
//
|
||||
// //TODO 测试
|
||||
// if(pokemonMap.isEmpty()){
|
||||
// for(SDifferDemonsConfig sDifferDemonsConfig : SDifferDemonsConfig.sDifferDemonsConfigMap.values() ){
|
||||
// pokemonManager.addPokemon(new Pokemon(sDifferDemonsConfig.getId()));
|
||||
// }
|
||||
// }
|
||||
List<CommonProto.PokemonInfo> pokemonInfoList = new ArrayList<>();
|
||||
//
|
||||
for(Pokemon pokemon : pokemonMap.values()){
|
||||
pokemonInfoList.add(CBean2Proto.getPokemon(pokemon));
|
||||
}
|
||||
List<CommonProto.TeamPokemonInfo> teamPokemonInfos = new ArrayList<>();
|
||||
for (Map.Entry<Integer, String> entry : pokemonManager.getPokemonTeamMap().entrySet()) {
|
||||
CommonProto.TeamPokemonInfo teamPokemonInfo = CommonProto.TeamPokemonInfo.newBuilder()
|
||||
.setPokemonId(entry.getValue())
|
||||
.setPosition(entry.getKey())
|
||||
.build();
|
||||
teamPokemonInfos.add(teamPokemonInfo);
|
||||
}
|
||||
HeroInfoProto.GetAllPokemonResponse build = HeroInfoProto.GetAllPokemonResponse.newBuilder().addAllPokemonInfo(pokemonInfoList)
|
||||
.addAllTeamPokemonInfos(teamPokemonInfos)
|
||||
.build();
|
||||
MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.GET_ALL_POKEMON_RESPONSE_VALUE,build,true);
|
||||
}
|
||||
|
||||
//异妖相关 组件放置升级
|
||||
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();
|
||||
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,messageType.getNumber(),null,true);
|
||||
// user.getUserMissionManager().onGameEvent(user,GameEvent.POKEMON_UPLEVEL,pokemonId);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
public void pokemonAdvanced(ISession session,int pokemonId) throws Exception {
|
||||
// int uid = session.getUid();
|
||||
|
@ -2834,4 +2748,106 @@ public class HeroLogic{
|
|||
}
|
||||
}
|
||||
|
||||
//============= 灵兽(异妖)系统 ========================
|
||||
|
||||
/**
|
||||
* 获取所有异妖
|
||||
* @param iSession
|
||||
* @throws Exception
|
||||
*/
|
||||
public void getAllPokemon(ISession iSession) throws Exception {
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
PokemonManager pokemonManager = user.getPokemonManager();
|
||||
//todo 灵兽
|
||||
Map<String, Pokemon> pokemonMap = pokemonManager.getPokemonMap();
|
||||
//
|
||||
// //TODO 测试
|
||||
// if(pokemonMap.isEmpty()){
|
||||
// for(SDifferDemonsConfig sDifferDemonsConfig : SDifferDemonsConfig.sDifferDemonsConfigMap.values() ){
|
||||
// pokemonManager.addPokemon(new Pokemon(sDifferDemonsConfig.getId()));
|
||||
// }
|
||||
// }
|
||||
List<CommonProto.PokemonInfo> pokemonInfoList = new ArrayList<>();
|
||||
//
|
||||
for(Pokemon pokemon : pokemonMap.values()){
|
||||
pokemonInfoList.add(CBean2Proto.getPokemon(pokemon));
|
||||
}
|
||||
List<CommonProto.TeamPokemonInfo> teamPokemonInfos = new ArrayList<>();
|
||||
for (Map.Entry<Integer, String> entry : pokemonManager.getPokemonTeamMap().entrySet()) {
|
||||
CommonProto.TeamPokemonInfo teamPokemonInfo = CommonProto.TeamPokemonInfo.newBuilder()
|
||||
.setPokemonId(entry.getValue())
|
||||
.setPosition(entry.getKey())
|
||||
.build();
|
||||
teamPokemonInfos.add(teamPokemonInfo);
|
||||
}
|
||||
HeroInfoProto.GetAllPokemonResponse build = HeroInfoProto.GetAllPokemonResponse.newBuilder().addAllPokemonInfo(pokemonInfoList)
|
||||
.addAllTeamPokemonInfos(teamPokemonInfos)
|
||||
.build();
|
||||
MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.GET_ALL_POKEMON_RESPONSE_VALUE,build,true);
|
||||
}
|
||||
|
||||
//异妖相关 组件放置升级
|
||||
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();
|
||||
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,messageType.getNumber(),null,true);
|
||||
// user.getUserMissionManager().onGameEvent(user,GameEvent.POKEMON_UPLEVEL,pokemonId);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存异妖阵容
|
||||
* @param session
|
||||
* @param teamPokemonInfos
|
||||
*/
|
||||
public void savePokemonTeam(ISession session, List<CommonProto.TeamPokemonInfo> teamPokemonInfos) throws Exception {
|
||||
if (teamPokemonInfos == null) {
|
||||
LOGGER.info("savePokemonTeam uid=>{} , teamPokemonInfos isEmpty", session.getUid());
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("Pokemon null"));
|
||||
}
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
int level = user.getPlayerInfoManager().getLevel();
|
||||
int openCount = 0;
|
||||
for (int sprintLevel : SSpiritAnimalSetting.sSpiritAnimalSetting.getBlockUnlockLevel()) {
|
||||
if (level >= sprintLevel) {
|
||||
openCount++;
|
||||
}
|
||||
}
|
||||
if (teamPokemonInfos.size() > openCount) {
|
||||
LOGGER.info("savePokemonTeam uid=>{} , count is wrong ", session.getUid());
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("count is wrong : " + openCount));
|
||||
}
|
||||
Map<String, Pokemon> pokemonMap = user.getPokemonManager().getPokemonMap();
|
||||
Map<Integer, String> pokemonTeamMap = new HashMap<>();
|
||||
Set<String> addpokemons = new HashSet<>();
|
||||
for (CommonProto.TeamPokemonInfo teamPokemonInfo : teamPokemonInfos) {
|
||||
if (!pokemonMap.containsKey(teamPokemonInfo.getPokemonId())) {
|
||||
LOGGER.info("savePokemonTeam uid=>{} , pokemon non-existent id=>{}", user.getId(), teamPokemonInfo.getPokemonId());
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("Pokemon null"));
|
||||
}
|
||||
addpokemons.add(teamPokemonInfo.getPokemonId());
|
||||
pokemonTeamMap.put(teamPokemonInfo.getPosition(), teamPokemonInfo.getPokemonId());
|
||||
}
|
||||
if (addpokemons.size() != pokemonTeamMap.size()) {
|
||||
LOGGER.info("savePokemonTeam uid=>{} , pokemon non-existent id=>{} =>{}", user.getId(), addpokemons.size(), addpokemons.size());
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("Pokemon null"));
|
||||
}
|
||||
user.getPokemonManager().updatePokemonTeamMap(pokemonTeamMap);
|
||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.POKEMON_REPLACE_RESPONSE.getNumber(), null);
|
||||
}
|
||||
|
||||
|
||||
// public void
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue