@ -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 / 10000 d ) ) ) ;
}
}
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 ) ;
}
}