zhangshanxue 2019-08-29 19:55:59 +08:00
commit f76a69da1a
8 changed files with 90 additions and 30 deletions

View File

@ -5,6 +5,7 @@ import com.ljsd.common.mogodb.LjsdMongoTemplate;
import com.ljsd.common.mogodb.test.pojo.PlayerForTest;
import com.ljsd.jieling.logic.dao.PlayerManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.util.MathUtils;
import com.mongodb.DBObject;
import com.mongodb.MongoClientURI;
import org.slf4j.Logger;
@ -63,17 +64,20 @@ public class MongoUtil {
return MongoUtil.getInstence().getMyMongoTemplate();
}
public List<User> getRandomUsers(int size, int uid, int level) throws Exception {
if(size <= 0){
return null;
}
int randomLevel = MathUtils.random(5, 20);
Criteria criatira = new Criteria();
Random random = new Random();
int minLevel = random.nextInt(level) - 10;
int minLevel = level - randomLevel;
minLevel = minLevel <= 5 ? 5 : minLevel;
int maxLevel = random.nextInt(level) + 10;
int maxLevel = level + randomLevel;
long befor3Day = System.currentTimeMillis() - BEFOR_3_DAY;
criatira.andOperator(Criteria.where("id").nin(uid),
Criteria.where("playerManager.level").gte(minLevel), Criteria.where("playerManager.level").lte(maxLevel),
Criteria.where("playerManager.loginTime").gte(befor3Day));//不包含自己
Query query = new Query(criatira).limit(size);
Query query = new Query(criatira).limit(size*2+1);
query.fields().include("playerManager");
return this.myMongoTemplate.findAllByCondition(query, User.class) ;
}

View File

@ -16,7 +16,7 @@ public class EatBuffBehavior extends BaseBehavior {
@Override
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
CombatLogic.getInstance().bufferAddByEatFoodOrEventTrigger(user.getMapManager(), behaviorTypeValues[0][0]);
CombatLogic.getInstance().bufferAddByEatFoodOrEventTrigger(user, behaviorTypeValues[0][0]);
return true;
}
}

View File

@ -17,7 +17,7 @@ public class FourtyBehavior extends BaseBehavior {
@Override
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
BehaviorUtil.updateMission(user, eventUpdateResponse);
CombatLogic.getInstance().bufferAddByEatFoodOrEventTrigger(user.getMapManager(), behaviorTypeValues[0][0]);
CombatLogic.getInstance().bufferAddByEatFoodOrEventTrigger(user, behaviorTypeValues[0][0]);
BehaviorUtil.destoryPoints(user, behaviorTypeValues[1]);
for (int i = 2; i < behaviorTypeValues.length; i++) {
BehaviorUtil.addBehaviorInfo(user,behaviorTypeValues[i][3], user.getMapManager(), behaviorTypeValues[i][0], behaviorTypeValues[i][1], behaviorTypeValues[i][2]);

View File

@ -15,7 +15,7 @@ public class ThirtyFourBehavior extends BaseBehavior {
@Override
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
CombatLogic.getInstance().bufferAddByEatFoodOrEventTrigger(user.getMapManager(), behaviorTypeValues[0][0]);
CombatLogic.getInstance().bufferAddByEatFoodOrEventTrigger(user, behaviorTypeValues[0][0]);
BehaviorUtil.destoryPoint(user, behaviorTypeValues[0][1]);
return true;
}

View File

@ -21,7 +21,7 @@ public class ThirtySevenBehavior extends BaseBehavior{
cost[0][0] = behaviorTypeValues[0][0];
cost[0][1] = behaviorTypeValues[0][1];
ItemUtil.itemCost(user,cost, BIReason.MAP_CONSUME,user.getMapManager().getCurMapId());
CombatLogic.getInstance().bufferAddByEatFoodOrEventTrigger(user.getMapManager(), behaviorTypeValues[0][2]);
CombatLogic.getInstance().bufferAddByEatFoodOrEventTrigger(user, behaviorTypeValues[0][2]);
return true;
}

View File

@ -8,6 +8,7 @@ import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.handler.map.EndlessHero;
import com.ljsd.jieling.handler.map.MapManager;
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
import com.ljsd.jieling.ktbeans.KTGameType;
@ -19,6 +20,7 @@ import com.ljsd.jieling.logic.activity.event.SecretEvent;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.logic.mail.MailLogic;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.store.StoreLogic;
@ -114,13 +116,33 @@ public class CombatLogic {
return heroAllAttributeMap;
}
public void bufferAddByEatFoodOrEventTrigger(MapManager mapManager,int foodIdOrEventId) throws Exception {
public void bufferAddByEatFoodOrEventTrigger(User user,int foodIdOrEventId) throws Exception {
MapManager mapManager = user.getMapManager();
Map<String, Map<Integer, Integer>> heroAllAttributeMap = bufferAddByEatFoodOrEventTrigger(foodIdOrEventId, mapManager.getHeroAllAttributeMap());
mapManager.setHeroAllAttributeMap(heroAllAttributeMap);
SFoodsConfig sFoodsConfig = SFoodsConfig.getsFoodsConfigByFoodId(foodIdOrEventId);
int contiue = sFoodsConfig.getContiue();
if(contiue==0){
contiue=-1;
int teamId = mapManager.getTeamId();
List<TeamPosHeroInfo> teamPosHeroInfoList = user.getTeamPosManager().getTeamPosForHero().get(teamId);
Map<Integer,Integer> foodAddMap = new HashMap<>();
getFoodAttributeAdd(GlobalsDef.FOOD_ADDITION_BATTLE_TYPE, GlobalsDef.FOOD_EAT_AFFECT_PERSON, foodAddMap, sFoodsConfig);
for (TeamPosHeroInfo heroInfo : teamPosHeroInfoList) {
Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId());
if (hero == null) {
continue;
}
Map<Integer, Integer> heroAllAttribute = user.getMapManager().getHeroAllAttributeByHeroId(hero.getId());
if(heroAllAttribute == null || heroAllAttribute.get(HeroAttributeEnum.CurHP.getPropertyId()) <= 0){
continue;
}
HeroLogic.getInstance().combinedAttribute(foodAddMap,heroAllAttribute);
HeroLogic.getInstance().calInteractAdd(heroAllAttribute);
heroAllAttributeMap.put(hero.getId(), heroAllAttribute);
}
mapManager.setHeroAllAttributeMap(heroAllAttributeMap);
}
mapManager.eatFood(foodIdOrEventId,contiue);
}
@ -136,24 +158,27 @@ public class CombatLogic {
}
int foodId = foodBuffer.getKey();
SFoodsConfig sFoodsConfig = SFoodsConfig.getsFoodsConfigByFoodId(foodId);
int typeTmp = sFoodsConfig.getType();
int targetTmp = sFoodsConfig.getTarget();
if( typeTmp==type && targetTmp==target ){
int[][] effectParas = sFoodsConfig.getEffectPara();
for(int[] effectPara : effectParas){
int effectId = effectPara[0];
int effectValue = effectPara[1];
if(!foddAddResult.containsKey(effectId)){
foddAddResult.put(effectId,effectValue);
continue;
}
foddAddResult.put( effectId,foddAddResult.get(effectId) + effectValue );
}
}
getFoodAttributeAdd(type, target, foddAddResult, sFoodsConfig);
}
return foddAddResult;
}
private void getFoodAttributeAdd(int type, int target, Map<Integer, Integer> foddAddResult, SFoodsConfig sFoodsConfig) {
int typeTmp = sFoodsConfig.getType();
int targetTmp = sFoodsConfig.getTarget();
if( typeTmp==type && targetTmp==target ){
int[][] effectParas = sFoodsConfig.getEffectPara();
for(int[] effectPara : effectParas){
int effectId = effectPara[0];
int effectValue = effectPara[1];
if(!foddAddResult.containsKey(effectId)){
foddAddResult.put(effectId,effectValue);
continue;
}
foddAddResult.put( effectId,foddAddResult.get(effectId) + effectValue );
}
}
}
/************** 新挂机*****************/

View File

@ -24,10 +24,7 @@ import com.ljsd.jieling.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
public class FriendLogic {
@ -95,18 +92,51 @@ public class FriendLogic {
FriendManager friendManager = user.getFriendManager();
int selectSize = 10;
Set<Integer> recommondIds = new HashSet<>();
Set<Integer> onlineUIds = OnlineUserManager.sessionMap.keySet();
int level = playerInfoManager.getLevel();
int randomLevel = MathUtils.random(5, 20);
List<Integer> recommandFriends = new ArrayList<>();
List<CommonProto.Friend> friendList = new CopyOnWriteArrayList<>();
for(Integer recommandId : onlineUIds){
if (!checkIsAllowRecommandFriend(friendManager, recommandId,recommondIds)){
continue;
}
User recommandIdUser = UserManager.getUserInMem(recommandId);
int minLevel = level - randomLevel;
minLevel = minLevel <= 5 ? 5 : minLevel;
int maxLevel = level + randomLevel;
int recommandLevel = recommandIdUser.getPlayerInfoManager().getLevel();
if(recommandLevel < minLevel || recommandLevel > maxLevel){
continue;
}
recommondIds.add(recommandId);
recommandFriends.add(recommandId);
selectSize--;
if(selectSize<=0){
break;
}
}
Collections.shuffle(recommandFriends);
List<User> cUsers = MongoUtil.getInstence().getRandomUsers(selectSize, uid, playerInfoManager.getLevel());
if (cUsers != null){
Collections.shuffle(cUsers);
for (User cUser1 : cUsers) {
int recommandId = cUser1.getId();
if (!checkIsAllowRecommandFriend(friendManager, recommandId,recommondIds)){
continue;
}
recommondIds.add(recommandId);
recommandFriends.add(recommandId);
selectSize--;
if(selectSize<=0){
break;
}
}
}
List<CommonProto.Friend> friendList = new CopyOnWriteArrayList<>();
for (Integer commondUid : recommondIds){
for (Integer commondUid : recommandFriends){
CommonProto.Friend friend = CBean2Proto.getFriendInfo(commondUid,friendManager);
friendList.add(friend);
}
@ -570,6 +600,7 @@ public class FriendLogic {
User user = UserManager.getUser(uid);
FriendManager friendManager = user.getFriendManager();
Map<Integer, Integer> giveMap = friendManager.getGiveMap();
friendManager.setHaveRewardMap(new HashMap<>());
for (Map.Entry<Integer,Integer> entry: giveMap.entrySet()){
Integer friendId = entry.getKey();
User friendUser = UserManager.getUser(friendId);

View File

@ -1081,7 +1081,7 @@ public class HeroLogic {
return heroAllAttribute;
}
//食物buffer加成
Map<Integer, Integer> foodAddMap = CombatLogic.getInstance().attributeByEatFood(user,GlobalsDef.FOOD_ADDITION_BATTLE_TYPE, GlobalsDef.FOOD_EAT_AFFECT_TEAM);
Map<Integer, Integer> foodAddMap = CombatLogic.getInstance().attributeByEatFood(user,GlobalsDef.FOOD_ADDITION_BATTLE_TYPE, GlobalsDef.FOOD_EAT_AFFECT_PERSON);
if(foodAddMap.isEmpty()){
return heroAllAttribute;
}