好感度代码提交
parent
db8504e51f
commit
8dc19f2d98
|
@ -70,6 +70,8 @@ public enum FunctionIdEnum {
|
|||
HongMeng(86,null),
|
||||
CrossYuxulundao(87,null),//跨服-玉虚论道
|
||||
CrossSevenWorld(112,new SevenWorldFunction()),//七界试炼
|
||||
FourQua(113,null),//四象心法
|
||||
Likable(114,null),//好感度
|
||||
WeekGood(9091,null),
|
||||
|
||||
;
|
||||
|
|
|
@ -347,6 +347,8 @@ public interface BIReason {
|
|||
|
||||
int SIXIANG_UP_STAR_COST=1106;//四象心法进阶消耗
|
||||
|
||||
int HERO_UP_LIKEBLE_COST=1107;//英雄提升好感度消耗
|
||||
|
||||
int FOUR_CHALLENGE_FIRST = 1201;//四灵试炼首通
|
||||
int FOUR_CHALLENGE_SWEEP = 1202;//四灵试炼扫荡
|
||||
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package com.ljsd.jieling.handler.hero;
|
||||
|
||||
import com.google.protobuf.GeneratedMessage;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
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.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.HeroInfoProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
///获取好感度数据请求
|
||||
@Component
|
||||
public class GetLikableDataRequestHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.GET_LIKABLE_DATA_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession session, PacketNetData netData) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
Map<Integer,Integer> likaMap=user.getHeroManager().getHeroLikableMap();
|
||||
List<CommonProto.LikableInfo> _list=new ArrayList<>();
|
||||
for (Map.Entry<Integer, Integer> integerEntry : likaMap.entrySet()) {
|
||||
CommonProto.LikableInfo likaInfo=CommonProto.LikableInfo.newBuilder()
|
||||
.setHeroStaticid(integerEntry.getKey())
|
||||
.setLikableNum(integerEntry.getValue())
|
||||
.build();
|
||||
_list.add(likaInfo);
|
||||
}
|
||||
HeroInfoProto.GetLikableDataResponse response=HeroInfoProto.GetLikableDataResponse.newBuilder()
|
||||
.addAllInfoList(_list)
|
||||
.build();
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.GET_LIKABLE_DATA_RESPONSE_VALUE,response,true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,155 @@
|
|||
package com.ljsd.jieling.handler.hero;
|
||||
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.dao.HeroManager;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SCHero;
|
||||
import config.SItem;
|
||||
import config.SLikeAbilityConfig;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.HeroInfoProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
//英雄好感度提升消息
|
||||
@Component
|
||||
public class HeroUpLikableRequestHandler extends BaseHandler<HeroInfoProto.HeroUpLikableRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.HERO_UP_LIKABLE_REQUEST;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession session, HeroInfoProto.HeroUpLikableRequest proto) throws Exception {
|
||||
int heroStaticId=proto.getHeroStaticId();//英雄静态id
|
||||
int itemId=proto.getItemId();//消耗道具id
|
||||
int itemNum=proto.getItemNum();//消耗道具数量
|
||||
int uid = session.getUid();
|
||||
|
||||
User user = UserManager.getUser(uid);
|
||||
HeroManager heroManager=user.getHeroManager();
|
||||
int[][]costArr=new int[2][1];
|
||||
costArr[0][0]=itemId;
|
||||
costArr[0][1]=itemNum;
|
||||
boolean costResult = ItemUtil.itemCost(user,costArr, BIReason.HERO_UP_LIKEBLE_COST,heroStaticId);
|
||||
if (costResult){
|
||||
SItem _item= SItem.getsItemMap().get(itemId);
|
||||
int profession=SCHero.getsCHero().get(heroStaticId).getProfession();
|
||||
String[]addArr=_item.getResolveReward().split("|");
|
||||
String addStr=addArr[profession-1];
|
||||
int singleAddNum=Integer.parseInt(addStr.split("#")[1]);
|
||||
int allAddNum=singleAddNum*itemNum;
|
||||
int curHeroLikableNum = heroManager.getHeroLikableMap().containsKey(heroStaticId)?user.getHeroManager().getHeroLikableMap().get(heroStaticId):0;
|
||||
int oldLv=GetHeroLikableLvByLikaNum(curHeroLikableNum);
|
||||
curHeroLikableNum+=allAddNum;
|
||||
int curLv=GetHeroLikableLvByLikaNum(curHeroLikableNum);
|
||||
if (curLv>oldLv){
|
||||
Map<Integer,Integer>curHeroPropAdd=GetHeroLikableAddPeop(curLv);
|
||||
heroManager.putHeroLikablePropAddMap(heroStaticId,curHeroPropAdd);
|
||||
}
|
||||
|
||||
int oldAllLikaLv=GetAllLikableLvByLikaNum(GetAllHeroLikableNum(heroManager.getHeroLikableMap()));
|
||||
heroManager.putHeroLikableMap(heroStaticId,curHeroLikableNum);
|
||||
int curAllLikaLv=GetAllLikableLvByLikaNum(GetAllHeroLikableNum(heroManager.getHeroLikableMap()));
|
||||
if (curAllLikaLv>oldAllLikaLv){
|
||||
Map<Integer,Integer>allHeroPropAdd=GetAllHeroLikableAddPeop(curAllLikaLv);
|
||||
heroManager.putAllLikablePropAddMap(allHeroPropAdd);
|
||||
}
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.HERO_UP_LIKABLE_RESPONSE_VALUE, null,true);
|
||||
}else{
|
||||
LOGGER.error("好感度提升材料不足");
|
||||
throw new ErrorCodeException(ErrorCode.HERO_ITEM_NOT);
|
||||
}
|
||||
}
|
||||
///通过神将好感度获取好感度等级
|
||||
public int GetHeroLikableLvByLikaNum(int _likaNum){
|
||||
int likaLv=0;
|
||||
for (Map.Entry<Integer, Integer> integerEntry : SLikeAbilityConfig.heroLikeAbilityByLevel.entrySet()) {
|
||||
if (_likaNum>=integerEntry.getValue()){
|
||||
likaLv= integerEntry.getKey();
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return likaLv;
|
||||
}
|
||||
///通过总好感度获取好感度等级
|
||||
public int GetAllLikableLvByLikaNum(int _likaNum){
|
||||
int likaLv=0;
|
||||
for (Map.Entry<Integer, Integer> integerEntry : SLikeAbilityConfig.allLikeAbilityByLevel.entrySet()) {
|
||||
if (_likaNum>=integerEntry.getValue()){
|
||||
likaLv= integerEntry.getKey();
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return likaLv;
|
||||
}
|
||||
//通过当前等级获取神将好感度属性加成
|
||||
public Map<Integer,Integer>GetHeroLikableAddPeop(int _lv){
|
||||
Map<Integer,Integer>_propMap=new HashMap<>();
|
||||
for (int i = 0; i <= _lv; i++) {
|
||||
SLikeAbilityConfig _config= SLikeAbilityConfig.heroLikeAbilityConfigMap.get(_lv);
|
||||
if (_config.getProperty()==null)continue;
|
||||
for (int[] ints : _config.getProperty()) {
|
||||
if (_propMap.containsKey(ints[1])) {
|
||||
int absProp=_propMap.get(ints[1])+ints[2];
|
||||
_propMap.put(ints[1],absProp);
|
||||
}else{
|
||||
_propMap.put(ints[1],ints[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return _propMap;
|
||||
}
|
||||
|
||||
//通过当前总好感度等级获取好感度属性加成
|
||||
public Map<Integer,Integer>GetAllHeroLikableAddPeop(int _allLv){
|
||||
Map<Integer,Integer>_propMap=new HashMap<>();
|
||||
for (int i = 0; i <= _allLv; i++) {
|
||||
SLikeAbilityConfig _config= SLikeAbilityConfig.allLikeAbilityConfigMap.get(_allLv);
|
||||
if (_config.getProperty()!=null){
|
||||
for (int[] ints : _config.getProperty()) {
|
||||
if (_propMap.containsKey(ints[0])) {
|
||||
int absProp=_propMap.get(ints[0])+ints[1];
|
||||
_propMap.put(ints[0],absProp);
|
||||
}else{
|
||||
_propMap.put(ints[0],ints[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_config.getPrivilegeProperty()!=null){
|
||||
for (int[] ints : _config.getPrivilegeProperty()) {
|
||||
if (_propMap.containsKey(ints[0])) {
|
||||
int absProp=_propMap.get(ints[0])+ints[1];
|
||||
_propMap.put(ints[0],absProp);
|
||||
}else{
|
||||
_propMap.put(ints[0],ints[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return _propMap;
|
||||
}
|
||||
|
||||
//获取总的好感度
|
||||
public int GetAllHeroLikableNum(Map<Integer,Integer>_heroLikableMap){
|
||||
int likableNum=0;
|
||||
for (Map.Entry<Integer, Integer> integerEntry : _heroLikableMap.entrySet()) {
|
||||
likableNum+=integerEntry.getKey();
|
||||
}
|
||||
return likableNum;
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ import com.ljsd.jieling.logic.activity.event.Poster;
|
|||
import com.ljsd.jieling.logic.activity.event.RemoveHeroEvent;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.hero.HongMengAttributeEnum;
|
||||
import config.SLikeAbilityConfig;
|
||||
import config.SSpecialConfig;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -111,6 +112,28 @@ public class HeroManager extends MongoBase {
|
|||
return sixiangPropUpMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 好感度数据
|
||||
* key: 英雄静态id value:好感度值
|
||||
*/
|
||||
private Map<Integer,Integer> heroLikableMap = new HashMap<>();
|
||||
|
||||
public Map<Integer, Integer> getHeroLikableMap() {
|
||||
return heroLikableMap;
|
||||
}
|
||||
//神将好感度属性加成
|
||||
private Map<Integer,Map<Integer,Integer>>heroLikablePropAddMap=new HashMap<>();
|
||||
|
||||
public Map<Integer,Map<Integer,Integer>>getHeroLikablePropAddMap() {
|
||||
return heroLikablePropAddMap;
|
||||
}
|
||||
//所有神将总好感度带来的属性加成(包含特权加成)
|
||||
private Map<Integer,Integer>allLikablePropAddMap=new HashMap<>();
|
||||
public Map<Integer,Integer>getAllLikablePropAddMap() {
|
||||
return allLikablePropAddMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 心愿可以选择的英雄列表
|
||||
*/
|
||||
|
@ -158,6 +181,21 @@ public class HeroManager extends MongoBase {
|
|||
updateString("sixiangPropUpMap."+professionId, _propMap);
|
||||
}
|
||||
|
||||
public void putHeroLikableMap(int heroStaticId,int likableNum) {
|
||||
heroLikableMap.put(heroStaticId,likableNum);
|
||||
updateString("heroLikableMap."+heroStaticId, likableNum);
|
||||
}
|
||||
|
||||
public void putHeroLikablePropAddMap(int heroStaticId,Map<Integer,Integer> _propMap) {
|
||||
heroLikablePropAddMap.put(heroStaticId,_propMap);
|
||||
updateString("heroLikablePropAddMap."+heroStaticId, _propMap);
|
||||
}
|
||||
|
||||
public void putAllLikablePropAddMap(Map<Integer,Integer> _propMap) {
|
||||
allLikablePropAddMap=_propMap;
|
||||
updateString("allLikablePropAddMap", allLikablePropAddMap);
|
||||
}
|
||||
|
||||
|
||||
public void updateRandCount(int type, int count){
|
||||
updateString("totalCount." + type, count);
|
||||
|
@ -493,6 +531,7 @@ public class HeroManager extends MongoBase {
|
|||
updateString("wishOpenHeroList", wishOpenHeroList);
|
||||
}
|
||||
|
||||
///获取四象心法共鸣等级
|
||||
public int GetSiXiangGongMingLv(){
|
||||
int gongmingLv=0;
|
||||
if (this.sixiangDataMap.size()<4){
|
||||
|
@ -506,5 +545,7 @@ public class HeroManager extends MongoBase {
|
|||
}
|
||||
return gongmingLv;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -2330,6 +2330,17 @@ public class HeroLogic{
|
|||
int[][]skillProp=ItemUtil.mapToArray(skillPropertyMap);
|
||||
combinedAttribute(skillProp,heroAllAttribute);
|
||||
|
||||
//英雄好感度属性加成
|
||||
if (user.getHeroManager().getHeroLikablePropAddMap().containsKey(scHero.getId())){
|
||||
int[][]likableProp=ItemUtil.mapToArray(user.getHeroManager().getHeroLikablePropAddMap().get(scHero.getId()));
|
||||
combinedAttribute(likableProp,heroAllAttribute);
|
||||
}
|
||||
//英雄总好感度属性加成
|
||||
if (user.getHeroManager().getAllLikablePropAddMap().size()>0){
|
||||
int[][]allLikableProp=ItemUtil.mapToArray(user.getHeroManager().getAllLikablePropAddMap());
|
||||
combinedAttribute(allLikableProp,heroAllAttribute);
|
||||
}
|
||||
|
||||
//装备总战力评分
|
||||
int equipForce=0;
|
||||
Iterator<Map.Entry<Integer, Integer>> iterator = hero.getEquipByHongmengPositionMap(user.getHeroManager()).entrySet().iterator();
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@Table(name ="FourQuadrantConfig")
|
||||
public class SLikeAbilityConfig implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int type;
|
||||
|
||||
private int level;
|
||||
|
||||
private int favorDegree;
|
||||
|
||||
private int[][] property;
|
||||
|
||||
private int[][] privilegeProperty;
|
||||
|
||||
|
||||
public static Map<Integer, SLikeAbilityConfig> sLikeAbilityConfigMap;
|
||||
|
||||
public static Map<Integer, SLikeAbilityConfig> heroLikeAbilityConfigMap;
|
||||
public static Map<Integer, Integer> heroLikeAbilityByLevel;
|
||||
|
||||
public static Map<Integer, SLikeAbilityConfig> allLikeAbilityConfigMap;
|
||||
public static Map<Integer, Integer> allLikeAbilityByLevel;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
heroLikeAbilityConfigMap=new HashMap<>();
|
||||
allLikeAbilityConfigMap=new HashMap<>();
|
||||
heroLikeAbilityByLevel=new TreeMap<>();
|
||||
allLikeAbilityByLevel=new TreeMap<>();
|
||||
sLikeAbilityConfigMap = STableManager.getConfig(SLikeAbilityConfig.class);
|
||||
int heroLike=0;
|
||||
int allLike=0;
|
||||
for (SLikeAbilityConfig value : sLikeAbilityConfigMap.values()) {
|
||||
if (value.type==1){
|
||||
allLikeAbilityConfigMap.put(value.level,value);
|
||||
allLike+=value.getFavorDegree();
|
||||
allLikeAbilityByLevel.put(value.level,allLike);
|
||||
}else {
|
||||
heroLikeAbilityConfigMap.put(value.level,value);
|
||||
heroLike+=value.getFavorDegree();
|
||||
heroLikeAbilityByLevel.put(value.level,heroLike);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public int getFavorDegree() {
|
||||
return favorDegree;
|
||||
}
|
||||
|
||||
public int[][] getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
public int[][] getPrivilegeProperty() {
|
||||
return privilegeProperty;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue