Merge branch 'master_test_gn' of http://60.1.1.230/backend/jieling_server into master_test_gn
commit
77b9fb6426
|
@ -794,10 +794,25 @@ public class TimeUtils {
|
|||
st.setTimeInMillis(src);
|
||||
Calendar et = Calendar.getInstance();
|
||||
et.setTimeInMillis(target);
|
||||
|
||||
return st.get(Calendar.WEEK_OF_YEAR) == et.get(Calendar.WEEK_OF_YEAR);
|
||||
return (st.get(Calendar.YEAR) ==et.get(Calendar.YEAR)) && (st.get(Calendar.WEEK_OF_YEAR) == et.get(Calendar.WEEK_OF_YEAR));
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为同一周
|
||||
*星期1是一周的开始
|
||||
* @param src
|
||||
* @param target
|
||||
* @return
|
||||
*/
|
||||
public static boolean isSameWeek7(long src) {
|
||||
long weekStart = getCurWeekdayStartTime(1,0);
|
||||
long weekEnd = TimeUtils.getCurWeekdayStartTime(1,0) + TimeUtils.WEEK;
|
||||
if(src>=weekStart && src<=weekEnd){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为同一周周一算第一天
|
||||
*
|
||||
|
|
|
@ -13,17 +13,19 @@ import com.ljsd.jieling.logic.activity.event.UserForceChangeEvent;
|
|||
import com.ljsd.jieling.logic.activity.eventhandler.UserForceUpEventHandler;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.FightRecordLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.thrift.idl.InvalidOperException;
|
||||
import com.ljsd.jieling.thrift.idl.RPCRequestGMIFace;
|
||||
import com.ljsd.jieling.thrift.idl.Result;
|
||||
import com.ljsd.jieling.util.*;
|
||||
import com.ljsd.jieling.util.InnerMessageUtil;
|
||||
import org.apache.thrift.TException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class GmService implements RPCRequestGMIFace.Iface {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GmService.class);
|
||||
|
@ -52,7 +54,6 @@ public class GmService implements RPCRequestGMIFace.Iface {
|
|||
}
|
||||
try {
|
||||
String[] parameters = java.util.Arrays.copyOfRange(arg, 1, arg.length);
|
||||
String[] parameters2;
|
||||
// 用户相关性
|
||||
if (obj instanceof GmRoleAbstract) {
|
||||
List<Integer> sendIds = new LinkedList<>();
|
||||
|
@ -102,12 +103,12 @@ public class GmService implements RPCRequestGMIFace.Iface {
|
|||
}
|
||||
}
|
||||
int randomTime = sendIds.size();
|
||||
parameters2 = java.util.Arrays.copyOfRange(parameters, 1, parameters.length);
|
||||
String[] value = java.util.Arrays.copyOfRange(parameters, 1, parameters.length);
|
||||
|
||||
//两分钟内发完所有协议
|
||||
InnerMessageUtil.broadcastWithRandom( user->{
|
||||
((GmRoleAbstract) obj).setUser(user);
|
||||
obj.exec(parameters2);
|
||||
obj.exec(value);
|
||||
}, sendIds, Math.min(randomTime, 10));
|
||||
}
|
||||
// 用户无关性
|
||||
|
|
|
@ -16,24 +16,21 @@ import com.ljsd.jieling.logic.GlobleSystemLogic;
|
|||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
|
||||
import com.ljsd.jieling.logic.dao.FriendManager;
|
||||
import com.ljsd.jieling.logic.dao.GuilidManager;
|
||||
import com.ljsd.jieling.logic.dao.PlayerManager;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.gm.ArenaOfUser;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import rpc.protocols.ChatProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.CBean2Proto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.util.SensitivewordFilter;
|
||||
import com.ljsd.jieling.util.ShieldedWordUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import rpc.protocols.ChatProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -136,14 +133,14 @@ public class ChatLogic {
|
|||
String unSymbolWord = ShieldedWordUtils.replaceUnword(message);
|
||||
String tmp = SensitivewordFilter.replaceSensitiveWord(unSymbolWord, 1, "*");
|
||||
|
||||
|
||||
boolean silence = false;
|
||||
if(playerInfoManager.getSilence() == 1 || playerInfoManager.getSkyEyeBanTime()>System.currentTimeMillis()){
|
||||
if(playerInfoManager.getSilence() == 1 || playerInfoManager.getSkyEyeBanTime() > TimeUtils.now()){
|
||||
silence = true;
|
||||
}else{
|
||||
MessageUtil.sendSkyEyeMsg(message,user,friendId,chatType);
|
||||
}
|
||||
if(tmp.contains("*") && !tmp.equals(message)||silence){
|
||||
boolean bol = tmp.contains("*") && !tmp.equals(message) || silence;
|
||||
if(bol){
|
||||
char[] chars = message.toCharArray();
|
||||
char[] original = unSymbolWord.toCharArray();
|
||||
char[] tmpChar = tmp.toCharArray();
|
||||
|
|
|
@ -176,6 +176,8 @@ public enum ErrorCode implements IErrorCode {
|
|||
CROSS_YXLD_OVER(145,"赛季结算中"),
|
||||
RIDING_SWARD_BET_TWO(146,"一轮比赛最多押注两次!"),
|
||||
PRACTICE_LEVE_DOWN(147,"修行等级不足"),
|
||||
|
||||
GUILD_NOT_AUTHORITY(300,"账号因错误发言导致相关功能封禁中,操作失败"),
|
||||
;
|
||||
private static final Set<Integer> CodeSet = new HashSet<>();
|
||||
|
||||
|
|
|
@ -366,4 +366,5 @@ public interface BIReason {
|
|||
|
||||
int LEVEL_UP_REWARD = 1220;// 玩家升级赠与的道具
|
||||
int PRACTICE_SKILL_UP_COST=1221;//修行技能升级消耗
|
||||
int WEEK_CARD_REWARD =1222;//周卡奖励
|
||||
}
|
|
@ -35,6 +35,7 @@ public interface GlobalItemType {
|
|||
// 万能狗粮
|
||||
int AllPowerful_DogFood = 25;
|
||||
int LikableCostItem=27;//好感度功能消耗道具
|
||||
int MOUNT_FRAGMENTS_ITEM = 28;//坐骑碎片
|
||||
//物品使用类型
|
||||
int NO_USE = 0 ; //不使用
|
||||
int RANDOM_USE = 1; // 随机使用
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
package com.ljsd.jieling.handler.activity;
|
||||
|
||||
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.WeekCardInfo;
|
||||
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.SWeekcardConfig;
|
||||
import config.SWeekcardRotationConfig;
|
||||
import manager.STableManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.ActivityProto;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 周卡领奖
|
||||
*/
|
||||
|
||||
@Component
|
||||
public class WeekCardHandler extends BaseHandler<ActivityProto.WeekCardRewardRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.WeekCardRewardRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession session, ActivityProto.WeekCardRewardRequest proto) throws Exception{
|
||||
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
int weekId = proto.getId();
|
||||
Map<Integer, WeekCardInfo> weekCard = user.getPlayerInfoManager().getWeekCard();
|
||||
ActivityProto.WeekCardRewardResponse.Builder res = ActivityProto.WeekCardRewardResponse.newBuilder();
|
||||
if(!weekCard.containsKey(weekId)){
|
||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.WeekCardRewardResponse.getNumber(), res.build(), true);
|
||||
return;
|
||||
}
|
||||
WeekCardInfo singleWeekCard = weekCard.get(weekId);
|
||||
//没买或者过期
|
||||
if(!singleWeekCard.isBuy()&&!TimeUtils.isSameWeek7(singleWeekCard.getBugTime())){
|
||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.WeekCardRewardResponse.getNumber(), res.build(), true);
|
||||
return;
|
||||
}
|
||||
Map<Integer, SWeekcardConfig> config = STableManager.getConfig(SWeekcardConfig.class);
|
||||
if(!config.containsKey(weekId)){
|
||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.WeekCardRewardResponse.getNumber(), res.build(), true);
|
||||
return;
|
||||
}
|
||||
Map<Integer,Integer>dropMap = new HashMap<>();
|
||||
for(int i=TimeUtils.getDayOfWeek()-singleWeekCard.getLeaveGetRewardDays();i>0;i--){
|
||||
int [][]drop =config.get(weekId).getBaseReward();
|
||||
for(int[] single:drop){
|
||||
if(dropMap.containsKey(single[0])){
|
||||
dropMap.put(single[0],dropMap.get(single[0])+single[1]);
|
||||
}else{
|
||||
dropMap.put(single[0],single[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
int [][] dropArray= dropMap.entrySet().stream().map(n->new int[]{n.getKey(),n.getValue()}).toArray(int[][]::new);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.dropPer(user, dropArray, BIReason.WEEK_CARD_REWARD);
|
||||
res.setDrop(drop);
|
||||
singleWeekCard.setLeaveGetRewardDays(TimeUtils.getDayOfWeek());
|
||||
user.getPlayerInfoManager().setWeekCard(weekCard);
|
||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.WeekCardRewardResponse.getNumber(), res.build(), true);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package com.ljsd.jieling.handler.activity;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.activity.activityLogic.WeekCardLogic;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.WeekCardInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SMServerArenaSetting;
|
||||
import config.SWeekcardConfig;
|
||||
import config.SWeekcardRotationConfig;
|
||||
import manager.STableManager;
|
||||
import rpc.protocols.ActivityProto;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WeekCardInfoHandler extends BaseHandler<ActivityProto.WeekCardInfoRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.WeekCardInfoRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可购买的周卡列表
|
||||
* @param session
|
||||
* @param proto
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void processWithProto(ISession session, ActivityProto.WeekCardInfoRequest proto) throws Exception{
|
||||
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
int[] weekType = WeekCardLogic.getInstance().getWeekCardType(user);
|
||||
if(weekType == null){
|
||||
return;
|
||||
}
|
||||
ActivityProto.WeekCardInfoResponse.Builder res = ActivityProto.WeekCardInfoResponse.newBuilder();
|
||||
List<CommonProto.WeekCard> weekCardList = WeekCardLogic.getInstance().initAllWeekCardInfo(user);
|
||||
/*long time= user.getPlayerInfoManager().getWeekCardTimeFirst();
|
||||
if(!TimeUtils.isSameWeek(time ,TimeUtils.now())){
|
||||
user.getPlayerInfoManager().setWeekCardTimeFirstLevel(user.getPlayerInfoManager().getLevel());
|
||||
user.getPlayerInfoManager().setWeekCardTimeFirst(TimeUtils.now());
|
||||
}
|
||||
int [] weekCardType = WeekCardLogic.getInstance().getWeekCardType(user);
|
||||
Map<Integer, WeekCardInfo> weekCard = user.getPlayerInfoManager().getWeekCard();
|
||||
Map<Integer,SWeekcardRotationConfig> config = STableManager.getConfig(SWeekcardRotationConfig.class);
|
||||
boolean isSaveToDb =false;
|
||||
for(int i= 0;i<weekCardType.length;i++){
|
||||
if(config.containsKey(weekCardType[i])){
|
||||
CommonProto.WeekCard.Builder weekCardProto = CommonProto.WeekCard.newBuilder();
|
||||
//周卡是否存在 判断是否过期
|
||||
if(!weekCard.containsKey(weekCardType[i])){
|
||||
weekCard.put(weekCardType[i],new WeekCardInfo(weekCardType[i],false,0,0));
|
||||
isSaveToDb = true;
|
||||
}
|
||||
WeekCardInfo singleWeekCard = weekCard.get(weekCardType[i]);
|
||||
if(singleWeekCard.isBuy()){
|
||||
//买过周卡
|
||||
if(!TimeUtils.isSameWeek(singleWeekCard.getBugTime() ,TimeUtils.now())){
|
||||
//周卡已经过期
|
||||
singleWeekCard.setBuy(false);
|
||||
singleWeekCard.setLeaveGetRewardDays(0);
|
||||
isSaveToDb = true;
|
||||
}
|
||||
}
|
||||
weekCardProto.setId(singleWeekCard.getId());
|
||||
weekCardProto.setIsBuy(singleWeekCard.isBuy());
|
||||
if(singleWeekCard.isBuy()){
|
||||
weekCardProto.setLeaveGetRewardDays(TimeUtils.getDayOfWeek()-singleWeekCard.getLeaveGetRewardDays());
|
||||
}else{
|
||||
weekCardProto.setLeaveGetRewardDays(singleWeekCard.getLeaveGetRewardDays());
|
||||
}
|
||||
|
||||
res.addAllWeekCardInfo(weekCardProto);
|
||||
}
|
||||
}
|
||||
if(isSaveToDb){
|
||||
user.getPlayerInfoManager().setWeekCard(weekCard);
|
||||
}*/
|
||||
res.addAllAllWeekCardInfo(weekCardList);
|
||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.WeekCardInfoResponse.getNumber(), res.build(), true);
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package com.ljsd.jieling.handler.hero;
|
||||
|
||||
import com.google.protobuf.GeneratedMessage;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
|
@ -12,21 +11,15 @@ import com.ljsd.jieling.logic.dao.root.User;
|
|||
import com.ljsd.jieling.logic.hardStage.HardStageLogic;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.CBean2Proto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SPlayerSkill;
|
||||
import config.SXiuXian;
|
||||
import config.SXiuXianSkill;
|
||||
import manager.STableManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.HeroInfoProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author hj
|
||||
* @Description 修行玩法,升级
|
||||
|
|
|
@ -1,17 +1,64 @@
|
|||
package com.ljsd.jieling.kefu;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.GuilidManager;
|
||||
import com.ljsd.jieling.logic.dao.PlayerManager;
|
||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import config.SGuildSetting;
|
||||
import util.TimeUtils;
|
||||
|
||||
public class Cmd_skyeye extends GmRoleAbstract {
|
||||
|
||||
/**
|
||||
* 天眼禁言封禁
|
||||
*/
|
||||
public static final int SKYEYE_BAN = 7;
|
||||
/**
|
||||
* 天眼禁言解禁
|
||||
*/
|
||||
public static final int CANCEL_SKYEYE_BAN = 8;
|
||||
|
||||
/**
|
||||
* 重置公会名称
|
||||
*/
|
||||
public static final int RESET_GUILD_NAME = 9;
|
||||
/**
|
||||
* 重置公会公告
|
||||
*/
|
||||
public static final int RESET_GUILD_ANNOUNCEMENT = 10;
|
||||
|
||||
@Override
|
||||
public boolean exec(String[] args) throws Exception {
|
||||
User user = getUser();
|
||||
int min = Integer.valueOf(args[0]);
|
||||
PlayerManager playerInfoManager = user.getPlayerInfoManager();
|
||||
//设置禁言
|
||||
playerInfoManager.setSkyEyeBanTime(System.currentTimeMillis()+ min * TimeUtils.ONE_MINUTE);
|
||||
PlayerManager playerManager = user.getPlayerInfoManager();
|
||||
|
||||
// 默认封禁
|
||||
int time = Integer.valueOf(args[1]);
|
||||
playerManager.setSkyEyeBanTime(System.currentTimeMillis() + time * TimeUtils.ONE_MINUTE);
|
||||
|
||||
int type = Integer.parseInt(args[0]);
|
||||
// 获取公会信息
|
||||
GuildInfo guildInfo = null;
|
||||
if (type == RESET_GUILD_NAME || type == RESET_GUILD_ANNOUNCEMENT){
|
||||
guildInfo = GuilidManager.guildInfoMap.get(Integer.parseInt(args[2]));
|
||||
}
|
||||
if (guildInfo == null){
|
||||
LOGGER.error("天眼,修改公会名称报错,找不到公会:{}",args[1]);
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (type){
|
||||
case RESET_GUILD_NAME:
|
||||
//修改公会名称
|
||||
guildInfo.setName(playerManager.getNickName()+"的公会");
|
||||
break;
|
||||
case RESET_GUILD_ANNOUNCEMENT:
|
||||
//修改公会公告
|
||||
guildInfo.setAnnounce(SGuildSetting.sGuildSetting.getDefaultDeclaration());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.ljsd.jieling.logic.activity.ActivityLogic;
|
|||
import com.ljsd.jieling.logic.activity.FightMainEventHandler;
|
||||
import com.ljsd.jieling.logic.activity.RemoveEventHeroHandler;
|
||||
import com.ljsd.jieling.logic.activity.UserLevelEventHandler;
|
||||
import com.ljsd.jieling.logic.activity.activityLogic.WeekCardLogic;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.activity.event.SuperBoxEvent;
|
||||
import com.ljsd.jieling.logic.activity.eventhandler.ActivityStateChangeHandler;
|
||||
|
@ -406,6 +407,8 @@ public class GlobalDataManaager implements IManager {
|
|||
public static void checkNeedReFlush(ISession session,User user,PlayerInfoProto.FivePlayerUpdateIndication.Builder fBuilder) throws Exception {
|
||||
// 需要隔天刷新的字段统一在这里处理
|
||||
if (TimeUtils.isOverTime(0,user.getPlayerInfoManager().getLoginTime())) {
|
||||
//周卡每日刷新
|
||||
//WeekCardLogic.getInstance().sendWeekCardInitInfo(session);
|
||||
//活动刷新
|
||||
ActivityLogic.getInstance().flushEveryDay(user,fBuilder);
|
||||
PlayerLogic.getInstance().vipflushEveryDay(user,fBuilder);
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
package com.ljsd.jieling.logic.activity.activityLogic;
|
||||
|
||||
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.WeekCardInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SWeekcardRotationConfig;
|
||||
import manager.STableManager;
|
||||
import rpc.protocols.ActivityProto;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WeekCardLogic {
|
||||
|
||||
public WeekCardLogic() {
|
||||
}
|
||||
|
||||
public static class Instance {
|
||||
public final static WeekCardLogic instance = new WeekCardLogic();
|
||||
|
||||
}
|
||||
|
||||
public static WeekCardLogic getInstance() {
|
||||
return WeekCardLogic.Instance.instance;
|
||||
}
|
||||
|
||||
public void sendWeekCardInitInfo(ISession session)throws Exception{
|
||||
ActivityProto.WeekCardIndicationInfoResponse.Builder res = ActivityProto.WeekCardIndicationInfoResponse.newBuilder();
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
List<CommonProto.WeekCard> weekCardList = initAllWeekCardInfo(user);
|
||||
res.addAllAllWeekCardInfo(weekCardList);
|
||||
//MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.WeekCardIndicationInfoResponse, res.build(), true);
|
||||
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.WeekCardIndicationInfoResponse_VALUE,res.build(),true);
|
||||
|
||||
}
|
||||
|
||||
public List<CommonProto.WeekCard> initAllWeekCardInfo(User user) throws Exception{
|
||||
long time= user.getPlayerInfoManager().getWeekCardTimeFirst();
|
||||
if(!TimeUtils.isSameWeek7(time)){
|
||||
user.getPlayerInfoManager().setWeekCardTimeFirstLevel(user.getPlayerInfoManager().getLevel());
|
||||
user.getPlayerInfoManager().setWeekCardTimeFirst(TimeUtils.now());
|
||||
}
|
||||
int [] weekCardType = getWeekCardType(user);
|
||||
Map<Integer, WeekCardInfo> weekCard = user.getPlayerInfoManager().getWeekCard();
|
||||
Map<Integer,SWeekcardRotationConfig> config = STableManager.getConfig(SWeekcardRotationConfig.class);
|
||||
boolean isSaveToDb =false;
|
||||
List<CommonProto.WeekCard> weekCardList=new ArrayList<>();
|
||||
for(int i= 1;i<weekCardType.length;i++){
|
||||
//if(config.containsKey(weekCardType[i])){
|
||||
CommonProto.WeekCard.Builder weekCardProto = CommonProto.WeekCard.newBuilder();
|
||||
//周卡是否存在 判断是否过期
|
||||
if(!weekCard.containsKey(weekCardType[i])){
|
||||
weekCard.put(weekCardType[i],new WeekCardInfo(weekCardType[i],false,0,0));
|
||||
isSaveToDb = true;
|
||||
}
|
||||
WeekCardInfo singleWeekCard = weekCard.get(weekCardType[i]);
|
||||
if(singleWeekCard.isBuy()){
|
||||
//买过周卡
|
||||
if(!TimeUtils.isSameWeek7(singleWeekCard.getBugTime())){
|
||||
//周卡已经过期
|
||||
singleWeekCard.setBuy(false);
|
||||
singleWeekCard.setLeaveGetRewardDays(0);
|
||||
isSaveToDb = true;
|
||||
}
|
||||
}
|
||||
weekCardProto.setId(singleWeekCard.getId());
|
||||
weekCardProto.setIsBuy(singleWeekCard.isBuy());
|
||||
weekCardProto.setLeaveGetRewardDays(TimeUtils.getDayOfWeek()-singleWeekCard.getLeaveGetRewardDays());
|
||||
weekCardList.add(weekCardProto.build());
|
||||
//}
|
||||
}
|
||||
if(isSaveToDb){
|
||||
user.getPlayerInfoManager().setWeekCard(weekCard);
|
||||
}
|
||||
return weekCardList;
|
||||
}
|
||||
|
||||
|
||||
public void buyWeekCard(User user,int weekCardType){
|
||||
Map<Integer, WeekCardInfo> weekCard = user.getPlayerInfoManager().getWeekCard();
|
||||
if(!weekCard.containsKey(weekCardType)){
|
||||
return;
|
||||
}
|
||||
WeekCardInfo singleWeekCard = weekCard.get(weekCardType);
|
||||
singleWeekCard.setBuy(true);
|
||||
singleWeekCard.setBugTime(TimeUtils.now());
|
||||
singleWeekCard.setLeaveGetRewardDays(0);
|
||||
user.getPlayerInfoManager().setWeekCard(weekCard);
|
||||
}
|
||||
|
||||
public int[] getWeekCardType(User user) throws Exception{
|
||||
Map<Integer,SWeekcardRotationConfig> config = STableManager.getConfig(SWeekcardRotationConfig.class);
|
||||
for(SWeekcardRotationConfig con:config.values()){
|
||||
if( TimeUtils.now()>=TimeUtils.parseTimeToMiles(con.getStartTime(),TimeUtils.Stand_CeHua_Data_format)
|
||||
&& TimeUtils.now()<=TimeUtils.parseTimeToMiles(con.getEndtime(),TimeUtils.Stand_CeHua_Data_format)){
|
||||
int [][]cardType = con.getWeekcardType();
|
||||
int level= user.getPlayerInfoManager().getWeekCardTimeFirstLevel();
|
||||
if(level == 0){
|
||||
level = user.getPlayerInfoManager().getLevel();
|
||||
}
|
||||
if(level>=cardType[0][0]&&level<=cardType[1][0]){
|
||||
return cardType[0];
|
||||
}else {
|
||||
return cardType[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -191,6 +191,11 @@ public class PlayerManager extends MongoBase {
|
|||
// 御剑行游玩次数
|
||||
private int ridingSwardNum;
|
||||
|
||||
//周卡
|
||||
private Map<Integer,WeekCardInfo> weekCard = new HashMap<>();
|
||||
private long weekCardTimeFirst;//本周第一次看到周卡的时间
|
||||
private int weekCardTimeFirstLevel;//本周第一次看到周卡时人物等级
|
||||
|
||||
public PlayerManager(){
|
||||
this.setRootCollection(User._COLLECTION_NAME);
|
||||
}
|
||||
|
@ -1302,4 +1307,32 @@ public class PlayerManager extends MongoBase {
|
|||
this.versionCode = versionCode;
|
||||
updateString("versionCode",versionCode);
|
||||
}
|
||||
|
||||
public Map<Integer, WeekCardInfo> getWeekCard() {
|
||||
return weekCard;
|
||||
}
|
||||
|
||||
public void setWeekCard(Map<Integer, WeekCardInfo> weekCard) {
|
||||
this.weekCard = weekCard;
|
||||
updateString("weekCard",weekCard);
|
||||
}
|
||||
|
||||
|
||||
public long getWeekCardTimeFirst() {
|
||||
return weekCardTimeFirst;
|
||||
}
|
||||
|
||||
public void setWeekCardTimeFirst(long weekCardTimeFirst) {
|
||||
this.weekCardTimeFirst = weekCardTimeFirst;
|
||||
updateString("weekCardTimeFirst",weekCardTimeFirst);
|
||||
}
|
||||
|
||||
public int getWeekCardTimeFirstLevel() {
|
||||
return weekCardTimeFirstLevel;
|
||||
}
|
||||
|
||||
public void setWeekCardTimeFirstLevel(int weekCardTimeFirstLevel) {
|
||||
this.weekCardTimeFirstLevel = weekCardTimeFirstLevel;
|
||||
updateString("weekCardTimeFirstLevel",weekCardTimeFirstLevel);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,7 +207,6 @@ public class UserManager {
|
|||
}
|
||||
|
||||
public static User getUserNotCache(int uid) {
|
||||
// User user = userMap.get(uid);
|
||||
try {
|
||||
User user = userMap.get(uid);
|
||||
if (user != null) {
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
public class WeekCardInfo {
|
||||
|
||||
private int id; //周卡id
|
||||
private boolean isBuy; //是否购买
|
||||
private int leaveGetRewardDays; //领取了几天的奖励
|
||||
private long bugTime; //购买周卡的时间
|
||||
|
||||
|
||||
public WeekCardInfo(int id, boolean isBuy, int leaveGetRewardDays, long bugTime) {
|
||||
this.id = id;
|
||||
this.isBuy = isBuy;
|
||||
this.leaveGetRewardDays = leaveGetRewardDays;
|
||||
this.bugTime = bugTime;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public boolean isBuy() {
|
||||
return isBuy;
|
||||
}
|
||||
|
||||
public void setBuy(boolean buy) {
|
||||
isBuy = buy;
|
||||
}
|
||||
|
||||
public int getLeaveGetRewardDays() {
|
||||
return leaveGetRewardDays;
|
||||
}
|
||||
|
||||
public void setLeaveGetRewardDays(int leaveGetRewardDays) {
|
||||
this.leaveGetRewardDays = leaveGetRewardDays;
|
||||
}
|
||||
|
||||
public long getBugTime() {
|
||||
return bugTime;
|
||||
}
|
||||
|
||||
public void setBugTime(long bugTime) {
|
||||
this.bugTime = bugTime;
|
||||
}
|
||||
}
|
|
@ -14,7 +14,10 @@ import com.ljsd.jieling.globals.Global;
|
|||
import com.ljsd.jieling.ktbeans.ReportEventEnum;
|
||||
import com.ljsd.jieling.ktbeans.ReportUtil;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.activity.event.*;
|
||||
import com.ljsd.jieling.logic.activity.event.CommitSheJiEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.GuildForceChangeEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.activity.event.UserMainTeamForceEvent;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.*;
|
||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||
|
@ -28,15 +31,15 @@ import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType;
|
|||
import com.ljsd.jieling.logic.store.StoreLogic;
|
||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.Family;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.*;
|
||||
import config.*;
|
||||
import manager.STableManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.Family;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
|
||||
|
@ -161,7 +164,7 @@ public class GuildLogic {
|
|||
* @param announce
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void createFamily(ISession session,String familyName,String announce) throws Exception {
|
||||
public static void createFamily(ISession session,String familyName,String announce) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
int msgId = MessageTypeProto.MessageType.FAMILY_CREATE_RESPONSE_VALUE;
|
||||
|
@ -173,13 +176,21 @@ public class GuildLogic {
|
|||
if(user.getPlayerInfoManager().getGuildId()!=0){
|
||||
throw new ErrorCodeException(ErrorCode.FAMILY_IN);
|
||||
}
|
||||
if (user.getPlayerInfoManager().getSkyEyeBanTime() > TimeUtils.now()){
|
||||
throw new ErrorCodeException(ErrorCode.GUILD_NOT_AUTHORITY);
|
||||
}
|
||||
if(StringUtil.isEmpty(announce)){
|
||||
announce= SGuildSetting.sGuildSetting.getDefaultDeclaration();
|
||||
}
|
||||
if(announce.length()==0||announce.length()>32){
|
||||
throw new ErrorCodeException(ErrorCode.ANNOUNCE_SIZE);
|
||||
}
|
||||
// 创建公会
|
||||
GuildInfo guildInfo = new GuildInfo(user.getId(),familyName,announce);
|
||||
// 天眼查询
|
||||
MessageUtil.sendSkyEyeMsgByGuild(familyName,user,MessageUtil.skyeye_guildName,guildInfo.getId());
|
||||
MessageUtil.sendSkyEyeMsgByGuild(announce,user,MessageUtil.skyeye_guildAnnounce,guildInfo.getId());
|
||||
|
||||
GuilidManager.addGuildInfo(guildInfo);
|
||||
user.getPlayerInfoManager().setGuildId(guildInfo.getId());
|
||||
addGuildLog(guildInfo.getId(),GuildDef.Log.CREATE,user.getPlayerInfoManager().getNickName());
|
||||
|
@ -815,11 +826,16 @@ public class GuildLogic {
|
|||
if(resultCode==0){
|
||||
throw new ErrorCodeException(ErrorCode.FAMILY_IN_SENSITIVE);
|
||||
}else{
|
||||
if (user.getPlayerInfoManager().getSkyEyeBanTime() > TimeUtils.now()){
|
||||
throw new ErrorCodeException(ErrorCode.GUILD_NOT_AUTHORITY);
|
||||
}
|
||||
if(type==1){
|
||||
if(content.length() > 32){
|
||||
throw new ErrorCodeException(ErrorCode.ANNOUNCE_SIZE);
|
||||
}
|
||||
guildInfo.setAnnounce(content);
|
||||
// 天眼查询
|
||||
MessageUtil.sendSkyEyeMsgByGuild(content,user,MessageUtil.skyeye_guildAnnounce,guildInfo.getId());
|
||||
}else{
|
||||
checkForCreateGuild(user, content, guildInfo.getAnnounce());
|
||||
int[][] renameCost = SGuildSetting.sGuildSetting.getRenameCost();
|
||||
|
@ -828,6 +844,8 @@ public class GuildLogic {
|
|||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
guildInfo.setName(content);
|
||||
// 天眼查询
|
||||
MessageUtil.sendSkyEyeMsgByGuild(content,user,MessageUtil.skyeye_guildName,guildInfo.getId());
|
||||
// 缓存同步
|
||||
CrossDeathPathLogic.setCrossGuild(guildInfo);
|
||||
}
|
||||
|
|
|
@ -135,8 +135,8 @@ public class FriendLogic {
|
|||
if (!checkIsAllowRecommandFriend(friendManager, recommandId,recommondIds)){
|
||||
continue;
|
||||
}
|
||||
User recommandIdUser = UserManager.getUserInMem(recommandId);
|
||||
if(recommandFriends== null||recommandIdUser==null){
|
||||
User recommandIdUser = UserManager.getUserNotCache(recommandId);
|
||||
if(recommandIdUser == null){
|
||||
continue;
|
||||
}
|
||||
if(recommandIdUser.getFriendManager().getBlackFriends().contains(uid)){
|
||||
|
@ -258,7 +258,7 @@ public class FriendLogic {
|
|||
if (friends.contains(inviteUid)){
|
||||
continue;
|
||||
}
|
||||
User inviteUser = UserManager.getUser(inviteUid);
|
||||
User inviteUser = UserManager.getUserNotCache(inviteUid);
|
||||
if (inviteUser == null){
|
||||
continue;
|
||||
}
|
||||
|
@ -295,11 +295,14 @@ public class FriendLogic {
|
|||
* 在线好友申请推送
|
||||
* @param inviteUid
|
||||
*/
|
||||
private void sendFriendInfoIndication(int uid,int inviteUid,int type) throws Exception {
|
||||
private void sendFriendInfoIndication(int uid,int inviteUid,int type){
|
||||
boolean isOnline = OnlineUserManager.checkUidOnline(inviteUid);
|
||||
if (isOnline) {
|
||||
ISession session = OnlineUserManager.getSessionByUid(inviteUid);
|
||||
User user = UserManager.getUser(inviteUid);
|
||||
User user = UserManager.getUserNotCache(inviteUid);
|
||||
if (user == null){
|
||||
return;
|
||||
}
|
||||
PlayerInfoProto.sendFriendInfoIndication.Builder sendFriendInfoIndication = PlayerInfoProto.sendFriendInfoIndication.newBuilder();
|
||||
sendFriendInfoIndication.setType(type);
|
||||
sendFriendInfoIndication.setFriends(CBean2Proto.getFriendInfo(uid, user.getFriendManager()));
|
||||
|
@ -329,12 +332,11 @@ public class FriendLogic {
|
|||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
FriendManager friendManager = user.getFriendManager();
|
||||
User friendUser = null;
|
||||
FriendManager friendfriendManager = null;
|
||||
if(friendId!=0){
|
||||
friendUser = UserManager.getUser(friendId);
|
||||
friendfriendManager = friendUser.getFriendManager();
|
||||
User friendUser = UserManager.getUserNotCache(friendId);
|
||||
if (friendId == 0 || friendUser == null){
|
||||
return;
|
||||
}
|
||||
FriendManager friendManager1 = friendUser.getFriendManager();
|
||||
List<Integer> friends = friendManager.getFriends();
|
||||
List<Integer> applyFriends = friendManager.getApplyFriends();
|
||||
int maxFriends = SSpecialConfig.getIntegerValue(SSpecialConfig.FRIENDAMOUNT_LIMIT);
|
||||
|
@ -349,28 +351,28 @@ public class FriendLogic {
|
|||
}
|
||||
if(friendManager.getBlackFriends().contains(friendId)){
|
||||
friendManager.delApplyFriend(friendId);
|
||||
friendfriendManager.delMyApplyFriend(uid);
|
||||
friendManager1.delMyApplyFriend(uid);
|
||||
throw new ErrorCodeException(ErrorCode.IN_BLACK);
|
||||
}
|
||||
friendFriendList = friendfriendManager.getFriends();
|
||||
friendFriendList = friendManager1.getFriends();
|
||||
if (friendFriendList.size() >=maxFriends){
|
||||
throw new ErrorCodeException(ErrorCode.FRIENDS_SIDE_MAX);
|
||||
}
|
||||
if(friendfriendManager.getBlackFriends().contains(uid)){
|
||||
if(friendManager1.getBlackFriends().contains(uid)){
|
||||
throw new ErrorCodeException(ErrorCode.FRIENDS_SIDE_BLACK);
|
||||
}
|
||||
if (applyFriends.contains(friendId)){
|
||||
friendManager.delApplyFriend(friendId);
|
||||
friendfriendManager.delMyApplyFriend(uid);
|
||||
friendManager1.delMyApplyFriend(uid);
|
||||
}
|
||||
if (friendfriendManager.getApplyFriends().contains(uid)||applyFriends.contains(friendId)){
|
||||
friendfriendManager.delApplyFriend(uid);
|
||||
if (friendManager1.getApplyFriends().contains(uid)||applyFriends.contains(friendId)){
|
||||
friendManager1.delApplyFriend(uid);
|
||||
friendManager.delMyApplyFriend(friendId);
|
||||
}
|
||||
friendManager.addFriendId(friendId);
|
||||
friendfriendManager.addFriendId(uid);
|
||||
friendManager1.addFriendId(uid);
|
||||
|
||||
initFriendGriveAndRreward(friendId, uid, friendManager, friendfriendManager);
|
||||
initFriendGriveAndRreward(friendId, uid, friendManager, friendManager1);
|
||||
sendFriendInfoIndication(uid,friendId,2);
|
||||
user.getUserMissionManager().onGameEvent(user,GameEvent.FRIEND_NUMS,1);
|
||||
updateFriendUserInfo(friendUser);
|
||||
|
@ -379,7 +381,7 @@ public class FriendLogic {
|
|||
applyFriends = friendManager.getApplyFriends();
|
||||
if (applyFriends.contains(friendId)){
|
||||
friendManager.delApplyFriend(friendId);
|
||||
friendfriendManager.delMyApplyFriend(uid);
|
||||
friendManager1.delMyApplyFriend(uid);
|
||||
}
|
||||
break;
|
||||
case 3://全部同意
|
||||
|
@ -406,38 +408,36 @@ public class FriendLogic {
|
|||
}
|
||||
|
||||
private int allApplyFriend(int uid, FriendManager friendManager, List<Integer> friends, List<Integer> applyFriends, int maxFriends) throws Exception {
|
||||
User friendUser;
|
||||
FriendManager friendfriendManager;
|
||||
List<Integer> friendFriendList;
|
||||
List<Integer> alreadyFriendList = new ArrayList<>();
|
||||
int nums =0;
|
||||
for (Integer applyfriendId :applyFriends){
|
||||
friendUser = UserManager.getUser(applyfriendId);
|
||||
friendfriendManager = friendUser.getFriendManager();
|
||||
friendFriendList = friendfriendManager.getFriends();
|
||||
if (friends.contains(applyfriendId)){
|
||||
for (Integer applyFriendId :applyFriends){
|
||||
User friendUser = UserManager.getUserNotCache(applyFriendId);
|
||||
if (friendUser == null){
|
||||
continue;
|
||||
}
|
||||
if(friendManager.getBlackFriends().contains(applyfriendId)){
|
||||
FriendManager friendManager1 = friendUser.getFriendManager();
|
||||
List<Integer> friendFriendList = friendManager1.getFriends();
|
||||
if (friends.contains(applyFriendId)){
|
||||
continue;
|
||||
}
|
||||
if(friendManager.getBlackFriends().contains(applyFriendId)){
|
||||
continue;
|
||||
}
|
||||
if (friends.size()+1> maxFriends){
|
||||
// throw new ErrorCodeException(ErrorCode.FRIENDS_MAX);
|
||||
continue;
|
||||
}
|
||||
if (friendFriendList.size()>= maxFriends){
|
||||
continue;
|
||||
}
|
||||
alreadyFriendList.add(applyfriendId);
|
||||
// friendManager.delApplyFriend(applyfriendId);
|
||||
friendfriendManager.addFriendId(uid);
|
||||
friendManager.addFriendId(applyfriendId);
|
||||
UserManager.getUser(applyfriendId).getFriendManager().delMyApplyFriend(uid);
|
||||
initFriendGriveAndRreward(applyfriendId, uid, friendManager, friendfriendManager);
|
||||
sendFriendInfoIndication(uid,applyfriendId,2);
|
||||
alreadyFriendList.add(applyFriendId);
|
||||
friendManager1.addFriendId(uid);
|
||||
friendManager.addFriendId(applyFriendId);
|
||||
friendManager1.delMyApplyFriend(uid);
|
||||
initFriendGriveAndRreward(applyFriendId, uid, friendManager, friendManager1);
|
||||
sendFriendInfoIndication(uid,applyFriendId,2);
|
||||
updateFriendUserInfo(friendUser);
|
||||
nums++;
|
||||
ReportUtil.onReportEvent(UserManager.getUser(uid),ReportEventEnum.ALLOW_FRIENDS_ASK.getType(),String.valueOf(applyfriendId),friendUser.getPlayerInfoManager().getNickName(),friendUser.getPlayerInfoManager().getLevel());
|
||||
ReportUtil.onReportEvent(UserManager.getUser(uid),ReportEventEnum.ALLOW_FRIENDS_ASK.getType(),String.valueOf(applyFriendId),friendUser.getPlayerInfoManager().getNickName(),friendUser.getPlayerInfoManager().getLevel());
|
||||
}
|
||||
if(!alreadyFriendList.isEmpty()){
|
||||
for(Integer id:alreadyFriendList){
|
||||
|
@ -480,12 +480,13 @@ public class FriendLogic {
|
|||
if (!friends.contains(friendId)){
|
||||
throw new ErrorCodeException(ErrorCode.FRIENDS_ISNOT_FRIEND);
|
||||
}
|
||||
User friendUser = UserManager.getUser(friendId);
|
||||
User friendUser = UserManager.getUserNotCache(friendId);
|
||||
if (friendUser == null){
|
||||
throw new ErrorCodeException(ErrorCode.FRIENDS_ISNOT_FRIEND);
|
||||
}
|
||||
FriendManager friendManager1 = friendUser.getFriendManager();
|
||||
delFriendInfo(friendId, uid, friendManager, friendManager1);
|
||||
sendFriendStatedication(uid,friendId,1);
|
||||
// 删除助战
|
||||
// HelpHeroLogic.getInstance().delFriendClearHelp(user,friendUser);
|
||||
MessageUtil.sendMessage(iSession, 1, msgId, null, true);
|
||||
}
|
||||
|
||||
|
@ -506,10 +507,12 @@ public class FriendLogic {
|
|||
}
|
||||
List<Integer> friends = friendManager.getFriends();
|
||||
if (friends.contains(friendId)){
|
||||
User friendUser = UserManager.getUser(friendId);
|
||||
FriendManager friendManager1 = friendUser.getFriendManager();
|
||||
delFriendInfo(friendId, uid, friendManager, friendManager1);
|
||||
sendFriendStatedication(uid,friendId,1);
|
||||
User friendUser = UserManager.getUserNotCache(friendId);
|
||||
if (friendUser != null){
|
||||
FriendManager friendManager1 = friendUser.getFriendManager();
|
||||
delFriendInfo(friendId, uid, friendManager, friendManager1);
|
||||
sendFriendStatedication(uid,friendId,1);
|
||||
}
|
||||
}
|
||||
friendManager.addBlackFriendId(friendId);
|
||||
}else if(optType == 2){
|
||||
|
@ -543,47 +546,37 @@ public class FriendLogic {
|
|||
FriendManager friendManager = user.getFriendManager();
|
||||
List<Integer> friends = friendManager.getFriends();
|
||||
Map<Integer, Integer> giveMap = friendManager.getGiveMap();
|
||||
|
||||
// 获取全部未赠送得好友
|
||||
ArrayList<Integer> notGive = new ArrayList<>();
|
||||
for (Integer friend : friends) {
|
||||
if (giveMap.get(friend) == 1){
|
||||
continue;
|
||||
}
|
||||
notGive.add(friend);
|
||||
}
|
||||
// 住过致送一个人,则清空,值添加一个
|
||||
if (type == 1 && notGive.contains(friendId)){
|
||||
notGive.clear();
|
||||
notGive.add(friendId);
|
||||
}
|
||||
// 记录赠送次数
|
||||
int times = 0;
|
||||
if (type == 1) {//赠送一个人
|
||||
if (!friends.contains(friendId)) {
|
||||
throw new ErrorCodeException(ErrorCode.FRIENDS_ISNOT_FRIEND);
|
||||
}
|
||||
if (giveMap.get(friendId) == 1) {
|
||||
throw new ErrorCodeException(ErrorCode.FRIENDS_SEMD_YET);
|
||||
}
|
||||
User friendUser = UserManager.getUser(friendId);
|
||||
FriendManager friendManager1 = friendUser.getFriendManager();
|
||||
Map<Integer, Integer> haveRewardMap = friendUser.getFriendManager().getHaveRewardMap();
|
||||
if (haveRewardMap.containsKey(uid) && haveRewardMap.get(uid) != 0) {
|
||||
throw new ErrorCodeException(ErrorCode.FRIENDS_SEMD_YET);
|
||||
}
|
||||
friendManager.updateGiveMap(friendId,1);
|
||||
// boolean check = PlayerLogic.getInstance().checkAndUpdate(user,STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getMaxEnergyGet(), 1);
|
||||
// if(check){
|
||||
friendManager1.updateHaveRewardMap(uid,1);
|
||||
sendFriendStatedication(uid,friendId,2);
|
||||
// }
|
||||
times++;
|
||||
}else{ //赠送全部好友
|
||||
for (Integer friendUserId : friends) {
|
||||
if (giveMap.get(friendUserId) == 1) {
|
||||
continue;
|
||||
}
|
||||
User friendUser = UserManager.getUser(friendUserId);
|
||||
for (Integer friendUid : notGive) {
|
||||
User friendUser = UserManager.getUserNotCache(friendUid);
|
||||
if (friendUser != null){
|
||||
FriendManager friendManager1 = friendUser.getFriendManager();
|
||||
Map<Integer, Integer> haveRewardMap = friendManager1.getHaveRewardMap();
|
||||
if (haveRewardMap.containsKey(uid) && haveRewardMap.get(uid) != 0) {
|
||||
continue;
|
||||
throw new ErrorCodeException(ErrorCode.FRIENDS_SEMD_YET);
|
||||
}
|
||||
friendManager.updateGiveMap(friendUserId,1);
|
||||
// boolean check = PlayerLogic.getInstance().checkAndUpdate(user,STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getMaxEnergyGet(), 1);
|
||||
// if(check){
|
||||
friendManager.updateGiveMap(friendId,1);
|
||||
friendManager1.updateHaveRewardMap(uid,1);
|
||||
sendFriendStatedication(uid,friendUserId,2);
|
||||
// }
|
||||
sendFriendStatedication(uid,friendId,2);
|
||||
times++;
|
||||
}
|
||||
}
|
||||
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.GIVE_PRESENT,times);
|
||||
MessageUtil.sendMessage(iSession, 1, msgId, null, true);
|
||||
}
|
||||
|
@ -671,22 +664,21 @@ public class FriendLogic {
|
|||
PlayerManager playerInfoManager = user.getPlayerInfoManager();
|
||||
FriendManager friendManager = user.getFriendManager();
|
||||
List<Integer> friends = friendManager.getFriends();
|
||||
// boolean result = ShieldedWordUtils.checkName( name);
|
||||
// if (!result) {
|
||||
// MessageUtil.sendErrorResponse(iSession, 0, msgId, "名字不合法");
|
||||
// return;
|
||||
// }
|
||||
if (playerInfoManager.getNickName().equals(name)){
|
||||
throw new ErrorCodeException(ErrorCode.FRIENDS_SEARCH_SELF);
|
||||
}
|
||||
String key = RedisKey.getKey(RedisKey.C_User_Name_Key, name, false);
|
||||
Object friend = RedisUtil.getInstence().get(key);
|
||||
if (friend == null){
|
||||
Object friendIds = RedisUtil.getInstence().get(key);
|
||||
if (friendIds == null){
|
||||
throw new ErrorCodeException(ErrorCode.FRIENDS_USER_NULL);
|
||||
}
|
||||
int type = 1;
|
||||
int friendId = Integer.parseInt(friend.toString());
|
||||
List<Integer> applyFriends = UserManager.getUser(friendId).getFriendManager().getApplyFriends();
|
||||
int friendId = Integer.parseInt(friendIds.toString());
|
||||
User friend = UserManager.getUserNotCache(friendId);
|
||||
if (friend == null){
|
||||
throw new ErrorCodeException(ErrorCode.FRIENDS_USER_NULL);
|
||||
}
|
||||
List<Integer> applyFriends = friend.getFriendManager().getApplyFriends();
|
||||
if (friends.contains(friendId)){
|
||||
type = 2;
|
||||
}else if (applyFriends.contains(friendId)){
|
||||
|
@ -713,13 +705,7 @@ public class FriendLogic {
|
|||
friendManager.setHaveRewardMap(new HashMap<>());
|
||||
for (Map.Entry<Integer,Integer> entry: giveMap.entrySet()){
|
||||
Integer friendId = entry.getKey();
|
||||
User friendUser = null;
|
||||
try {
|
||||
friendUser = UserManager.getUser(friendId);
|
||||
}catch (Exception e){
|
||||
LOGGER.info("获取好友信息报错,friendId当前:{}",friendId);
|
||||
e.printStackTrace();
|
||||
}
|
||||
User friendUser = UserManager.getUserNotCache(friendId);
|
||||
if (friendUser == null){
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.ljsd.jieling.logic.activity.AbstractActivity;
|
|||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
import com.ljsd.jieling.logic.activity.ActivityType;
|
||||
import com.ljsd.jieling.logic.activity.ActivityTypeEnum;
|
||||
import com.ljsd.jieling.logic.activity.activityLogic.WeekCardLogic;
|
||||
import com.ljsd.jieling.logic.activity.event.*;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
@ -399,7 +400,11 @@ public class BuyGoodsNewLogic {
|
|||
if(type==GiftGoodsType.ENDLESS_TREASURE){
|
||||
user.getMapManager().setTreasureIsBuy(1);
|
||||
}
|
||||
|
||||
//周卡
|
||||
if(type==GiftGoodsType.WEEKCARD){
|
||||
WeekCardLogic.getInstance().buyWeekCard(user,config.getId());
|
||||
WeekCardLogic.getInstance().sendWeekCardInitInfo(session);
|
||||
}
|
||||
if(drop!=null&&session!=null){
|
||||
PlayerInfoProto.DirectBuyIndication build = PlayerInfoProto.DirectBuyIndication.newBuilder().setDrop(drop).build();
|
||||
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.DIRECT_BUY_GOODS_INDICATION_VALUE,build,true);
|
||||
|
|
|
@ -809,10 +809,10 @@ public class CBean2Proto {
|
|||
}
|
||||
|
||||
|
||||
public static CommonProto.Friend getFriendInfo(int friendId, FriendManager friendManager) throws Exception {
|
||||
public static CommonProto.Friend getFriendInfo(int friendId, FriendManager friendManager){
|
||||
User user = null;
|
||||
try {
|
||||
user = UserManager.getUser(friendId);
|
||||
user = UserManager.getUserNotCache(friendId);
|
||||
} catch (Exception e) {
|
||||
LOGGER.info("getFriendInfo user == null friendId={} e={}", friendId, e.toString());
|
||||
}
|
||||
|
|
|
@ -566,6 +566,7 @@ public class ItemUtil {
|
|||
case GlobalItemType.SELECTSecretBox:
|
||||
case GlobalItemType.SpecialMonsterItem:
|
||||
case GlobalItemType.AllPowerful_DogFood:
|
||||
case GlobalItemType.MOUNT_FRAGMENTS_ITEM:
|
||||
itemType = GlobalItemType.ITEM;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package com.ljsd.jieling.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.GeneratedMessage;
|
||||
import com.googlecode.protobuf.format.JsonFormat;
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.SkyEyeService;
|
||||
import com.ljsd.jieling.chat.messge.MessageCache;
|
||||
|
@ -24,7 +22,6 @@ import com.ljsd.jieling.netty.PackageConstant;
|
|||
import com.ljsd.jieling.netty.cocdex.Tea;
|
||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.sun.tools.javac.util.StringUtils;
|
||||
import config.SErrorCodeEerverConfig;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.PooledByteBufAllocator;
|
||||
|
@ -32,7 +29,6 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import rpc.protocols.*;
|
||||
import util.StringUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
@ -41,6 +37,12 @@ public class MessageUtil {
|
|||
private static final Logger LOGGER = LoggerFactory.getLogger(MessageUtil.class);
|
||||
private static HashMap<String, String> skyEyeExtraMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 天眼的类型,和gm上的对应
|
||||
*/
|
||||
public static int skyeye_guildName = 9;
|
||||
public static int skyeye_guildAnnounce = 10;
|
||||
|
||||
public static byte[] wrappedBuffer(int uid, int token, int index, int result, int msgId, GeneratedMessage generatedMessage) {
|
||||
byte[] backMessage;
|
||||
if (generatedMessage == null) {
|
||||
|
@ -459,56 +461,85 @@ public class MessageUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static void sendSkyEyeMsg(String msg,User me,int uid,int channel)throws Exception{
|
||||
if(channel == 2){
|
||||
channel = 4;
|
||||
}else if(channel == 3){
|
||||
channel = 8;
|
||||
}
|
||||
User he = null;
|
||||
if(uid != 0){
|
||||
he = UserManager.getUser(uid);
|
||||
}
|
||||
public static void sendSkyEyeMsg(String msg,User me,int uid,int channel){
|
||||
// 渠道特殊处理
|
||||
channel = channel == 2?4:channel;
|
||||
channel = channel == 3?8:channel;
|
||||
// 聊天的玩家
|
||||
User he = UserManager.getUserNotCache(uid);
|
||||
ChatProto.ChatV3.Builder v3 = buildChatV3(msg,me,channel);
|
||||
v3.setTo(buildChatUser(he));
|
||||
skyEyeSendMsg(v3.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑基础信息,天眼
|
||||
* @param msg
|
||||
* @param me
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
private static ChatProto.ChatV3.Builder buildChatV3(String msg,User me,int type){
|
||||
ChatProto.ChatV3.Builder v3 = ChatProto.ChatV3.newBuilder();
|
||||
String uuid = UUID.randomUUID().toString().replaceAll("-","");
|
||||
v3.setId(uuid);
|
||||
v3.setChannel(String.valueOf(type));
|
||||
v3.setFrom(buildChatUser(me));
|
||||
v3.setContent(msg);
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
String url = Optional.ofNullable(ConfigurableApplicationContextManager.getBean(SkyEyeAutoConfigration.class))
|
||||
.map(SkyEyeAutoConfigration::getSkyEyeProperties)
|
||||
.map(SkyEyeProperties::getGmAddress)
|
||||
.orElse("");
|
||||
object.put("url",url);
|
||||
v3.setExtra(object.toJSONString());
|
||||
|
||||
ISession iSession = OnlineUserManager.getSessionByUid(me.getId());
|
||||
String ip = Optional.ofNullable(iSession).map(v->v.getChannel().getLocalAddress().getHostString()).orElse("");
|
||||
v3.setIp(ip);
|
||||
return v3;
|
||||
}
|
||||
|
||||
/**
|
||||
* 天眼,公会
|
||||
* @param msg
|
||||
* @param user
|
||||
* @param channel
|
||||
* @param guildId
|
||||
*/
|
||||
public static void sendSkyEyeMsgByGuild(String msg,User user,int channel,int guildId){
|
||||
// 信息封装
|
||||
ChatProto.ChatV3.Builder v3 = buildChatV3(msg,user,channel);
|
||||
JSONObject jsonObject = JSONObject.parseObject(v3.getExtra());
|
||||
jsonObject.put("guildId",String.valueOf(guildId));
|
||||
v3.setExtra(jsonObject.toJSONString());
|
||||
// 发送消息
|
||||
skyEyeSendMsg(v3.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送天眼信息
|
||||
* @param chatV3
|
||||
*/
|
||||
private static void skyEyeSendMsg(ChatProto.ChatV3 chatV3){
|
||||
LOGGER.info("天眼上报,参数:【{}】",chatV3.toString());
|
||||
SkyEyeAutoConfigration netServerConfig = ConfigurableApplicationContextManager.getBean(SkyEyeAutoConfigration.class);
|
||||
SkyEyeProperties properties = netServerConfig.getSkyEyeProperties();
|
||||
if(properties == null){
|
||||
return;
|
||||
}
|
||||
ChatProto.ChatV3.Builder v3 = buildChatV3(msg,me,he,channel,properties);
|
||||
byte[] byteBuf = wrappedBufferSE(v3.build(),properties);
|
||||
// session.writeAndFlush(byteBuf);
|
||||
// session.putBackMassageToMap(byteBuf);
|
||||
byte[] byteBuf = wrappedBufferSE(chatV3,properties);
|
||||
ByteBuf bb = PooledByteBufAllocator.DEFAULT.heapBuffer();
|
||||
bb.writeBytes(byteBuf);
|
||||
SkyEyeService.sendMsg(bb);
|
||||
}
|
||||
|
||||
public static ChatProto.ChatV3.Builder buildChatV3(String msg,User me,User he,int type,SkyEyeProperties properties){
|
||||
ChatProto.ChatV3.Builder v3 = ChatProto.ChatV3.newBuilder();
|
||||
String uuid = UUID.randomUUID().toString().replaceAll("-","");
|
||||
v3.setId(uuid);
|
||||
v3.setChannel(type+"");
|
||||
v3.setFrom(buildChatUser(me));
|
||||
if(he != null){
|
||||
v3.setTo(buildChatUser(he));
|
||||
}
|
||||
v3.setContent(msg);
|
||||
ISession iSession = OnlineUserManager.getSessionByUid(me.getId());
|
||||
String ip = iSession.getChannel().getLocalAddress().getHostString();
|
||||
v3.setIp(ip);
|
||||
skyEyeExtraMap.clear();
|
||||
String url = properties.getGmAddress();
|
||||
if(url == null){
|
||||
private static ChatProto.ChatUserV3.Builder buildChatUser(User user){
|
||||
ChatProto.ChatUserV3.Builder v3 = ChatProto.ChatUserV3.newBuilder();
|
||||
if (user == null){
|
||||
return v3;
|
||||
}
|
||||
LOGGER.info("天眼封禁userId:{},zonId:{},content:{},URL:{}",me.getId(),String.valueOf(GameApplication.serverId),msg,url);
|
||||
skyEyeExtraMap.put("url",url);
|
||||
v3.setExtra(JSON.toJSONString(skyEyeExtraMap));
|
||||
return v3;
|
||||
}
|
||||
|
||||
public static ChatProto.ChatUserV3.Builder buildChatUser(User user){
|
||||
ChatProto.ChatUserV3.Builder v3 = ChatProto.ChatUserV3.newBuilder();
|
||||
v3.setPlayerId(String.valueOf(user.getId()));
|
||||
v3.setUserId(user.getPlayerInfoManager().getOpenId());
|
||||
v3.setNickname(user.getPlayerInfoManager().getNickName());
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="WeekcardConfig")
|
||||
public class SWeekcardConfig implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private String name;
|
||||
|
||||
private int price;
|
||||
|
||||
private int[][] baseReward;
|
||||
|
||||
private int contiueDays;
|
||||
|
||||
private int time;
|
||||
|
||||
private String startTime;
|
||||
|
||||
private String endtime;
|
||||
|
||||
public static Map<Integer,SWeekcardConfig> weekcardConfig;
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
weekcardConfig = STableManager.getConfig(SWeekcardConfig.class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public int[][] getBaseReward() {
|
||||
return baseReward;
|
||||
}
|
||||
|
||||
public int getContiueDays() {
|
||||
return contiueDays;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public String getEndtime() {
|
||||
return endtime;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="WeekcardRotationConfig")
|
||||
public class SWeekcardRotationConfig implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int[][] weekcardType;
|
||||
|
||||
private int time;
|
||||
|
||||
private String startTime;
|
||||
|
||||
private String endtime;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int[][] getWeekcardType() {
|
||||
return weekcardType;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public String getEndtime() {
|
||||
return endtime;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue