Merge branch 'master' of http://60.1.1.230/backend/jieling_server
# Conflicts: # serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.javaback_recharge
commit
cf996208a8
|
|
@ -0,0 +1,21 @@
|
|||
package com.ljsd.jieling.battle;
|
||||
|
||||
|
||||
|
||||
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BattleManager {
|
||||
|
||||
static Map<Integer, CommonProto.FightTeamInfo> fightTeamInfoMap = new HashMap<>();
|
||||
|
||||
public static void snapUserFightInfo(User mine, int myteamId){
|
||||
CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(mine,myteamId,false);
|
||||
fightTeamInfoMap.put(mine.getId(),fightTeamInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -15,6 +15,8 @@ public class SRechargeCommodityConfig implements BaseConfig {
|
|||
|
||||
private int id;
|
||||
|
||||
private String name;
|
||||
|
||||
private int type;
|
||||
|
||||
private int price;
|
||||
|
|
@ -186,6 +188,9 @@ public class SRechargeCommodityConfig implements BaseConfig {
|
|||
return contiueDays;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setStartTimeLong(long startTimeLong) {
|
||||
this.startTimeLong = startTimeLong;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
|||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.AyyncWorker;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -78,11 +79,14 @@ public class HandlerLogicThread extends Thread{
|
|||
|
||||
whiteMsg.add(MessageTypeProto.MessageType.SERVER_FIVE_REQEUST_VALUE);
|
||||
whiteMsg.add(MessageTypeProto.MessageType.SERVER_ZERO_REQUEST_VALUE);
|
||||
whiteMsg.add(MessageTypeProto.MessageType.FAMILY_FIGHT_ROUND_INFO_REQUEST_VALUE);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public ConcurrentLinkedQueue<PacketNetData> handlerLinkedQueue = new ConcurrentLinkedQueue();
|
||||
public ConcurrentLinkedQueue<AyyncWorker> ayyncWorkerConcurrentLinkedQueue = new ConcurrentLinkedQueue();
|
||||
|
||||
|
||||
@Override
|
||||
|
|
@ -94,6 +98,10 @@ public class HandlerLogicThread extends Thread{
|
|||
|
||||
public void doWork(){
|
||||
try {
|
||||
AyyncWorker ayyncWorker =null;
|
||||
while ( (ayyncWorker = ayyncWorkerConcurrentLinkedQueue.poll())!=null){
|
||||
ayyncWorker.exec();
|
||||
}
|
||||
PacketNetData packetNetData = handlerLinkedQueue.poll();
|
||||
if(packetNetData == null){
|
||||
Thread.sleep(2);
|
||||
|
|
@ -268,4 +276,8 @@ public class HandlerLogicThread extends Thread{
|
|||
public void addEntry(PacketNetData packetNetData){
|
||||
handlerLinkedQueue.offer(packetNetData);
|
||||
}
|
||||
|
||||
public void addAyyncWorker(AyyncWorker ayyncWorker){
|
||||
ayyncWorkerConcurrentLinkedQueue.offer(ayyncWorker);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,6 +118,8 @@ public class RedisKey {
|
|||
public static final String FAMILY_FIGHT = "FAMILY_FIGHT" ;
|
||||
public static final String FAMILY_FIGHT_RANK = "FAMILY_FIGHT_RANK";
|
||||
public static final String FAMILY_FIGHT_MATCHING_RANK ="FAMILY_FIGHT_MATCHING_RANK";
|
||||
//公会战进攻获得星数排行榜
|
||||
public static final String FAMILY_FIGHT_STAR_RANK = "FAMILY_FIGHT_STAR_RANK";
|
||||
|
||||
public static final String OPERATE_FAMILY = "OPERATE_FAMILY";
|
||||
public static final String OPERATE_FAMILY_APPLY = "OPERATE_FAMILY_APPLY";
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
.setTreasureScore(playerInfoManager.getTreasureScore())
|
||||
.setSignInInfo(CommonProto.SignInInfo.newBuilder().setDays(playerInfoManager.getSign()+1).setState(playerInfoManager.getSignTotay()).build())
|
||||
.setMonsterAttackTime(user.getMapManager().getLastMonsterAttack())
|
||||
.setFirstTenth(user.getHeroManager().getFirstTenth())
|
||||
.build();
|
||||
try {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_PLAYERINFO_RESPONSE_VALUE, getPlayerInfoResponse, true);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.ljsd.jieling.handler.family;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.Family;
|
||||
|
|
@ -20,6 +20,6 @@ public class FamilyDefendDetailInfoHandler extends BaseHandler {
|
|||
byte[] bytes = netData.parseClientProtoNetData();
|
||||
Family.FamilyDefendDetailViewRequest request = Family.FamilyDefendDetailViewRequest.parseFrom(bytes);
|
||||
|
||||
GuildLogic.viewDefendDetailInfo(iSession,request.getPlayerId(), MessageTypeProto.MessageType.FAMILY_VIEW_DEFEND_DETAIL_RESPONSE);
|
||||
GuildFightLogic.viewDefendDetailInfo(iSession,request.getPlayerId(), MessageTypeProto.MessageType.FAMILY_VIEW_DEFEND_DETAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
package com.ljsd.jieling.handler.family;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.Family;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -18,6 +17,6 @@ public class FamilyDefendInfoHandler extends BaseHandler {
|
|||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
|
||||
GuildLogic.viewDefendInfo(iSession,MessageTypeProto.MessageType.FAMILY_VIEW_DEFEND_RESPONSE);
|
||||
GuildFightLogic.viewDefendInfo(iSession,MessageTypeProto.MessageType.FAMILY_VIEW_DEFEND_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
package com.ljsd.jieling.handler.family;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.Family;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class FamilyFightAttackHandler extends BaseHandler<Family.FamilyFightAttackRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.FAMILY_FIGHT_ATTACK_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, Family.FamilyFightAttackRequest proto) throws Exception {
|
||||
int attackUid = proto.getAttackUid();
|
||||
GuildFightLogic.familyFightResult(iSession,attackUid, MessageTypeProto.MessageType.FAMILY_FIGHT_ATTACK_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package com.ljsd.jieling.handler.family;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
|
|
@ -16,6 +16,6 @@ public class FamilyFightInfoHandler extends BaseHandler {
|
|||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
GuildLogic.viewFightInfo(iSession, MessageTypeProto.MessageType.FAMILY_FIGHT_INFO_RESPONSE);
|
||||
GuildFightLogic.viewFightInfo(iSession, MessageTypeProto.MessageType.FAMILY_FIGHT_INFO_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.ljsd.jieling.handler.family;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class FamilyPersonalResultHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.FAMILY_PERSONAL_FIGHT_RESULT_REQUEST;
|
||||
}
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
GuildFightLogic.personalFightResult(iSession,MessageTypeProto.MessageType.FAMILY_PERSONAL_FIGHT_RESULT_RESPONSE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package com.ljsd.jieling.handler.family;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.Family;
|
||||
|
|
@ -20,6 +20,6 @@ public class FamilyQuickSetDefendHandler extends BaseHandler {
|
|||
byte[] bytes = netData.parseClientProtoNetData();
|
||||
Family.FamilyQuickDefendRequest request = Family.FamilyQuickDefendRequest.parseFrom(bytes);
|
||||
|
||||
GuildLogic.quickSetDefend(iSession,request.getBuildId(),request.getUid(), MessageTypeProto.MessageType.FAMILY_QUICK_SET_DEFEND_RESPONSE);
|
||||
GuildFightLogic.quickSetDefend(iSession,request.getBuildId(),request.getUid(), MessageTypeProto.MessageType.FAMILY_QUICK_SET_DEFEND_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.ljsd.jieling.handler.family;
|
||||
|
||||
public class FamilyRound {
|
||||
|
||||
public static final int FAMILY_FIGHT_START = 9;
|
||||
|
||||
public static final int FAMILY_FIGHT_DEFEND_END = 10;
|
||||
|
||||
public static final int FAMILY_FIGHT_MATCHING_END =11;
|
||||
|
||||
public static final int FAMILY_FIGHT_ATTACK_END = 12;
|
||||
|
||||
public static final int FAMILY_FIGHT_END = 13;
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.ljsd.jieling.handler.family;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class FamilyRoundInfoHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.FAMILY_FIGHT_ROUND_INFO_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
GuildFightLogic.getFamilyFightRoundInfo(iSession, MessageTypeProto.MessageType.FAMILY_FIGHT_ROUND_INFO_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
@ -73,7 +73,11 @@ public class KtEventUtils {
|
|||
int costTotal = (int)parm[4];
|
||||
paramEventBean.add(String.valueOf(storeId));
|
||||
paramEventBean.add(String.valueOf(buyItemId));
|
||||
paramEventBean.add(currencyMap.get(goldType));
|
||||
if(currencyMap.containsKey(goldType)){
|
||||
paramEventBean.add(currencyMap.get(goldType));
|
||||
}else{
|
||||
paramEventBean.add(Integer.toString(goldType));
|
||||
}
|
||||
paramEventBean.add(String.valueOf(buyTimes));
|
||||
paramEventBean.add(String.valueOf(costTotal/buyTimes));
|
||||
paramEventBean.add(String.valueOf(costTotal));
|
||||
|
|
@ -84,7 +88,7 @@ public class KtEventUtils {
|
|||
String payValid = payResult[(int)parm[2]];
|
||||
String amount = String.valueOf( ((int)parm[3]/10));
|
||||
SRechargeCommodityConfig sRechargeCommodityConfig = SRechargeCommodityConfig.rechargeCommodityConfigMap.get(goodsId);
|
||||
paramEventBean.add("IN_GAME_"+sRechargeCommodityConfig.getType());
|
||||
paramEventBean.add(sRechargeCommodityConfig.getName());
|
||||
paramEventBean.add(orderId);
|
||||
paramEventBean.add(payValid);
|
||||
paramEventBean.add(amount);
|
||||
|
|
|
|||
|
|
@ -92,7 +92,9 @@ public class CumulationData {
|
|||
public int wearEquipTimes;// 妖灵师穿戴装备件数达到
|
||||
public Map<Integer,Integer> synthesisHeroStarTimesMap = new HashMap<>();// 碎片合成%s星妖灵师次数达到
|
||||
|
||||
public Map<Integer,Integer> heroUpStarTimesMap = new HashMap<>();// 碎片合成%s星妖灵师次数达到
|
||||
public Map<Integer,Integer> heroUpStarTimesMap = new HashMap<>();//将妖灵师%s进阶次数达到
|
||||
|
||||
public Map<Integer,Integer> heroUpSomeStarTimesMap = new HashMap<>();// 进阶x星卡牌个数达到
|
||||
|
||||
public int consumerStamina; //消耗体力数量达到
|
||||
|
||||
|
|
@ -100,6 +102,12 @@ public class CumulationData {
|
|||
|
||||
public Set<Integer> differentHeros = new HashSet<>();
|
||||
|
||||
public int buyGenerStoreTimes;
|
||||
|
||||
public int givePresents ; //好友赠礼
|
||||
|
||||
public int friendNums;
|
||||
|
||||
|
||||
|
||||
//任务重置
|
||||
|
|
@ -141,6 +149,10 @@ public class CumulationData {
|
|||
differentHeros.clear();
|
||||
heroUpStarTimesMap.clear();
|
||||
heroInTeamNums=0;
|
||||
buyGenerStoreTimes=0;
|
||||
heroUpSomeStarTimesMap.clear();
|
||||
givePresents=0;
|
||||
friendNums=0;
|
||||
}
|
||||
|
||||
private void clearArray(int[] source){
|
||||
|
|
@ -189,6 +201,14 @@ public class CumulationData {
|
|||
heroUpStarTimesMap.put(heroTid,count+1);
|
||||
}
|
||||
|
||||
public void updateHeroUpSomeStarTimes(int heroStar){
|
||||
Integer count = heroUpSomeStarTimesMap.get(heroStar);
|
||||
if(count == null){
|
||||
count = 0;
|
||||
}
|
||||
heroUpStarTimesMap.put(heroStar,count+1);
|
||||
}
|
||||
|
||||
|
||||
public int getSecretRandomCount() {
|
||||
return secretRandomCount;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ public class HeroManager extends MongoBase {
|
|||
|
||||
Map<Integer,Integer> heroHandBook;
|
||||
|
||||
private int firstTenth;
|
||||
|
||||
|
||||
public HeroManager() {
|
||||
heroMap = new HashMap();
|
||||
|
|
@ -74,4 +76,14 @@ public class HeroManager extends MongoBase {
|
|||
public Map<Integer, Integer> getHeroHandBook() {
|
||||
return heroHandBook;
|
||||
}
|
||||
|
||||
public int getFirstTenth() {
|
||||
return firstTenth;
|
||||
}
|
||||
|
||||
public void updateFirstTenth() {
|
||||
this.firstTenth = 1;
|
||||
updateString("firstTenth" , 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ public class UserMissionManager extends MongoBase {
|
|||
case DAILY_MISSION_REWARD:{
|
||||
dailyMissionIdsType.rewardMission((int)parm[0], missionTypeEnumListMap.get(GameMisionType.DAILYMISSION));
|
||||
calCumulationDataResult(user,MissionType.FINSIH_DAYILY_TIMES,missionTypeEnumListMap,(int)parm[0]);
|
||||
updateString("dailyMissionIdsType",dailyMissionIdsType);
|
||||
}
|
||||
break;
|
||||
case TREASURE_MISSION_REWARD:{
|
||||
|
|
@ -123,6 +124,7 @@ public class UserMissionManager extends MongoBase {
|
|||
int score = STreasureTaskConfig.sTreasureTaskConfigMap.get(missionId).getPoints();
|
||||
calCumulationDataResult(user,MissionType.SENVER_HAPPY,missionTypeEnumListMap,score);
|
||||
}
|
||||
updateString("sevenHappyMissionType",sevenHappyMissionType);
|
||||
}
|
||||
break;
|
||||
case BEGINNER_MISSION_REWARD:{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,475 @@
|
|||
package com.ljsd.jieling.logic.family;
|
||||
|
||||
import com.ljsd.jieling.config.SGuildSetting;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.handler.family.FamilyRound;
|
||||
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.CheckFight;
|
||||
import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.Family;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.FightDataUtil;
|
||||
import com.ljsd.jieling.util.MathUtils;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class GuildFightLogic {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GuildFightLogic.class);
|
||||
/**
|
||||
* 公会战状态
|
||||
*/
|
||||
private static int status;
|
||||
private static boolean startMatching;
|
||||
|
||||
/**
|
||||
* 查看工会布防信息
|
||||
*
|
||||
* @param session
|
||||
* @param messageType
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void viewDefendInfo(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
int gid = user.getPlayerInfoManager().getGuildId();
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(gid);
|
||||
Map<Integer, Integer> defendInfo = guildInfo.getDefendInfo();
|
||||
Family.FamilyDefendViewResponse.Builder response = Family.FamilyDefendViewResponse.newBuilder();
|
||||
for (Map.Entry<Integer, Integer> entry : defendInfo.entrySet()) {
|
||||
Family.FamilyDefendInfo.Builder defend = Family.FamilyDefendInfo.newBuilder();
|
||||
defend.setStarCount(5);
|
||||
defend.setUid(entry.getKey());
|
||||
defend.setBuildId(entry.getValue());
|
||||
defend.setCurForce(HeroLogic.getInstance().calTeamTotalForce(UserManager.getUser(entry.getKey()), 501, false));
|
||||
response.addInfo(defend);
|
||||
}
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), response.build(), true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看公会具体布防信息
|
||||
*
|
||||
* @param session
|
||||
* @param uid
|
||||
* @param messageType
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void viewDefendDetailInfo(ISession session, int uid, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User user = UserManager.getUser(uid);
|
||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||
FamilyFightInfo fightInfo = RedisUtil.getInstence().getMapEntry(RedisKey.FAMILY_FIGHT, String.valueOf(guildId), String.valueOf(uid), FamilyFightInfo.class);
|
||||
TeamPosManager teamPosManager = user.getTeamPosManager();
|
||||
CommonProto.Team.Builder team = CommonProto.Team.newBuilder();
|
||||
CommonProto.TeamOneTeamInfo.Builder oneInfo = CommonProto.TeamOneTeamInfo.newBuilder();
|
||||
for(Map.Entry<String, FamilyHeroInfo> entry:fightInfo.getHeroAttribute().entrySet()){
|
||||
int templateId = entry.getValue().getTempleteId();
|
||||
team.addHeroTid(templateId);
|
||||
Map<Integer, Integer> attribute = entry.getValue().getAttribute();
|
||||
if(status==3){
|
||||
int remainHp = attribute.get(HeroAttributeEnum.CurHP.getPropertyId())*100/attribute.get(HeroAttributeEnum.Hp.getPropertyId());
|
||||
LOGGER.info("血量为百分之{}",remainHp);
|
||||
oneInfo.addRemainHp(remainHp);
|
||||
}
|
||||
}
|
||||
oneInfo.setTeam(team);
|
||||
oneInfo.setTotalForce(HeroLogic.getInstance().calTeamTotalForce(user, 501, false));
|
||||
if (teamPosManager.getTeamPosForPoken().get(1) != null && teamPosManager.getTeamPosForPoken().get(1).size() > 0) {
|
||||
for (TeamPosForPokenInfo posForPokenInfo : teamPosManager.getTeamPosForPoken().get(1)) {
|
||||
oneInfo.addPokemonInfos(posForPokenInfo.getPokenId());
|
||||
}
|
||||
}
|
||||
Family.FamilyDefendDetailViewResponse.Builder response = Family.FamilyDefendDetailViewResponse.newBuilder();
|
||||
response.setTeamInfo(oneInfo);
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), response.build(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键布防、调整布防
|
||||
*
|
||||
* @param session
|
||||
* @param messageType
|
||||
*/
|
||||
public static void quickSetDefend(ISession session, int buildId, int uid, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User user = UserManager.getUser(uid);
|
||||
TeamPosManager teamPosManager = user.getTeamPosManager();
|
||||
if (teamPosManager.getTeamPosForHero().get(501) == null || teamPosManager.getTeamPosForHero().get(501).size() < 1) {
|
||||
teamPosManager.updateTeamPosByTeamId(501, teamPosManager.getTeamPosForHero().get(1));
|
||||
}
|
||||
if (buildId == 0) {
|
||||
buildId = 1;
|
||||
}
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(user.getPlayerInfoManager().getGuildId());
|
||||
SGuildSetting guildSetting = SGuildSetting.sGuildSetting;
|
||||
int memberType = GuildLogic.getMemberType(uid, guildInfo.getMembers());
|
||||
guildInfo.updateDefendInfo(uid, buildId);
|
||||
Family.FamilyDefendInfo.Builder defend = Family.FamilyDefendInfo.newBuilder();
|
||||
defend.setBuildId(buildId);
|
||||
defend.setUid(uid);
|
||||
defend.setStarCount(guildSetting.getStarNum()[memberType-1]);
|
||||
defend.setCurForce(HeroLogic.getInstance().calTeamTotalForce(user, 501, false));
|
||||
GuildLogic.sendIndicationToMember(guildInfo, MessageTypeProto.MessageType.FAMILY_QUICK_SET_DEFEND_INDICATION, defend.build());
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true);
|
||||
}
|
||||
|
||||
|
||||
private static Family.FamilyFightInfo familyFightDetailInfo(int guildId) throws Exception {
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||
Map<Integer, Integer> defendInfo = guildInfo.getDefendInfo();
|
||||
Family.FamilyFightInfo.Builder fightInfo = Family.FamilyFightInfo.newBuilder();
|
||||
fightInfo.setGid(guildId);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Family.FamilyBuildBuffInfo.Builder buffInfo = Family.FamilyBuildBuffInfo.newBuilder();
|
||||
buffInfo.setBuildId(i + 1);
|
||||
buffInfo.setBuffId(i + 1);
|
||||
fightInfo.addBuildBuff(buffInfo);
|
||||
}
|
||||
for (Map.Entry<Integer, Integer> entry : defendInfo.entrySet()) {
|
||||
Family.FamilyFightPlayerInfo.Builder playerInfo = Family.FamilyFightPlayerInfo.newBuilder();
|
||||
playerInfo.setBuildId(entry.getValue());
|
||||
playerInfo.setStarCount(5);
|
||||
PlayerManager playerManager = UserManager.getUser(entry.getKey()).getPlayerInfoManager();
|
||||
Family.FamilyUserInfo.Builder userInfo = Family.FamilyUserInfo.newBuilder()
|
||||
.setRoleUid(entry.getKey())
|
||||
.setUserName(playerManager.getNickName())
|
||||
.setUserLevel(playerManager.getLevel())
|
||||
.setPosition(2)
|
||||
.setSoulForce(HeroLogic.getInstance().calTeamTotalForce(UserManager.getUser(entry.getKey()), 501, false))
|
||||
.setHead(playerManager.getHead())
|
||||
.setFrame(playerManager.getHeadFrame())
|
||||
.setContribute(0);
|
||||
playerInfo.setUserInfo(userInfo.build());
|
||||
fightInfo.addUser(playerInfo);
|
||||
}
|
||||
return fightInfo.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 公会战查看双方对战信息
|
||||
*
|
||||
* @param session
|
||||
* @param messageType
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void viewFightInfo(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||
int enemyId = getEnemyFamily(guildId);
|
||||
Family.FamilyFightInfoResponse.Builder builder = Family.FamilyFightInfoResponse.newBuilder();
|
||||
builder.addInfo(familyFightDetailInfo(guildId));
|
||||
builder.addInfo(familyFightDetailInfo(enemyId));
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), builder.build(), true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 公会战计入缓存
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void familyFightMatching() throws Exception {
|
||||
Set<Integer> guildIds = GuilidManager.guildInfoMap.keySet();
|
||||
if (guildIds.size() < 1) {
|
||||
return;
|
||||
}
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
String key = RedisKey.getKey(RedisKey.FAMILY_FIGHT_RANK, "", false);
|
||||
Set<String> rank = redisUtil.getZset(key, 0, redisUtil.getZsetSize(key));
|
||||
for (Integer gid : guildIds) {
|
||||
//匹配处理
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(gid);
|
||||
if (guildInfo.getDefendInfo() != null && guildInfo.getDefendInfo().size() > 0) {
|
||||
String matchingKey = RedisKey.getKey(RedisKey.FAMILY_FIGHT_MATCHING_RANK, "", false);
|
||||
int random = MathUtils.randomInt(30);
|
||||
if (!rank.contains(gid.toString())) {
|
||||
redisUtil.zsetAddOne(key, gid.toString(), 100);
|
||||
redisUtil.zsetAddOne(matchingKey, gid.toString(), 100 + random);
|
||||
} else {
|
||||
Double zSetScore = redisUtil.getZSetScore(RedisKey.FAMILY_FIGHT_RANK, "", gid.toString());
|
||||
redisUtil.zsetAddOne(matchingKey, gid.toString(), zSetScore + random);
|
||||
}
|
||||
}
|
||||
Map<Integer, Integer> defendInfo = guildInfo.getDefendInfo();
|
||||
if (defendInfo == null || defendInfo.size() < 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//血量记录处理,星级记录处理
|
||||
SGuildSetting guildSetting = SGuildSetting.sGuildSetting;
|
||||
for (Map.Entry<Integer, Integer> entry : defendInfo.entrySet()) {
|
||||
User user = UserManager.getUser(entry.getKey());
|
||||
int memberType = GuildLogic.getMemberType(entry.getKey(), guildInfo.getMembers());
|
||||
HeroManager heroManager = user.getHeroManager();
|
||||
TeamPosManager teamPosManager = user.getTeamPosManager();
|
||||
List<TeamPosHeroInfo> teamPosHeroInfos = teamPosManager.getTeamPosForHero().get(501);
|
||||
Iterator<TeamPosHeroInfo> it = teamPosHeroInfos.iterator();
|
||||
FamilyFightInfo fightInfo = new FamilyFightInfo();
|
||||
Map<String, FamilyHeroInfo> heroAllAttribute = new HashMap<>();
|
||||
while (it.hasNext()) {
|
||||
TeamPosHeroInfo heroInfo = it.next();
|
||||
Hero hero = heroManager.getHero(heroInfo.getHeroId());
|
||||
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false, 501);
|
||||
heroAllAttribute.put(heroInfo.getHeroId(), new FamilyHeroInfo(hero.getTemplateId(), hero.getLevel(), heroAttributeMap));
|
||||
}
|
||||
fightInfo.setHeroAttribute(heroAllAttribute);
|
||||
fightInfo.setStarCount(guildSetting.getStarNum()[memberType-1]);
|
||||
redisUtil.putMapEntry(RedisKey.FAMILY_FIGHT, String.valueOf(guildInfo.getId()), String.valueOf(entry.getKey()), fightInfo);
|
||||
}
|
||||
}
|
||||
for (Integer gid : guildIds) {
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(gid);
|
||||
int enemyFamily = getEnemyFamily(guildInfo.getId());
|
||||
if (enemyFamily == -1) {
|
||||
continue;
|
||||
}
|
||||
GuildInfo enemyInfo = GuilidManager.guildInfoMap.get(enemyFamily);
|
||||
Family.EnemyFamily familyInfo = Family.EnemyFamily.newBuilder().setId(enemyInfo.getId()).setLevel(enemyInfo.getLevel()).setName(enemyInfo.getName()).setPictureId(1).build();
|
||||
GuildLogic.sendIndicationToMember(guildInfo, MessageTypeProto.MessageType.FAMILY_FIGHT_MATCHING_SUCCESS_INDICATION, familyInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户公会的敌对公会
|
||||
*
|
||||
* @param myFamilyId
|
||||
* @return
|
||||
*/
|
||||
private static int getEnemyFamily(int myFamilyId) {
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
Long matchingRank = redisUtil.getZSetreverseRank(RedisKey.FAMILY_FIGHT_MATCHING_RANK, "", String.valueOf(myFamilyId));
|
||||
int enmeyFamilyId;
|
||||
long rank;
|
||||
if (matchingRank % 2 == 1) {
|
||||
rank = matchingRank;
|
||||
} else {
|
||||
rank = matchingRank - 2;
|
||||
}
|
||||
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.FAMILY_FIGHT_MATCHING_RANK, "", rank, rank);
|
||||
if (zsetreverseRangeWithScores.size() != 1) {
|
||||
return -1;
|
||||
} else {
|
||||
String value = zsetreverseRangeWithScores.iterator().next().getValue();
|
||||
enmeyFamilyId = Integer.parseInt(value);
|
||||
}
|
||||
return enmeyFamilyId;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 战斗之后数据更新
|
||||
*
|
||||
* @param userAttack
|
||||
* @param userDefend
|
||||
*/
|
||||
public static void familyFightResult(ISession session, int defendUid, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User userAttack = UserManager.getUser(session.getUid());
|
||||
User userDefend = UserManager.getUser(defendUid);
|
||||
int defendGuildId = userDefend.getPlayerInfoManager().getGuildId();
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
FamilyFightInfo defendInfo = redisUtil.getMapEntry(RedisKey.FAMILY_FIGHT, String.valueOf(defendGuildId), String.valueOf(userDefend.getId()), FamilyFightInfo.class);
|
||||
Map<String, FamilyHeroInfo> heroAttribute = defendInfo.getHeroAttribute();
|
||||
int seed = (int) (System.currentTimeMillis() / 1000);
|
||||
List<CommonProto.FightUnitInfo> heroDefendFightInfos = new ArrayList<>();
|
||||
for (Map.Entry<String, FamilyHeroInfo> entry : heroAttribute.entrySet()) {
|
||||
Hero hero = userDefend.getHeroManager().getHero(entry.getKey());
|
||||
if (hero == null) {
|
||||
continue;
|
||||
}
|
||||
StringBuilder skillSb = new StringBuilder();
|
||||
StringBuilder propertySb = new StringBuilder();
|
||||
String heroSkill = HeroLogic.getInstance().getHeroSkills(userDefend, hero, skillSb).toString();
|
||||
String property = HeroLogic.getInstance().getHeroPropertyBuilder(propertySb, hero, entry.getValue().getAttribute()).toString();
|
||||
CommonProto.FightUnitInfo heroFightInfo = CommonProto.FightUnitInfo
|
||||
.newBuilder()
|
||||
.setUnitId(Integer.toString(hero.getTemplateId()))
|
||||
.setUnitSkillIds(heroSkill.substring(0, heroSkill.length() - 1))
|
||||
.setProperty(property.substring(0, property.length() - 1))
|
||||
.build();
|
||||
heroDefendFightInfos.add(heroFightInfo);
|
||||
}
|
||||
CommonProto.FightTeamInfo fightDefendTeamInfo = CommonProto.FightTeamInfo.
|
||||
newBuilder()
|
||||
.addAllFightUnitList(heroDefendFightInfos)
|
||||
.setTeamSkillList(HeroLogic.getInstance().getPokenmonSkills(userDefend, 1))
|
||||
.build();
|
||||
CommonProto.FightTeamInfo fightAttackTeamInfo = BehaviorUtil.getFightTeamInfo(userAttack, 502, true);
|
||||
LuaValue getFightData = FightDataUtil.getFinalPlayerFightData(fightAttackTeamInfo, fightDefendTeamInfo);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData("");
|
||||
|
||||
int[] fightResult = CheckFight.getInstance().checkFight(seed, 1000, getFightData, getOptionData);
|
||||
for (int i = 0; i < fightResult.length; i++) {
|
||||
System.out.println(fightResult[i]);
|
||||
}
|
||||
int index = 2;
|
||||
// 战斗之后数据处理
|
||||
for (Map.Entry<String, FamilyHeroInfo> entry : heroAttribute.entrySet()) {
|
||||
FamilyHeroInfo value = entry.getValue();
|
||||
Map<Integer, Integer> attribute = value.getAttribute();
|
||||
if(fightResult[0]==0) {
|
||||
attribute.put(HeroAttributeEnum.CurHP.getPropertyId(), fightResult[index]);
|
||||
}else{
|
||||
attribute.put(HeroAttributeEnum.CurHP.getPropertyId(), 0);
|
||||
}
|
||||
value.setAttribute(attribute);
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
defendInfo.setHeroAttribute(heroAttribute);
|
||||
if (fightResult[0] == 0) {
|
||||
defendInfo.setStarCount(defendInfo.getStarCount() - 1);
|
||||
}
|
||||
redisUtil.putMapEntry(RedisKey.FAMILY_FIGHT, String.valueOf(defendGuildId), String.valueOf(userDefend.getId()), defendInfo);
|
||||
//获得星数处理
|
||||
int attackGuildId = userAttack.getPlayerInfoManager().getGuildId();
|
||||
String attackRankKey = RedisKey.getKey(RedisKey.FAMILY_FIGHT_STAR_RANK, String.valueOf(attackGuildId), false);
|
||||
Double starCount = redisUtil.getZSetScore(RedisKey.FAMILY_FIGHT_STAR_RANK, String.valueOf(attackGuildId), String.valueOf(userAttack.getId()));
|
||||
redisUtil.zsetAddOne(attackRankKey,String.valueOf(userAttack.getId()),starCount+1);
|
||||
Family.FamilyFightAttackResponse response = Family.FamilyFightAttackResponse.newBuilder().setResult(fightResult[0]).setStarCount(1).build();
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), response, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公会战阶段信息
|
||||
*
|
||||
* @param session
|
||||
* @param messageType
|
||||
*/
|
||||
public static void getFamilyFightRoundInfo(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int startFightTime;
|
||||
int roundStartTime = 0;
|
||||
int roundEndTime = 0;
|
||||
int hour = TimeUtils.getHourOfDay();
|
||||
//活动开启时间
|
||||
if (hour < FamilyRound.FAMILY_FIGHT_END) {
|
||||
startFightTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_START) / 1000);
|
||||
} else {
|
||||
startFightTime = (int) ((TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_START) + TimeUtils.DAY) / 1000);
|
||||
}
|
||||
//阶段以及时间段
|
||||
if (hour >= FamilyRound.FAMILY_FIGHT_START && hour < FamilyRound.FAMILY_FIGHT_DEFEND_END) {
|
||||
roundStartTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_START) / 1000);
|
||||
roundEndTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_DEFEND_END) / 1000);
|
||||
} else if (hour >= FamilyRound.FAMILY_FIGHT_DEFEND_END && hour < FamilyRound.FAMILY_FIGHT_MATCHING_END) {
|
||||
roundStartTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_DEFEND_END) / 1000);
|
||||
roundEndTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_MATCHING_END) / 1000);
|
||||
} else if (hour >= FamilyRound.FAMILY_FIGHT_MATCHING_END && hour < FamilyRound.FAMILY_FIGHT_ATTACK_END) {
|
||||
roundStartTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_MATCHING_END) / 1000);
|
||||
roundEndTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_ATTACK_END) / 1000);
|
||||
} else if (hour >= FamilyRound.FAMILY_FIGHT_ATTACK_END && hour < FamilyRound.FAMILY_FIGHT_END) {
|
||||
roundStartTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_ATTACK_END) / 1000);
|
||||
roundEndTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_END) / 1000);
|
||||
}
|
||||
int enemyFamily = getEnemyFamily(UserManager.getUser(session.getUid()).getPlayerInfoManager().getGuildId());
|
||||
|
||||
Family.FamilyFightRoundResponse.Builder response = Family.FamilyFightRoundResponse.newBuilder()
|
||||
.setType(status)
|
||||
.setStartTime(startFightTime)
|
||||
.setRoundStartTime(roundStartTime)
|
||||
.setRoundEndTime(roundEndTime)
|
||||
.setJoinType(1);
|
||||
if (enemyFamily != -1) {
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(enemyFamily);
|
||||
Family.EnemyFamily familyInfo = Family.EnemyFamily.newBuilder().setId(guildInfo.getId()).setLevel(guildInfo.getLevel()).setName(guildInfo.getName()).setPictureId(1).build();
|
||||
response.setEnemy(familyInfo);
|
||||
}
|
||||
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), response.build(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 公会战状态更改
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void familyFightStatus() throws Exception {
|
||||
if (status == 2 && startMatching) {
|
||||
familyFightMatching();
|
||||
startMatching = false;
|
||||
}
|
||||
int hour = TimeUtils.getHourOfDay();
|
||||
if (status == 0 && hour == FamilyRound.FAMILY_FIGHT_START) {
|
||||
LOGGER.info("阶段变为布防");
|
||||
status = 1;
|
||||
} else if (status == 1 && hour == FamilyRound.FAMILY_FIGHT_DEFEND_END) {
|
||||
status = 2;
|
||||
LOGGER.info("阶段变为匹配");
|
||||
startMatching = true;
|
||||
} else if (status == 2 && hour == FamilyRound.FAMILY_FIGHT_MATCHING_END) {
|
||||
status = 3;
|
||||
LOGGER.info("阶段变为进攻");
|
||||
|
||||
} else if (status == 3 && hour == FamilyRound.FAMILY_FIGHT_ATTACK_END) {
|
||||
status = 4;
|
||||
LOGGER.info("阶段变为结算");
|
||||
|
||||
} else if (status == 4 && hour == FamilyRound.FAMILY_FIGHT_END) {
|
||||
|
||||
status = 0;
|
||||
LOGGER.info("阶段变为等待");
|
||||
} else if (hour > FamilyRound.FAMILY_FIGHT_END || hour < FamilyRound.FAMILY_FIGHT_START) {
|
||||
status = 0;
|
||||
removeMatchingInfo();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*公会战结束删除匹配信息
|
||||
*/
|
||||
private static void removeMatchingInfo(){
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
String key = RedisKey.getKey(RedisKey.FAMILY_FIGHT_MATCHING_RANK,"",false);
|
||||
redisUtil.removeZSetRangeByRank(key,0,redisUtil.getZsetSize(key));
|
||||
}
|
||||
/**
|
||||
* 公会战结算
|
||||
*/
|
||||
public void accountFamilyFightResult() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询该公会个人战绩
|
||||
* @param session
|
||||
* @param messageType
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void personalFightResult(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int guildId = UserManager.getUser(session.getUid()).getPlayerInfoManager().getGuildId();
|
||||
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.FAMILY_FIGHT_STAR_RANK, String.valueOf(guildId), 0, 20);
|
||||
Iterator<ZSetOperations.TypedTuple<String>> it = zsetreverseRangeWithScores.iterator();
|
||||
int rank = 1;
|
||||
Family.PersonalFightResultResponse.Builder response = Family.PersonalFightResultResponse.newBuilder();
|
||||
while (it.hasNext()){
|
||||
ZSetOperations.TypedTuple<String> personal = it.next();
|
||||
int uid = Integer.parseInt(personal.getValue());
|
||||
PlayerManager playerInfoManager = UserManager.getUser(uid).getPlayerInfoManager();
|
||||
Family.PersonalFightResult.Builder fightResult = Family.PersonalFightResult.newBuilder()
|
||||
.setRank(rank)
|
||||
.setAttackCount(2)
|
||||
.setUid(uid)
|
||||
.setHead(1)
|
||||
.setHeadFrame(playerInfoManager.getHeadFrame())
|
||||
.setPosition(1)
|
||||
.setName(playerInfoManager.getNickName())
|
||||
.setStarCount(personal.getScore().intValue());
|
||||
response.addResult(fightResult.build());
|
||||
rank++;
|
||||
}
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,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.family.FamilyRound;
|
||||
import com.ljsd.jieling.handler.map.MapManager;
|
||||
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
|
|
@ -66,7 +67,6 @@ public class GuildLogic {
|
|||
for(Set<Integer> members : guildInfo.getMembers().values()){
|
||||
for(int uidOfMember : members){
|
||||
User userMember = UserManager.getUser(uidOfMember);
|
||||
userMember.getGuildMyInfo().move(System.currentTimeMillis());
|
||||
builder.addFamilyWalkIndicaiton(CBean2Proto.getFamilyWalkIndicaiton(userMember));
|
||||
}
|
||||
}
|
||||
|
|
@ -104,8 +104,6 @@ public class GuildLogic {
|
|||
.setFamilyWalkIndicaiton(CBean2Proto.getFamilyWalkIndicaiton(user))
|
||||
.build();
|
||||
MessageUtil.sendMessage(session,1,msgId,build,true);
|
||||
familyFightMatching();
|
||||
|
||||
}
|
||||
|
||||
public static String checkForCreateGuild( User user,String familyName,String announce) throws Exception {
|
||||
|
|
@ -232,7 +230,6 @@ public class GuildLogic {
|
|||
addGuildLog(guildInfo.getId(),GuildDef.Log.JOIN,user.getPlayerInfoManager().getNickName());
|
||||
Family.FamilyJoinIndicaion build = Family.FamilyJoinIndicaion.newBuilder().setFamilyBaseInfo(CBean2Proto.getFamilyBaseInfo(guildInfo)).setFamilyUserInfo(CBean2Proto.getFamilyUserInfo(user, GlobalsDef.MEMBER)).build();
|
||||
Family.FamilyJoinResponse response = Family.FamilyJoinResponse.newBuilder().setFamilyJoinIndicaion(build).build();
|
||||
|
||||
MessageUtil.sendMessage(session,1,msgId,response,true);
|
||||
}
|
||||
|
||||
|
|
@ -402,8 +399,6 @@ public class GuildLogic {
|
|||
targetUser.getPlayerInfoManager().setGuildId(guildInfo.getId());
|
||||
GuilidManager.removeMineApplyGuildInfos(guildInfo.getId(),applyId);
|
||||
GuilidManager.removeOneApplyGuildInfos(guildInfo.getId(),applyId);
|
||||
Family.FamilyWalkIndicaiton familyWalkIndicaiton = CBean2Proto.getFamilyWalkIndicaiton(targetUser);
|
||||
sendIndicationToMember(guildInfo, MessageTypeProto.MessageType.FAMILY_WALK_INDICATION,familyWalkIndicaiton);
|
||||
}catch (Exception e){
|
||||
LOGGER.error("the exception={}",e);
|
||||
}finally {
|
||||
|
|
@ -707,21 +702,16 @@ public class GuildLogic {
|
|||
return;
|
||||
}
|
||||
GuildMyInfo guildMyInfo = user.getGuildMyInfo();
|
||||
|
||||
|
||||
user.getGuildMyInfo().move(System.currentTimeMillis());
|
||||
LOGGER.info("old ={},path={}",guildMyInfo.getCurPos(),path);
|
||||
LOGGER.info("cur ={},path={}",guildMyInfo.getCurPos(),path);
|
||||
boolean continuous = CellUtil.isContinuous(guildMyInfo.getCurPos(),path);
|
||||
if(!continuous){
|
||||
MessageUtil.sendErrorResponse(session,0,msgId,"路线有误");
|
||||
return;
|
||||
}
|
||||
user.getGuildMyInfo().move(path);
|
||||
LOGGER.info("cur ={},path={}",guildMyInfo.getCurPos(),path);
|
||||
Family.FamilyWalkIndicaiton familyWalkIndicaiton = CBean2Proto.getFamilyWalkIndicaiton(user);
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||
sendIndicationToMember(guildInfo, MessageTypeProto.MessageType.FAMILY_WALK_INDICATION,familyWalkIndicaiton);
|
||||
MessageUtil.sendMessage(session,1,msgId,null,true);
|
||||
}
|
||||
|
||||
public static void updateMyPos(User user) {
|
||||
|
|
@ -778,90 +768,13 @@ public class GuildLogic {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看工会布防信息
|
||||
* @param session
|
||||
* @param messageType
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void viewDefendInfo(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
int gid = user.getPlayerInfoManager().getGuildId();
|
||||
GuildInfo guildInfo =GuilidManager.guildInfoMap.get(gid);
|
||||
Map<Integer, Integer> defendInfo = guildInfo.getDefendInfo();
|
||||
Family.FamilyDefendViewResponse.Builder response = Family.FamilyDefendViewResponse.newBuilder();
|
||||
for(Map.Entry<Integer, Integer> entry:defendInfo.entrySet()){
|
||||
Family.FamilyDefendInfo.Builder defend = Family.FamilyDefendInfo.newBuilder();
|
||||
defend.setStarCount(5);
|
||||
defend.setUid(entry.getKey());
|
||||
defend.setBuildId(entry.getValue());
|
||||
defend.setCurForce(HeroLogic.getInstance().calTeamTotalForce(UserManager.getUser(entry.getKey()),501,false));
|
||||
response.addInfo(defend);
|
||||
}
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看公会具体布防信息
|
||||
* @param session
|
||||
* @param uid
|
||||
* @param messageType
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void viewDefendDetailInfo(ISession session,int uid,MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User user = UserManager.getUser(uid);
|
||||
TeamPosManager teamPosManager = user.getTeamPosManager();
|
||||
CommonProto.Team.Builder team = CommonProto.Team.newBuilder();
|
||||
for (TeamPosHeroInfo heroInfo:teamPosManager.getTeamPosForHero().get(501)) {
|
||||
int templateId = user.getHeroManager().getHero(heroInfo.getHeroId()).getTemplateId();
|
||||
team.addHeroTid(templateId);
|
||||
}
|
||||
CommonProto.TeamOneTeamInfo.Builder oneInfo = CommonProto.TeamOneTeamInfo.newBuilder()
|
||||
.setTeam(team);
|
||||
oneInfo.setTotalForce(HeroLogic.getInstance().calTeamTotalForce(user,501,false));
|
||||
if(teamPosManager.getTeamPosForPoken().get(1)!=null&&teamPosManager.getTeamPosForPoken().get(1).size()>0){
|
||||
for(TeamPosForPokenInfo posForPokenInfo:teamPosManager.getTeamPosForPoken().get(1)){
|
||||
oneInfo.addPokemonInfos(posForPokenInfo.getPokenId());
|
||||
}
|
||||
}
|
||||
Family.FamilyDefendDetailViewResponse.Builder response = Family.FamilyDefendDetailViewResponse.newBuilder();
|
||||
response.setTeamInfo(oneInfo);
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
|
||||
}
|
||||
/**
|
||||
* 一键布防、调整布防
|
||||
* @param session
|
||||
* @param messageType
|
||||
*/
|
||||
public static void quickSetDefend(ISession session,int buildId,int uid, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User user = UserManager.getUser(uid);
|
||||
TeamPosManager teamPosManager = user.getTeamPosManager();
|
||||
if(teamPosManager.getTeamPosForHero().get(501)==null||teamPosManager.getTeamPosForHero().get(501).size()<1){
|
||||
teamPosManager.updateTeamPosByTeamId(501,teamPosManager.getTeamPosForHero().get(1));
|
||||
}
|
||||
if(buildId==0){
|
||||
buildId = 1;
|
||||
}
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(user.getPlayerInfoManager().getGuildId());
|
||||
guildInfo.updateDefendInfo(uid,buildId);
|
||||
Family.FamilyDefendInfo.Builder defend = Family.FamilyDefendInfo.newBuilder();
|
||||
defend.setBuildId(buildId);
|
||||
defend.setUid(uid);
|
||||
defend.setStarCount(5);
|
||||
defend.setCurForce(HeroLogic.getInstance().calTeamTotalForce(user,501,false));
|
||||
sendIndicationToMember(guildInfo,MessageTypeProto.MessageType.FAMILY_QUICK_SET_DEFEND_INDICATION,defend.build());
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给公会所有在线成员发送indication
|
||||
* @param guildInfo
|
||||
* @param messageType
|
||||
* @param generatedMessage
|
||||
*/
|
||||
private static void sendIndicationToMember(GuildInfo guildInfo, MessageTypeProto.MessageType messageType, GeneratedMessage generatedMessage){
|
||||
public static void sendIndicationToMember(GuildInfo guildInfo, MessageTypeProto.MessageType messageType, GeneratedMessage generatedMessage){
|
||||
Map<Integer, Set<Integer>> members = guildInfo.getMembers();
|
||||
for(Set<Integer> items : members.values()){
|
||||
for(Integer sendUid : items){
|
||||
|
|
@ -872,159 +785,4 @@ public class GuildLogic {
|
|||
}
|
||||
}
|
||||
}
|
||||
private static Family.FamilyFightInfo familyFightDetailInfo(int guildId) throws Exception {
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||
Map<Integer, Integer> defendInfo = guildInfo.getDefendInfo();
|
||||
Family.FamilyFightInfo.Builder fightInfo = Family.FamilyFightInfo.newBuilder();
|
||||
fightInfo.setGid(guildId);
|
||||
for(int i = 0 ; i <3 ;i ++){
|
||||
Family.FamilyBuildBuffInfo.Builder buffInfo = Family.FamilyBuildBuffInfo.newBuilder();
|
||||
buffInfo.setBuildId(i+1);
|
||||
buffInfo.setBuffId(i+1);
|
||||
fightInfo.addBuildBuff(buffInfo);
|
||||
}
|
||||
for(Map.Entry<Integer, Integer> entry:defendInfo.entrySet()){
|
||||
Family.FamilyFightPlayerInfo.Builder playerInfo = Family.FamilyFightPlayerInfo.newBuilder();
|
||||
playerInfo.setBuildId(entry.getValue());
|
||||
playerInfo.setStarCount(5);
|
||||
PlayerManager playerManager = UserManager.getUser(entry.getKey()).getPlayerInfoManager();
|
||||
Family.FamilyUserInfo.Builder userInfo =Family.FamilyUserInfo.newBuilder()
|
||||
.setRoleUid(entry.getKey())
|
||||
.setUserName(playerManager.getNickName())
|
||||
.setUserLevel(playerManager.getLevel())
|
||||
.setPosition(2)
|
||||
.setSoulForce(HeroLogic.getInstance().calTeamTotalForce(UserManager.getUser(entry.getKey()),501,false))
|
||||
.setHead(playerManager.getHead())
|
||||
.setFrame(playerManager.getHeadFrame())
|
||||
.setContribute(0);
|
||||
playerInfo.setUserInfo(userInfo.build());
|
||||
fightInfo.addUser(playerInfo);
|
||||
}
|
||||
return fightInfo.build();
|
||||
}
|
||||
/**
|
||||
* 公会战查看双方对战信息
|
||||
* @param session
|
||||
* @param messageType
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void viewFightInfo(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||
int enemyId = 13;
|
||||
if(guildId==13){
|
||||
enemyId = 14;
|
||||
}
|
||||
Family.FamilyFightInfoResponse.Builder builder = Family.FamilyFightInfoResponse.newBuilder();
|
||||
builder.addInfo(familyFightDetailInfo(guildId));
|
||||
builder.addInfo(familyFightDetailInfo(enemyId));
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),builder.build(),true);
|
||||
|
||||
}
|
||||
/**
|
||||
* 公会战计入缓存
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void familyFightMatching() throws Exception {
|
||||
Set<Integer> guildIds= GuilidManager.guildInfoMap.keySet();
|
||||
if(guildIds.size()<1){
|
||||
return;
|
||||
}
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
Set<String> rank = redisUtil.getZset(RedisKey.FAMILY_FIGHT_RANK, 0, redisUtil.getZsetSize(RedisKey.FAMILY_FIGHT_RANK));
|
||||
for(Integer gid:guildIds){
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(gid);
|
||||
if(guildInfo.getDefendInfo()!=null&&guildInfo.getDefendInfo().size()>0) {
|
||||
if (!rank.contains(gid.toString())) {
|
||||
String key = RedisKey.getKey(RedisKey.FAMILY_FIGHT_MATCHING_RANK, gid.toString(), false);
|
||||
redisUtil.zsetAddOne(key, gid.toString(), 100);
|
||||
} else {
|
||||
Double zSetScore = redisUtil.getZSetScore(RedisKey.FAMILY_FIGHT_RANK, "", gid.toString());
|
||||
redisUtil.zsetAddOne(RedisKey.FAMILY_FIGHT_MATCHING_RANK, gid.toString(), zSetScore);
|
||||
}
|
||||
}
|
||||
Map<Integer, Integer> defendInfo = guildInfo.getDefendInfo();
|
||||
if(defendInfo==null||defendInfo.size()<1){
|
||||
continue;
|
||||
}
|
||||
for(Map.Entry<Integer,Integer> entry:defendInfo.entrySet()){
|
||||
User user = UserManager.getUser(entry.getKey());
|
||||
HeroManager heroManager = user.getHeroManager();
|
||||
TeamPosManager teamPosManager = user.getTeamPosManager();
|
||||
List<TeamPosHeroInfo> teamPosHeroInfos = teamPosManager.getTeamPosForHero().get(501);
|
||||
Iterator<TeamPosHeroInfo> it = teamPosHeroInfos.iterator();
|
||||
FamilyFightInfo fightInfo = new FamilyFightInfo();
|
||||
Map<String ,FamilyHeroInfo> heroAllAttribute = new HashMap<>();
|
||||
while (it.hasNext()){
|
||||
TeamPosHeroInfo heroInfo = it.next();
|
||||
Hero hero = heroManager.getHero(heroInfo.getHeroId());
|
||||
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false,501);
|
||||
heroAllAttribute.put(heroInfo.getHeroId(),new FamilyHeroInfo(hero.getTemplateId(),hero.getLevel(),heroAttributeMap));
|
||||
}
|
||||
fightInfo.setHeroAttribute(heroAllAttribute);
|
||||
redisUtil.putMapEntry(RedisKey.FAMILY_FIGHT,String.valueOf(guildInfo.getId()),String.valueOf(entry.getKey()),fightInfo);
|
||||
}
|
||||
}
|
||||
// redisUtil.getZset(key,0, redisUtil.getZsetSize(RedisKey.FAMILY_FIGHT_RANK));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 战斗之后数据更新
|
||||
* @param userAttack
|
||||
* @param userDefend
|
||||
*/
|
||||
public void familyFightResult(User userAttack,User userDefend){
|
||||
int defendGuildId =userDefend.getPlayerInfoManager().getGuildId();
|
||||
FamilyFightInfo defendInfo = RedisUtil.getInstence().getMapEntry(RedisKey.FAMILY_FIGHT, String.valueOf(defendGuildId), String.valueOf(userDefend.getId()), FamilyFightInfo.class);
|
||||
Map<String, FamilyHeroInfo> heroAttribute = defendInfo.getHeroAttribute();
|
||||
int seed = (int)(System.currentTimeMillis()/1000);
|
||||
List<CommonProto.FightUnitInfo> heroDefendFightInfos = new ArrayList<>();
|
||||
for (Map.Entry<String, FamilyHeroInfo> entry : heroAttribute.entrySet()) {
|
||||
Hero hero = userDefend.getHeroManager().getHero(entry.getKey());
|
||||
if (hero == null) {
|
||||
continue;
|
||||
}
|
||||
StringBuilder skillSb = new StringBuilder();
|
||||
StringBuilder propertySb = new StringBuilder();
|
||||
String heroSkill = HeroLogic.getInstance().getHeroSkills(userDefend,hero,skillSb).toString();
|
||||
String property = HeroLogic.getInstance().getHeroPropertyBuilder(propertySb,hero,entry.getValue().getAttribute()).toString();
|
||||
CommonProto.FightUnitInfo heroFightInfo = CommonProto.FightUnitInfo
|
||||
.newBuilder()
|
||||
.setUnitId(Integer.toString(hero.getTemplateId()))
|
||||
.setUnitSkillIds(heroSkill.substring(0,heroSkill.length()-1))
|
||||
.setProperty(property.substring(0, property.length()-1))
|
||||
.build();
|
||||
heroDefendFightInfos.add(heroFightInfo);
|
||||
}
|
||||
CommonProto.FightTeamInfo fightDefendTeamInfo = CommonProto.FightTeamInfo.
|
||||
newBuilder()
|
||||
.addAllFightUnitList(heroDefendFightInfos)
|
||||
.setTeamSkillList(HeroLogic.getInstance().getPokenmonSkills(userDefend,1))
|
||||
.build();
|
||||
CommonProto.FightTeamInfo fightAttackTeamInfo = BehaviorUtil.getFightTeamInfo(userAttack, 502, true);
|
||||
LuaValue getFightData = FightDataUtil.getFinalPlayerFightData(fightAttackTeamInfo, fightDefendTeamInfo);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData("");
|
||||
|
||||
int[] fightResult = CheckFight.getInstance().checkFight(seed,1000,getFightData,getOptionData);
|
||||
int index = 2;
|
||||
// 战斗之后数据处理
|
||||
for (Map.Entry<String, FamilyHeroInfo> entry : heroAttribute.entrySet()) {
|
||||
FamilyHeroInfo value = entry.getValue();
|
||||
Map<Integer, Integer> attribute = value.getAttribute();
|
||||
attribute.put(HeroAttributeEnum.CurHP.getPropertyId(),fightResult[index]);
|
||||
value.setAttribute(attribute);
|
||||
index++;
|
||||
}
|
||||
defendInfo.setHeroAttribute(heroAttribute);
|
||||
if(fightResult[0]==0){
|
||||
defendInfo.setStarCount(defendInfo.getStarCount()-1);
|
||||
}
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.FAMILY_FIGHT,String.valueOf(defendGuildId),String.valueOf(userDefend.getId()),defendInfo);
|
||||
}
|
||||
public void accountFamilyFightResult(){
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.logic.friend;
|
||||
|
||||
import com.ljsd.jieling.config.SGameSetting;
|
||||
import com.ljsd.jieling.core.HandlerLogicThread;
|
||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
|
|
@ -12,14 +13,14 @@ import com.ljsd.jieling.logic.dao.FriendManager;
|
|||
import com.ljsd.jieling.logic.dao.PlayerManager;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||
import com.ljsd.jieling.logic.mission.event.MissionEventDistributor;
|
||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.CBean2Proto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.util.StringUtil;
|
||||
import com.ljsd.jieling.util.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
@ -272,6 +273,8 @@ public class FriendLogic {
|
|||
|
||||
initFriendGriveAndRreward(friendId, uid, friendManager, friendfriendManager);
|
||||
sendFriendInfoIndication(uid,friendId,2);
|
||||
user.getUserMissionManager().onGameEvent(user,GameEvent.FRIEND_NUMS,1);
|
||||
updateFriendUserInfo(friendUser);
|
||||
break;
|
||||
case 2://拒绝
|
||||
applyFriends = friendManager.getApplyFriends();
|
||||
|
|
@ -280,7 +283,8 @@ public class FriendLogic {
|
|||
}
|
||||
break;
|
||||
case 3://全部同意
|
||||
allApplyFriend(uid, friendManager, friends, applyFriends, maxFriends);
|
||||
int nums = allApplyFriend(uid, friendManager, friends, applyFriends, maxFriends);
|
||||
user.getUserMissionManager().onGameEvent(user,GameEvent.FRIEND_NUMS,nums);
|
||||
break;
|
||||
case 4://全部拒绝
|
||||
friendManager.setApplyFriends(new CopyOnWriteArrayList<>());
|
||||
|
|
@ -289,10 +293,33 @@ public class FriendLogic {
|
|||
MessageUtil.sendMessage(iSession, 1, msgId, null, true);
|
||||
}
|
||||
|
||||
private void allApplyFriend(int uid, FriendManager friendManager, List<Integer> friends, List<Integer> applyFriends, int maxFriends) throws Exception {
|
||||
private void updateFriendUserInfo(User friendUser){
|
||||
AyyncWorker ayyncWorker = new AyyncWorker(friendUser,true) {
|
||||
@Override
|
||||
public void work(User user) throws Exception {
|
||||
boolean isOnline = OnlineUserManager.checkUidOnline(user.getId());
|
||||
if(isOnline){
|
||||
MissionEventDistributor.requestStart();
|
||||
}
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.FRIEND_NUMS, 1);
|
||||
if(isOnline){
|
||||
ISession session = OnlineUserManager.getSessionByUid(user.getId());
|
||||
MissionEventDistributor.requestEnd(session,true);
|
||||
}
|
||||
MongoUtil.getInstence().lastUpdate();
|
||||
|
||||
}
|
||||
};
|
||||
ProtocolsManager instance = ProtocolsManager.getInstance();
|
||||
HandlerLogicThread handlerThread = instance.handlerThreads[friendUser.getId() % instance.HANDLER_THREAD_NUM];
|
||||
handlerThread.addAyyncWorker(ayyncWorker);
|
||||
}
|
||||
|
||||
private int allApplyFriend(int uid, FriendManager friendManager, List<Integer> friends, List<Integer> applyFriends, int maxFriends) throws Exception {
|
||||
User friendUser;
|
||||
FriendManager friendfriendManager;
|
||||
List<Integer> friendFriendList;
|
||||
int nums =0;
|
||||
for (Integer applyfriendId :applyFriends){
|
||||
friendUser = UserManager.getUser(applyfriendId);
|
||||
friendfriendManager = friendUser.getFriendManager();
|
||||
|
|
@ -311,7 +338,10 @@ public class FriendLogic {
|
|||
friendManager.addFriendId(applyfriendId);
|
||||
initFriendGriveAndRreward(applyfriendId, uid, friendManager, friendfriendManager);
|
||||
sendFriendInfoIndication(uid,applyfriendId,2);
|
||||
nums++;
|
||||
updateFriendUserInfo(friendUser);
|
||||
}
|
||||
return nums;
|
||||
}
|
||||
|
||||
private void initFriendGriveAndRreward(int friendId, int uid, FriendManager friendManager, FriendManager friendfriendManager) {
|
||||
|
|
@ -377,6 +407,7 @@ public class FriendLogic {
|
|||
FriendManager friendManager = user.getFriendManager();
|
||||
List<Integer> friends = friendManager.getFriends();
|
||||
Map<Integer, Integer> giveMap = friendManager.getGiveMap();
|
||||
int times = 0;
|
||||
if (type == 1) {//赠送一个人
|
||||
if (!friends.contains(friendId)) {
|
||||
MessageUtil.sendErrorResponse(iSession, 0, msgId, "没有该好友");
|
||||
|
|
@ -398,6 +429,7 @@ public class FriendLogic {
|
|||
if(check){
|
||||
friendManager1.updateHaveRewardMap(uid,1);
|
||||
sendFriendStatedication(uid,friendId,2);
|
||||
times++;
|
||||
}
|
||||
}else{ //赠送全部好友
|
||||
for (Integer friendUserId : friends) {
|
||||
|
|
@ -415,9 +447,11 @@ public class FriendLogic {
|
|||
if(check){
|
||||
friendManager1.updateHaveRewardMap(uid,1);
|
||||
sendFriendStatedication(uid,friendId,2);
|
||||
times++;
|
||||
}
|
||||
}
|
||||
}
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.GIVE_PRESENT,times);
|
||||
MessageUtil.sendMessage(iSession, 1, msgId, null, true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,16 @@
|
|||
package com.ljsd.jieling.logic.hero;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.common.mogodb.util.GlobalData;
|
||||
import com.ljsd.jieling.chat.logic.ChatLogic;
|
||||
import com.ljsd.jieling.config.*;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.core.VipPrivilegeType;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.ktbeans.KtEventUtils;
|
||||
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
import com.ljsd.jieling.logic.activity.ActivityType;
|
||||
import com.ljsd.jieling.logic.activity.event.HeroUpStarEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.fight.CombatLogic;
|
||||
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
|
|
@ -24,13 +18,9 @@ import com.ljsd.jieling.protocols.CommonProto;
|
|||
import com.ljsd.jieling.protocols.HeroInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.*;
|
||||
import com.sun.org.apache.regexp.internal.RE;
|
||||
import org.omg.CORBA.PUBLIC_MEMBER;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.logging.Slf4JLoggingSystem;
|
||||
|
||||
import java.rmi.ServerError;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
|
@ -147,11 +137,13 @@ public class HeroLogic {
|
|||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
SLotterySetting sLotterySetting = SLotterySetting.getsLotterySettingMap().get(type);
|
||||
|
||||
HeroManager heroManager = user.getHeroManager();
|
||||
if(type==11&&heroManager.getFirstTenth()==0){
|
||||
heroManager.updateFirstTenth();
|
||||
}
|
||||
//筛选卡池
|
||||
int pooId =0;
|
||||
int perCount = sLotterySetting.getPerCount();
|
||||
HeroManager heroManager = user.getHeroManager();
|
||||
if(heroManager!=null&& heroManager.getHeroMap()!=null){
|
||||
if(heroManager.getHeroMap().size() + perCount > SGameSetting.getGameSetting().getHeroNumlimit()){
|
||||
MessageUtil.sendErrorResponse(session, 0, MessageTypeProto.MessageType.HERO_RAND_RESPONSE_VALUE,"超出数量上限");
|
||||
|
|
@ -638,7 +630,7 @@ public class HeroLogic {
|
|||
targetHero.upStar( 1 );
|
||||
Poster.getPoster().dispatchEvent(new HeroUpStarEvent(user.getId(),targetHero.getStar()));
|
||||
targetHero.setStarBreakId(scHeroRankUpConfig.getId());
|
||||
user.getUserMissionManager().onGameEvent(user,GameEvent.HERO_UP,2,targetHero.getTemplateId());
|
||||
user.getUserMissionManager().onGameEvent(user,GameEvent.HERO_UP,2,targetHero.getTemplateId(),targetHero.getStar());
|
||||
MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.UP_HERO_STAR_RESPONSE_VALUE,null,true);
|
||||
if(targetHero.getStar()>=7){
|
||||
String message = SErrorCodeEerverConfig.getI18NMessage("lamp_rankup_hero_content", new Object[]{user.getPlayerInfoManager().getNickName(), scHero.getReadingName(),targetHero.getStar()});
|
||||
|
|
|
|||
|
|
@ -46,4 +46,7 @@ public enum GameEvent {
|
|||
|
||||
HERO_IN_TEAM, // 上阵卡牌数量
|
||||
|
||||
GIVE_PRESENT,//赠送体力
|
||||
FRIEND_NUMS,//好友数量
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -559,6 +559,21 @@ public class MissionLoigc {
|
|||
case HERO_IN_TEAM_NUMS:
|
||||
count = cumulationData.heroInTeamNums;
|
||||
break;
|
||||
case BUY_GROCERY_TIMES:
|
||||
count = cumulationData.buyGenerStoreTimes;
|
||||
break;
|
||||
case FRIEND_NUMS:
|
||||
count = cumulationData.friendNums;
|
||||
break;
|
||||
case GIVE_FRIEND_STAMIN_TIMES:
|
||||
count = cumulationData.givePresents;
|
||||
break;
|
||||
case HERO_UP_SOME_STAR_TIMES:
|
||||
num = cumulationData.heroUpSomeStarTimesMap.get(missionSubType[0]);
|
||||
if(num!=null){
|
||||
count = num;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
count = 0;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.ljsd.jieling.logic.mission;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum MissionType {
|
||||
RECRUITMENT_RANDOM_HEROES(1), //群英征募 群英招募次数
|
||||
COLLECT_QUALITY_HERO (2), //获得某品质妖灵师 获得SSR、SR品质的妖灵师数量
|
||||
|
|
@ -62,9 +65,16 @@ public enum MissionType {
|
|||
SYNTHESIS_HERO_STAR_TIMES(47),//碎片合成%s星妖灵师次数达到
|
||||
USER_CONSUMER_STAMINA(48),//消耗体力数量达到
|
||||
COLLECT_DIFFERENT_HEROS(49), // 收集不同妖灵师数目达到
|
||||
ONE_HERO_UP_STAR_TIMES(50), // 收集不同妖灵师数目达到
|
||||
ONE_HERO_UP_STAR_TIMES(50), // 将妖灵师%s进阶次数达到
|
||||
|
||||
HERO_IN_TEAM_NUMS(51), // 上阵卡牌数量
|
||||
|
||||
BUY_GROCERY_TIMES(52),//杂货店购买次数:%s
|
||||
FRIEND_NUMS(53),//拥有好友的个数:%:%s
|
||||
GIVE_FRIEND_STAMIN_TIMES(54),//赠送好友体力次数:%s
|
||||
HERO_UP_SOME_STAR_TIMES(55),//进阶x星卡牌个数达到:%s
|
||||
|
||||
|
||||
;
|
||||
|
||||
private int missionType;
|
||||
|
|
@ -181,6 +191,14 @@ public enum MissionType {
|
|||
return ONE_HERO_UP_STAR_TIMES;
|
||||
case 51:
|
||||
return HERO_IN_TEAM_NUMS;
|
||||
case 52:
|
||||
return BUY_GROCERY_TIMES;
|
||||
case 53:
|
||||
return FRIEND_NUMS;
|
||||
case 54:
|
||||
return GIVE_FRIEND_STAMIN_TIMES;
|
||||
case 55:
|
||||
return HERO_UP_SOME_STAR_TIMES;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,18 +3,23 @@ package com.ljsd.jieling.logic.mission.data;
|
|||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.logic.dao.CumulationData;
|
||||
import com.ljsd.jieling.logic.mission.MissionType;
|
||||
import com.ljsd.jieling.logic.store.StoreType;
|
||||
|
||||
public class BuyGoodsManager implements BaseDataManager {
|
||||
@Override
|
||||
public CumulationData.Result updateData(CumulationData data, MissionType missionType, Object... parm) {
|
||||
int itemId = (int)parm[0];
|
||||
int itemNum = (int)parm[1];
|
||||
int storeType = (int)parm[2];
|
||||
if(missionType == MissionType.BUY_GOLD_TIMES && itemId == Global.GOLD){
|
||||
data.buyGoldTimes = data.buyGoldTimes + itemNum;
|
||||
return new CumulationData.Result(missionType);
|
||||
}else if(missionType == MissionType.BUY_STAMINA_TIMES && itemId == Global.STAMINA){
|
||||
data.buyStaminaTimes = data.buyStaminaTimes + itemNum;
|
||||
return new CumulationData.Result(missionType);
|
||||
}else if(missionType == MissionType.BUY_GROCERY_TIMES && storeType == StoreType.GENERAL_STORE.getType()){
|
||||
data.buyGenerStoreTimes = data.buyGenerStoreTimes + itemNum;
|
||||
return new CumulationData.Result(missionType);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ public class DataManagerDistributor {
|
|||
|
||||
judges.put(MissionType.BUY_GOLD_TIMES,new BuyGoodsManager());
|
||||
judges.put(MissionType.BUY_STAMINA_TIMES,new BuyGoodsManager());
|
||||
judges.put(MissionType.BUY_GROCERY_TIMES,new BuyGoodsManager());
|
||||
|
||||
judges.put(MissionType.WORKSHOP_CREATE_EQUIP_NUMS,new WorkShopCreateEquipTimesManager());
|
||||
|
||||
|
|
@ -73,6 +74,7 @@ public class DataManagerDistributor {
|
|||
judges.put(MissionType.HERO_BREAK_TIMES,new HeroUpDataManager());
|
||||
judges.put(MissionType.HERO_UP_STAR_TIMES,new HeroUpDataManager());
|
||||
judges.put(MissionType.ONE_HERO_UP_STAR_TIMES,new HeroUpDataManager());
|
||||
judges.put(MissionType.HERO_UP_SOME_STAR_TIMES,new HeroUpDataManager());
|
||||
|
||||
judges.put(MissionType.TAKE_CHAPTER_REWARD_TIMES,new TakeActivityRewardHandler());
|
||||
judges.put(MissionType.TAKE_ONLINE_REWARD_TIMES,new TakeActivityRewardHandler());
|
||||
|
|
@ -86,6 +88,10 @@ public class DataManagerDistributor {
|
|||
|
||||
judges.put(MissionType.HERO_IN_TEAM_NUMS,new HeroInTeamNumsDataManager());
|
||||
|
||||
judges.put(MissionType.GIVE_FRIEND_STAMIN_TIMES,new GivePresentDataManager());
|
||||
|
||||
judges.put(MissionType.FRIEND_NUMS,new FriendNumDataManager());
|
||||
|
||||
|
||||
judges.put(MissionType.VIP_LEVEL,new DefaultDataManager());
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
package com.ljsd.jieling.logic.mission.data;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.CumulationData;
|
||||
import com.ljsd.jieling.logic.mission.MissionType;
|
||||
|
||||
public class FriendNumDataManager implements BaseDataManager{
|
||||
@Override
|
||||
public CumulationData.Result updateData(CumulationData data, MissionType missionType, Object... parm) {
|
||||
int nums = (int)parm[0];
|
||||
data.friendNums+=nums;
|
||||
return new CumulationData.Result(missionType);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.ljsd.jieling.logic.mission.data;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.CumulationData;
|
||||
import com.ljsd.jieling.logic.mission.MissionType;
|
||||
|
||||
public class GivePresentDataManager implements BaseDataManager{
|
||||
@Override
|
||||
public CumulationData.Result updateData(CumulationData data, MissionType missionType, Object... parm) {
|
||||
int times = (int)parm[0];
|
||||
data.givePresents+=times;
|
||||
return new CumulationData.Result(missionType);
|
||||
}
|
||||
}
|
||||
|
|
@ -7,13 +7,24 @@ public class HeroUpDataManager implements BaseDataManager {
|
|||
@Override
|
||||
public CumulationData.Result updateData(CumulationData data, MissionType missionType, Object... parm) {
|
||||
int type = (int) parm[0];
|
||||
if(missionType == MissionType.HERO_BREAK_TIMES && type == 1){
|
||||
data.heroBreakTimes++;
|
||||
}else if(missionType == MissionType.HERO_UP_STAR_TIMES && type == 2){
|
||||
data.heroUpStarTimes++;
|
||||
}else if(missionType == MissionType.ONE_HERO_UP_STAR_TIMES && type == 2){
|
||||
int heroTid = (int) parm[1];
|
||||
data.updateHeroUpStarTimes(heroTid);
|
||||
if(type == 1){
|
||||
if(missionType == MissionType.HERO_BREAK_TIMES){
|
||||
data.heroBreakTimes++;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}else if(type == 2){
|
||||
if(missionType == MissionType.HERO_UP_STAR_TIMES){
|
||||
data.heroUpStarTimes++;
|
||||
}else if(missionType == MissionType.ONE_HERO_UP_STAR_TIMES){
|
||||
int heroTid = (int) parm[1];
|
||||
data.updateHeroUpStarTimes(heroTid);
|
||||
}else if(missionType == MissionType.HERO_UP_SOME_STAR_TIMES){
|
||||
int heroStar = (int) parm[2];
|
||||
data.updateHeroUpSomeStarTimes(heroStar);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ public class MissionEventDistributor {
|
|||
typeList = new ArrayList<>();
|
||||
typeList.add(MissionType.BUY_GOLD_TIMES);
|
||||
typeList.add(MissionType.BUY_STAMINA_TIMES);
|
||||
typeList.add(MissionType.BUY_GROCERY_TIMES);
|
||||
eventEnumListMap.put(GameEvent.BUY_MATERIAL,typeList);
|
||||
eventProcessor.put(GameEvent.BUY_MATERIAL,new CumulationDataEventProcessor());
|
||||
|
||||
|
|
@ -189,6 +190,7 @@ public class MissionEventDistributor {
|
|||
typeList.add(MissionType.HERO_BREAK_TIMES);
|
||||
typeList.add(MissionType.HERO_UP_STAR_TIMES);
|
||||
typeList.add(MissionType.ONE_HERO_UP_STAR_TIMES);
|
||||
typeList.add(MissionType.HERO_UP_SOME_STAR_TIMES);
|
||||
eventEnumListMap.put(GameEvent.HERO_UP,typeList);
|
||||
eventProcessor.put(GameEvent.HERO_UP,new CumulationDataEventProcessor());
|
||||
|
||||
|
|
@ -219,6 +221,16 @@ public class MissionEventDistributor {
|
|||
eventEnumListMap.put(GameEvent.HERO_IN_TEAM,typeList);
|
||||
eventProcessor.put(GameEvent.HERO_IN_TEAM,new CumulationDataEventProcessor());
|
||||
|
||||
typeList = new ArrayList<>();
|
||||
typeList.add(MissionType.GIVE_FRIEND_STAMIN_TIMES);
|
||||
eventEnumListMap.put(GameEvent.GIVE_PRESENT,typeList);
|
||||
eventProcessor.put(GameEvent.GIVE_PRESENT,new CumulationDataEventProcessor());
|
||||
|
||||
typeList = new ArrayList<>();
|
||||
typeList.add(MissionType.FRIEND_NUMS);
|
||||
eventEnumListMap.put(GameEvent.FRIEND_NUMS,typeList);
|
||||
eventProcessor.put(GameEvent.FRIEND_NUMS,new CumulationDataEventProcessor());
|
||||
|
||||
}
|
||||
|
||||
private static final ThreadLocal<Map<GameMisionType, List<MissionStateChangeInfo>>> threadMissionChangeList =
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ public class StoreLogic {
|
|||
}
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, dropItems, BIReason.STORE_BUY_ITEM);
|
||||
if(SStoreTypeConfig.getsStoreTypeConfigMap().get(storeId).getStoreType() != StoreType.GIFT_STORE.getType()){
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.BUY_MATERIAL,sStoreConfig.getGoods()[0][0],itemNum);
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.BUY_MATERIAL,sStoreConfig.getGoods()[0][0],itemNum,SStoreTypeConfig.getsStoreTypeConfigMap().get(storeId).getStoreType());
|
||||
}
|
||||
if(itemId==10005){
|
||||
Poster.getPoster().dispatchEvent(new GoldEvent(user.getId(),itemNum));
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
public static Map<MessageTypeProto.MessageType, String> gameMessageForLogin = new ConcurrentHashMap<>();
|
||||
private Map<Integer, BaseHandler> handlers = new HashMap<>();
|
||||
|
||||
public final int HANDLER_THREAD_NUM = 50;
|
||||
public HandlerLogicThread[] handlerThreads = new HandlerLogicThread[HANDLER_THREAD_NUM];
|
||||
public final int HANDLER_THREAD_NUM = 50;
|
||||
public HandlerLogicThread[] handlerThreads = new HandlerLogicThread[HANDLER_THREAD_NUM];
|
||||
|
||||
private ProtocolsManager() {
|
||||
initContext();
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.ljsd.jieling.logic.OnlineUserManager;
|
|||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
import com.ljsd.jieling.logic.arena.ArenaLogic;
|
||||
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
||||
import com.ljsd.jieling.logic.fight.CheckFight;
|
||||
import com.ljsd.jieling.logic.fight.CombatLogic;
|
||||
import com.ljsd.jieling.logic.store.StoreLogic;
|
||||
|
|
@ -49,6 +50,7 @@ public class MinuteTask extends Thread {
|
|||
fiveMinuteOnlineSend();
|
||||
CheckFight.getInstance().luaHotFix();
|
||||
MongoUtil.getInstence().lastUpdate();
|
||||
GuildFightLogic.familyFightStatus();
|
||||
LOGGER.info("MinuteTask end...");
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("e",e);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package com.ljsd.jieling.util;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
||||
public abstract class AyyncWorker {
|
||||
private User user;
|
||||
private boolean isTask;
|
||||
public AyyncWorker(User user,boolean isTask){
|
||||
this.user = user;
|
||||
this.isTask = isTask;
|
||||
}
|
||||
public void exec() throws Exception {
|
||||
work(user);
|
||||
}
|
||||
public abstract void work(User user) throws Exception;
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue