灵兽提交

back_recharge
lvxinran 2020-10-22 20:26:40 +08:00
parent 03069929b7
commit bf282624e7
6 changed files with 169 additions and 34 deletions

View File

@ -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 PokemonBookEnableHandler extends BaseHandler<HeroInfoProto.PokemonBookEnableRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.POKEMON_BOOK_ENABLE_REQUEST;
}
@Override
public void processWithProto(ISession iSession, HeroInfoProto.PokemonBookEnableRequest proto) throws Exception {
HeroLogic.getInstance().pokemonBookEnable(iSession,proto.getBookId(),MessageTypeProto.MessageType.POKEMON_BOOK_ENABLE_REPONSE);
}
}

View File

@ -5,7 +5,9 @@ import com.ljsd.jieling.db.mongo.MongoKey;
import com.ljsd.jieling.logic.dao.root.User;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class PokemonManager extends MongoBase {
private Map<String,Pokemon> pokemonMap=new HashMap<>();
@ -13,6 +15,11 @@ public class PokemonManager extends MongoBase {
// 异妖编队
private Map<Integer, String> pokemonTeamMap = new HashMap<>();
private Set<Integer> pokemonGot = new HashSet<>();
private Set<Integer> pokemonBookEnabled = new HashSet<>();
public PokemonManager() {
this.setRootCollection(User._COLLECTION_NAME);
}
@ -51,5 +58,23 @@ public class PokemonManager extends MongoBase {
}
public Set<Integer> getPokemonGot() {
return pokemonGot;
}
public void addPokemonGot(int pokemonId) {
pokemonGot.add(pokemonId);
updateString("pokemonGot", pokemonGot);
}
public Set<Integer> getPokemonBookEnabled() {
return pokemonBookEnabled;
}
public void addPokemonBookEnabled(int bookId) {
pokemonBookEnabled.add(bookId);
updateString("pokemonBookEnabled", pokemonBookEnabled);
}
}

View File

@ -15,9 +15,9 @@ public class TeamPosManager extends MongoBase {
@Transient
private int curTeamPosId;
@Transient
private Map<Integer,int[][]> cacheTeamPro = new HashMap<>(5);
private Map<Integer,int[][]> cacheTeamPro = new HashMap<>(6);
@Transient
private Map<Integer,List<Integer>> cachePassskill = new HashMap<>(5);
private Map<Integer,List<Integer>> cachePassskill = new HashMap<>(6);
public TeamPosManager(){
this.setRootCollection(User._COLLECTION_NAME);

View File

@ -1380,25 +1380,22 @@ public class HeroLogic{
PokemonManager pokemonManager = user.getPokemonManager();
SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId());
int profession = scHero.getProfession();
int heroNum = user.getTeamPosManager().getTeamPosForHero().get(teamId).size();
int[][] pokemonAttr = calPokenmonAttribute(pokemonManager);
for(int i = 0 ; i <pokemonAttr.length;i++){
pokemonAttr[i][1] = pokemonAttr[i][1]/heroNum;
}
combinedAttribute(pokemonAttr,heroAllAttribute);
//todo 灵兽
// Map<Integer, Pokemon> pokemonMap = pokemonManager.getPokemonMap();
// for(Map.Entry<Integer,Pokemon> item : pokemonMap.entrySet()){
// Pokemon pokemon = item.getValue();
// Map<Integer, Integer> comonpentsLevelMap = pokemon.getComonpentsLevelMap();
// for(Map.Entry<Integer, Integer> comonpentsLevelItem : comonpentsLevelMap.entrySet()){
// Integer comonpentId = comonpentsLevelItem.getKey();
// Integer comonpentLevel = comonpentsLevelItem.getValue();
// Map<Integer, SDifferDemonsComonpentsConfig> sDifferDemonsComonpentsConfigMap = SDifferDemonsComonpentsConfig.getsDifferDemonsComonpentsConfigMap(comonpentId);
// SDifferDemonsComonpentsConfig sDifferDemonsComonpentsConfig = sDifferDemonsComonpentsConfigMap.get(comonpentLevel);
// Map<Integer, Map<Integer, Integer>> extraAddMap = sDifferDemonsComonpentsConfig.getExtraAddMap();
// if(extraAddMap!=null&&(extraAddMap.containsKey(profession)||extraAddMap.containsKey(0))){
// int innerId = extraAddMap.containsKey(0) ? 0 : profession;
// Map<Integer, Integer> professionAddMap = extraAddMap.get(innerId);
// combinedAttribute(professionAddMap,heroAllAttribute);
// }
// combinedAttribute(sDifferDemonsComonpentsConfig.getBaseAttribute(),heroAllAttribute);
// }
// }
//灵兽图鉴加成
Set<Integer> pokemonBookEnabled = pokemonManager.getPokemonBookEnabled();
if(!pokemonBookEnabled.isEmpty()){
Map<Integer, SSpiritAnimalBook> config = STableManager.getConfig(SSpiritAnimalBook.class);
for(int bootId:pokemonBookEnabled){
int[][] activePara = config.get(bootId).getActivePara();
combinedAttribute(activePara,heroAllAttribute);
}
}
//装备总战力评分
int equipForce=0;
boolean needRemove = false;
@ -1807,7 +1804,7 @@ public class HeroLogic{
Integer propertyId = item.getKey();
float propertyValue = item.getValue();
if(propertyId == HeroAttributeEnum.EquipForce.getPropertyId()){
// LOGGER.info("the equipScore={}",propertyValue);
LOGGER.info("the equipScore={}",propertyValue);
continue;
}
SPropertyConfig sPropertyConfig = SPropertyConfig.getsPropertyConfigByPID(propertyId);
@ -1817,9 +1814,9 @@ public class HeroLogic{
float score = sPropertyConfig.getScore();
result += propertyValue*score;
// LOGGER.info("the propertyId={} the value is ={},propertyValue={},score={}result ={},the value={}",propertyId,propertyValue*score,propertyValue,score,result,propertyValue*score);
LOGGER.info("the propertyId={} the value is ={},propertyValue={},score={}result ={},the value={}",propertyId,propertyValue*score,propertyValue,score,result,propertyValue*score);
}
// System.out.println(result);
System.out.println(result);
return (int)result;
}
@ -1838,10 +1835,6 @@ public class HeroLogic{
for(int[] item : otherAttriMap){
int propertyId = item[0];
int propertyValue = item[1];
// if(heroAttributeMap.containsKey(propertyId)){
// propertyValue += heroAttributeMap.get(propertyId);
// }
// heroAttributeMap.put(propertyId,propertyValue);
heroAttributeMap.put(propertyId,heroAttributeMap.getOrDefault(propertyId,0)+propertyValue);
}
}
@ -2210,10 +2203,34 @@ public class HeroLogic{
return result;
}
public int calPokenmonForce(Pokemon pokemon){
public int[][] calPokenmonAttribute(PokemonManager pokemonManager){
Map<Integer,Integer> pokemonAttributeMap = new HashMap<>();
combinePokemonAttribute(pokemonAttributeMap, pokemon,false);
return calForce(pokemonAttributeMap)*5;
Map<Integer, String> pokemonTeamMap = pokemonManager.getPokemonTeamMap();
for(Map.Entry<Integer,String> entry:pokemonTeamMap.entrySet()){
Pokemon pokemon = pokemonManager.getPokemonMap().get(entry.getValue());
Map<Integer,Integer> oneAttrMap = new HashMap<>();
SSpiritAnimal animal = STableManager.getConfig(SSpiritAnimal.class).get(pokemon.getTmpId());
oneAttrMap.put(GlobalsDef.HP_TYPE,(int)animal.getHp());
oneAttrMap.put(GlobalsDef.ATTACK_TYPE,(int)animal.getAttack());
oneAttrMap.put(GlobalsDef.PHYSICAL_DEFENCE_TYPE,(int)animal.getPhysicalDefence());
oneAttrMap.put(GlobalsDef.MAGIC_DEFENCE_TYPE,(int)animal.getMagicDefence());
//等级增量
SSpiritAnimalLevel levelConfig = SSpiritAnimalLevel.configByQualityAndLevel.get(animal.getQuality()).get(pokemon.getLevel());
int[][] characterLevelPara = levelConfig.getCharacterLevelPara();
for(int[] para:characterLevelPara){
oneAttrMap.put(para[0],oneAttrMap.getOrDefault(para[0],0)+para[1]);
}
//星级增量
SSpiritAnimalStar starConfig = SSpiritAnimalStar.configByQualityAndStar.get(animal.getQuality()).get(pokemon.getStar());
int starPara = starConfig.getStarPara();
for(int key:oneAttrMap.keySet()){
pokemonAttributeMap.put(key,pokemonAttributeMap.getOrDefault(key,0)+(int)(oneAttrMap.getOrDefault(key,0)*(1+starPara/10000d)));
}
}
int[][] resultArray = ItemUtil.mapToArray(pokemonAttributeMap);
return resultArray;
}
//todo 灵兽
@ -2635,6 +2652,7 @@ public class HeroLogic{
hero.removeSoulEquip(e.getPosition());
returnItems.put(e.getEquipId(),1);
});
Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(iSession.getUid()));
ItemUtil.dropMap(user,returnItems,BIReason.UNLOAD_SOUL_REWARD);
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.SOUL_EQUIP_UNLOAD_OPT_RESPONSE_VALUE,null,true);
}
@ -2696,6 +2714,8 @@ public class HeroLogic{
}
HeroInfoProto.GetAllPokemonResponse build = HeroInfoProto.GetAllPokemonResponse.newBuilder().addAllPokemonInfo(pokemonInfoList)
.addAllTeamPokemonInfos(teamPokemonInfos)
.addAllPokemonGot(pokemonManager.getPokemonGot())
.addAllPokemonBookEnabled(pokemonManager.getPokemonBookEnabled())
.build();
MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.GET_ALL_POKEMON_RESPONSE_VALUE,build,true);
}
@ -2738,6 +2758,9 @@ public class HeroLogic{
throw new ErrorCodeException(ErrorCode.newDefineCode("Pokemon null"));
}
user.getPokemonManager().updatePokemonTeamMap(pokemonTeamMap);
Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(session.getUid()));
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.POKEMON_REPLACE_RESPONSE.getNumber(), null);
}
@ -2773,6 +2796,9 @@ public class HeroLogic{
if(pokemon == null){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
if(pokemonManager.getPokemonTeamMap().containsValue(pokemonId)){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
getPokemonReturnReward(pokemon,returnMap);
SSpiritAnimal animalConfig = STableManager.getConfig(SSpiritAnimal.class).get(pokemon.getTmpId());
@ -2863,7 +2889,14 @@ public class HeroLogic{
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
Map<Integer, SSpiritAnimalLevel> levelMap = SSpiritAnimalLevel.configByQualityAndLevel.get(3);
SSpiritAnimal animal = STableManager.getConfig(SSpiritAnimal.class).get(pokemon.getTmpId());
if(animal==null){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
if(level>=animal.getMaxLevel()){
throw new ErrorCodeException(ErrorCode.HERO_LEVE_MAX);
}
Map<Integer, SSpiritAnimalLevel> levelMap = SSpiritAnimalLevel.configByQualityAndLevel.get(animal.getQuality());
Map<Integer,Integer> costMap = new HashMap<>();
int finalLevel = pokemon.getLevel();
for(int i = pokemon.getLevel();i<level;i++){
@ -2893,6 +2926,10 @@ public class HeroLogic{
ItemUtil.itemCost(user,costMap,BIReason.SPECIAL_LEVEL_UP_CONSUME,1);
pokemonManager.updatePokemonLevel(pokemonId,finalLevel);
if(pokemonManager.getPokemonTeamMap().containsValue(pokemonId)){
Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(session.getUid()));
}
HeroInfoProto.PokenmonUpLevelResponse response = HeroInfoProto.PokenmonUpLevelResponse.newBuilder().setLevel(finalLevel).build();
//发送成功消息
MessageUtil.sendMessage(session,1,messageType.getNumber(),response,true);
@ -2915,7 +2952,14 @@ public class HeroLogic{
if(pokemon == null){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
Map<Integer, SSpiritAnimalStar> configMap = SSpiritAnimalStar.configByQualityAndStar.get(3);
SSpiritAnimal animal = STableManager.getConfig(SSpiritAnimal.class).get(pokemon.getTmpId());
if(animal==null){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
if(pokemon.getStar()>=animal.getMaxStar()){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
Map<Integer, SSpiritAnimalStar> configMap = SSpiritAnimalStar.configByQualityAndStar.get(animal.getQuality());
if(!configMap.containsKey(pokemon.getStar())){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
@ -2945,6 +2989,9 @@ public class HeroLogic{
pokemonManager.removePokemon(consume);
}
pokemonManager.updatePokemonStar(pokemonId,pokemon.getStar()+1);
if(pokemonManager.getPokemonTeamMap().containsValue(pokemonId)){
Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(session.getUid()));
}
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.POKEMON_ADVANCED_RESPONSE_VALUE,null,true);
}
@ -2993,4 +3040,38 @@ public class HeroLogic{
MessageUtil.sendMessage(session, 1, messageType.getNumber(), response, true);
}
/**
*
* @param session
* @param bookId
* @param messageType
*/
public void pokemonBookEnable(ISession session, int bookId, MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
PokemonManager pokemonManager = user.getPokemonManager();
if(pokemonManager.getPokemonBookEnabled().contains(bookId)){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
SSpiritAnimalBook bookConfig = STableManager.getConfig(SSpiritAnimalBook.class).get(bookId);
if(bookConfig==null){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
int[] teamers = bookConfig.getTeamers();
for(int pokemon:teamers){
if(!pokemonManager.getPokemonGot().contains(pokemon)){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
}
pokemonManager.addPokemonBookEnabled(bookId);
Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(session.getUid()));
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
}
}

View File

@ -1593,6 +1593,9 @@ public class ItemUtil {
for(int i = 0 ; i <entry.getValue();i++){
Pokemon pokemon = new Pokemon(user.getId(),entry.getKey());
user.getPokemonManager().addPokemon(pokemon);
if(user.getPokemonManager().getPokemonGot().contains(pokemon.getTmpId())){
user.getPokemonManager().addPokemonGot(pokemon.getTmpId());
}
dropBuilder.addPokemon(CBean2Proto.getPokemon(pokemon));
}
}

View File

@ -10,7 +10,7 @@ public class SSpiritAnimalBook implements BaseConfig {
private int id;
private int[][] teamers;
private int[] teamers;
private int[][] activePara;
@ -27,7 +27,7 @@ public class SSpiritAnimalBook implements BaseConfig {
return id;
}
public int[][] getTeamers() {
public int[] getTeamers() {
return teamers;
}