gm命令 异步事件分发 探宝活动
parent
5af0c05c6b
commit
f10ff47dc4
|
@ -20,10 +20,7 @@ import com.ljsd.jieling.protocols.MessageTypeProto;
|
|||
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.AyyncWorker;
|
||||
import com.ljsd.jieling.util.InnerMessageUtil;
|
||||
import com.ljsd.jieling.util.MathUtils;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.util.*;
|
||||
import org.apache.thrift.TException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -134,15 +131,14 @@ public class GmService implements RPCRequestGMIFace.Iface {
|
|||
}
|
||||
}
|
||||
|
||||
InnerMessageUtil.broadcastWithRandom(new AyyncWorker() {
|
||||
@Override
|
||||
public void work(User user) throws Exception {
|
||||
InnerMessageUtil.broadcastWithRandom( user->{
|
||||
((GmRoleAbstract) obj).setUser(user);
|
||||
obj.exec(parameters2);
|
||||
}
|
||||
}, sendIds, Math.min(randomTime, 120));
|
||||
} else {
|
||||
LOGGER.info("gm________________________start:"+cmd);
|
||||
obj.exec(parameters);
|
||||
LOGGER.info("gm________________________end:"+cmd);
|
||||
}
|
||||
|
||||
} catch (final Exception ex) {
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
package com.ljsd.jieling.config;
|
||||
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.Table;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Table(name = "DialRewardConfig")
|
||||
public class SDialRewardConfig implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int activityId;
|
||||
|
||||
private int poolId;
|
||||
|
||||
private int[] reward;
|
||||
|
||||
private int initializeWeight;
|
||||
|
||||
private int extractWeight;
|
||||
|
||||
private int limitNum;
|
||||
public static Map<Integer, SDialRewardConfig> sDialRewardConfigMap;
|
||||
public static Map<Integer, Map<Integer, Set<Integer>>> sRandPosMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
sDialRewardConfigMap = STableManager.getConfig(SDialRewardConfig.class);
|
||||
sDialRewardConfigMap.forEach((k, v) ->
|
||||
sRandPosMap.compute(v.getActivityId(), (activityId, oldv) -> {
|
||||
if (oldv == null) {
|
||||
Map<Integer, Set<Integer>> map = new HashMap<>();
|
||||
Set<Integer> set = new HashSet<>();
|
||||
set.add(v.getId());
|
||||
map.put(v.getPoolId(), set);
|
||||
return map;
|
||||
}
|
||||
oldv.computeIfPresent(v.getPoolId(), (pooid, setv) -> {
|
||||
setv.add(v.getId());
|
||||
return setv;
|
||||
});
|
||||
return oldv;
|
||||
})
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public static Map<Integer, SDialRewardConfig> getsDialRewardConfigMap() {
|
||||
return sDialRewardConfigMap;
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getActivityId() {
|
||||
return activityId;
|
||||
}
|
||||
|
||||
public int getPoolId() {
|
||||
return poolId;
|
||||
}
|
||||
|
||||
public int[] getReward() {
|
||||
return reward;
|
||||
}
|
||||
|
||||
public int getInitializeWeight() {
|
||||
return initializeWeight;
|
||||
}
|
||||
|
||||
public int getExtractWeight() {
|
||||
return extractWeight;
|
||||
}
|
||||
|
||||
public int getLimitNum() {
|
||||
return limitNum;
|
||||
}
|
||||
|
||||
public static Map<Integer, Map<Integer, Set<Integer>>> getsRandPosMap() {
|
||||
return sRandPosMap;
|
||||
}
|
||||
|
||||
public static void setsRandPosMap(Map<Integer, Map<Integer, Set<Integer>>> sRandPosMap) {
|
||||
SDialRewardConfig.sRandPosMap = sRandPosMap;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
package com.ljsd.jieling.config;
|
||||
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.Table;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="DialRewardSetting")
|
||||
public class SDialRewardSetting implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int activityType;
|
||||
|
||||
private int updateItem;
|
||||
|
||||
private int[][] cost;
|
||||
|
||||
private int[][] costItem;
|
||||
|
||||
private int[][] multipleCostItem;
|
||||
|
||||
private int integral;
|
||||
|
||||
|
||||
private static Map<Integer, SDialRewardSetting> sDialRewardSettingMap;
|
||||
private static Map<Integer, SDialRewardSetting> sDialRewardSettingMapByType = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
sDialRewardSettingMap = STableManager.getConfig(SDialRewardSetting.class);
|
||||
sDialRewardSettingMap.forEach((integer, sDialRewardSetting) ->
|
||||
sDialRewardSettingMapByType.put(sDialRewardSetting.getActivityType(), sDialRewardSetting)
|
||||
);
|
||||
|
||||
if (sDialRewardSettingMap.size() != sDialRewardSettingMapByType.size()) {
|
||||
throw new Exception("sDialRewardSetting acitivityType multiple");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static Map<Integer, SDialRewardSetting> getsDialRewardSettingMap() {
|
||||
return sDialRewardSettingMap;
|
||||
}
|
||||
|
||||
public static void setsDialRewardSettingMap(Map<Integer, SDialRewardSetting> sDialRewardSettingMap) {
|
||||
SDialRewardSetting.sDialRewardSettingMap = sDialRewardSettingMap;
|
||||
}
|
||||
|
||||
public static Map<Integer, SDialRewardSetting> getsDialRewardSettingMapByType() {
|
||||
return sDialRewardSettingMapByType;
|
||||
}
|
||||
|
||||
public static void setsDialRewardSettingMapByType(Map<Integer, SDialRewardSetting> sDialRewardSettingMapByType) {
|
||||
SDialRewardSetting.sDialRewardSettingMapByType = sDialRewardSettingMapByType;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getActivityType() {
|
||||
return activityType;
|
||||
}
|
||||
|
||||
public int getUpdateItem() {
|
||||
return updateItem;
|
||||
}
|
||||
|
||||
public int[][] getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
public int[][] getCostItem() {
|
||||
return costItem;
|
||||
}
|
||||
|
||||
public int[][] getMultipleCostItem() {
|
||||
return multipleCostItem;
|
||||
}
|
||||
|
||||
public int getIntegral() {
|
||||
return integral;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.ljsd.jieling.config;
|
|||
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.Table;
|
||||
import com.ljsd.jieling.util.StringUtil;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@ -17,6 +18,7 @@ public class SSpecialConfig implements BaseConfig {
|
|||
private String value;
|
||||
|
||||
public static final String PHONE_BINDING = "Phone_Binding";
|
||||
public static final String DIAL_PERSCORE = "DIAL_PERSCORE";//探宝转盘每转一次获得的积分
|
||||
public static final String MANDATORY_ASTROLOGICAL = "Mandatory_Astrological";//强制占星跳到第四颗星
|
||||
public static final String ARENA_RANKINGSHOWNUM = "Arena_RankingShowNum";//竞技场排行榜上榜显示排名
|
||||
public static final String TRIAL_RANKINGSHOWNUM = "Trial_RankingShowNum";//试炼副本排行榜上榜显示排名
|
||||
|
@ -28,6 +30,8 @@ public class SSpecialConfig implements BaseConfig {
|
|||
public static final String FRIENDAPPLYAMOUNT_LIMIT = "FriendApplyAmount_limit";//好友申请上限
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
|
@ -54,6 +58,11 @@ public class SSpecialConfig implements BaseConfig {
|
|||
return Integer.valueOf(value);
|
||||
}
|
||||
|
||||
public static int[] getIntegerArrayValue(String key) {
|
||||
String value = enumers.get(key);
|
||||
return StringUtil.parseFiledInt(value);
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
|
|
|
@ -84,6 +84,8 @@ public interface BIReason {
|
|||
|
||||
int DIRECT_BUY = 52; // 直购
|
||||
|
||||
int LUCK_WHEEl_REWARD = 53; //幸运转盘
|
||||
int LUCK_WHEEl_ADVANCE_REWARD = 54; //高级幸运转盘
|
||||
|
||||
//道具消耗原因 1000开头
|
||||
int ADVENTURE_UPLEVEL_CONSUME = 1000; //秘境升级
|
||||
|
@ -151,4 +153,8 @@ public interface BIReason {
|
|||
|
||||
int FAMILY_SET_ICON = 1037;//工会修改图腾
|
||||
|
||||
int LUCK_WHEEL = 1038; //幸运转盘消耗
|
||||
int LUCK_WHEEL_ADVANCE = 1039; //高级幸运转盘消耗
|
||||
|
||||
|
||||
}
|
|
@ -61,4 +61,6 @@ public interface Global {
|
|||
int DILIGENT = 2; //勤勉
|
||||
int LUCKCAT = 3; //招财猫
|
||||
int GMMSG = 4; //gm
|
||||
int LUCKWHEEL = 5; //幸运探宝
|
||||
int LUCKWHEEL_ADVANCE = 6; //高级探宝
|
||||
}
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
package com.ljsd.jieling.handler.activity;
|
||||
|
||||
import com.ljsd.jieling.config.SDialRewardConfig;
|
||||
import com.ljsd.jieling.config.SDialRewardSetting;
|
||||
import com.ljsd.jieling.config.SGlobalActivity;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.activity.AbstractActivity;
|
||||
import com.ljsd.jieling.logic.activity.ActivityTypeEnum;
|
||||
import com.ljsd.jieling.logic.activity.LuckWheelActivity;
|
||||
import com.ljsd.jieling.logic.dao.LuckWheelMission;
|
||||
import com.ljsd.jieling.logic.dao.LuckWheelPosInfo;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
|
||||
/**
|
||||
* Description: des
|
||||
* Author: zsx
|
||||
* CreateDate: 2019/9/25 20:31
|
||||
*/
|
||||
public class GetLuckWheelRandHandler extends BaseHandler<PlayerInfoProto.GetLuckWheelRandRewardRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.GET_LUCKWHEEL_RANDREWARD_REQUEST;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, PlayerInfoProto.GetLuckWheelRandRewardRequest proto) throws Exception {
|
||||
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
AbstractActivity abstractActivity = ActivityTypeEnum.getActicityType(proto.getActivityId());
|
||||
if (null == abstractActivity) {
|
||||
MessageUtil.sendErrorResponse(iSession, 0, MessageTypeProto.MessageType.GET_LUCKWHEEL_RANDREWARD_RESPONSE_VALUE, "活动未开启");
|
||||
return;
|
||||
}
|
||||
if (!(abstractActivity instanceof LuckWheelActivity)) {
|
||||
MessageUtil.sendErrorResponse(iSession, 0, MessageTypeProto.MessageType.GET_LUCKWHEEL_RANDREWARD_RESPONSE_VALUE, "activity err");
|
||||
return;
|
||||
}
|
||||
|
||||
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(proto.getActivityId());
|
||||
SDialRewardSetting sDialRewardSetting = SDialRewardSetting.getsDialRewardSettingMapByType().get(sGlobalActivity.getType());
|
||||
int reson = sGlobalActivity.getType() == 30 ? BIReason.LUCK_WHEEL : BIReason.LUCK_WHEEL_ADVANCE;
|
||||
|
||||
|
||||
//check cost
|
||||
LuckWheelMission luckWheelMission = user.getActivityManager().getLuckWheel(sGlobalActivity.getType());
|
||||
|
||||
int[][] costmap = proto.getRepeated() ? sDialRewardSetting.getCostItem() : sDialRewardSetting.getMultipleCostItem();
|
||||
int[][] realCost = LuckWheelActivity.getCost(luckWheelMission.getRefreshTime(), costmap);
|
||||
boolean enough = ItemUtil.itemCost(user, realCost, reson, 0);
|
||||
if (!enough) {
|
||||
MessageUtil.sendErrorResponse(iSession, 0, MessageTypeProto.MessageType.GET_LUCKWHEEL_RANDREWARD_RESPONSE_VALUE, "道具不足");
|
||||
return;
|
||||
}
|
||||
|
||||
//dodrop
|
||||
int time = costmap[1][3];
|
||||
int luckId = 0;
|
||||
int lastpos;
|
||||
|
||||
int[][] drops = new int[time][];
|
||||
for (int i = 0; i < time; i++) {
|
||||
luckId = ((LuckWheelActivity) abstractActivity).getNewRewardPool(user);
|
||||
SDialRewardConfig sDialRewardConfig = SDialRewardConfig.getsDialRewardConfigMap().get(luckId);
|
||||
drops[i] = sDialRewardConfig.getReward();
|
||||
//upprocess
|
||||
lastpos = sDialRewardConfig.getPoolId();
|
||||
LuckWheelPosInfo luckWheelPosInfo = luckWheelMission.getPosInfoMap().get(lastpos);
|
||||
luckWheelPosInfo.addProgrss();
|
||||
luckWheelMission.upPosInfo(lastpos, luckWheelPosInfo);
|
||||
}
|
||||
int dropReson = sGlobalActivity.getType() == 30 ? BIReason.LUCK_WHEEl_REWARD : BIReason.LUCK_WHEEl_ADVANCE_REWARD;
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, drops, dropReson);
|
||||
PlayerInfoProto.GetLuckWheelRandRewardResponse.Builder builder = PlayerInfoProto.GetLuckWheelRandRewardResponse.newBuilder();
|
||||
builder.setActivityId(proto.getActivityId());
|
||||
builder.setDrop(drop);
|
||||
builder.setPos(luckId);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package com.ljsd.jieling.handler.activity;
|
||||
|
||||
import com.ljsd.jieling.config.SDialRewardSetting;
|
||||
import com.ljsd.jieling.config.SGlobalActivity;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.activity.AbstractActivity;
|
||||
import com.ljsd.jieling.logic.activity.ActivityTypeEnum;
|
||||
import com.ljsd.jieling.logic.activity.LuckWheelActivity;
|
||||
import com.ljsd.jieling.logic.dao.LuckWheelMission;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
|
||||
/**
|
||||
* Description: 手动刷新幸运转盘奖励
|
||||
* Author: zsx
|
||||
* CreateDate: 2019/9/25 20:07
|
||||
*/
|
||||
public class RefreshLuckWheelRequestHandler extends BaseHandler<PlayerInfoProto.RefreshLuckWheelRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.REFRESH_LUCKWHEEL_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, PlayerInfoProto.RefreshLuckWheelRequest proto) throws Exception {
|
||||
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
AbstractActivity abstractActivity = ActivityTypeEnum.getActicityType(proto.getActivityId());
|
||||
if (null == abstractActivity) {
|
||||
MessageUtil.sendErrorResponse(iSession, 0, MessageTypeProto.MessageType.REFRESH_LUCKWHEEL_RESPONSE_VALUE, "活动未开启");
|
||||
return;
|
||||
}
|
||||
if (!(abstractActivity instanceof LuckWheelActivity)) {
|
||||
MessageUtil.sendErrorResponse(iSession, 0, MessageTypeProto.MessageType.REFRESH_LUCKWHEEL_RESPONSE_VALUE, "activity err");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//check cost
|
||||
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(proto.getActivityId());
|
||||
int reson = sGlobalActivity.getType()==30? BIReason.LUCK_WHEEL: BIReason.LUCK_WHEEL_ADVANCE;
|
||||
SDialRewardSetting sDialRewardSetting = SDialRewardSetting.getsDialRewardSettingMapByType().get(sGlobalActivity.getType());
|
||||
if(proto.getIsFree()){
|
||||
int[][] cost= new int[1][];
|
||||
cost[0] = new int[2];
|
||||
cost[0][0]= sDialRewardSetting.getUpdateItem();
|
||||
cost[0][1] = 1;
|
||||
boolean enough = ItemUtil.itemCost(user, cost, reson, 0);
|
||||
if(!enough){
|
||||
MessageUtil.sendErrorResponse(iSession,0,MessageTypeProto.MessageType.REFRESH_LUCKWHEEL_RESPONSE_VALUE,"次数不足");
|
||||
return;
|
||||
}
|
||||
}else {
|
||||
LuckWheelMission luckWheelMission = user.getActivityManager().getLuckWheel(sGlobalActivity.getType());
|
||||
int[][] cost = LuckWheelActivity.getCost(luckWheelMission.getRefreshTime(), sDialRewardSetting.getCost());
|
||||
boolean enough = ItemUtil.itemCost(user, cost, reson, 0);
|
||||
if(!enough){
|
||||
MessageUtil.sendErrorResponse(iSession,0,MessageTypeProto.MessageType.REFRESH_LUCKWHEEL_RESPONSE_VALUE,"道具不足");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//random
|
||||
((LuckWheelActivity) abstractActivity).randomReward(user);
|
||||
PlayerInfoProto.RefreshLuckWheelResponse.Builder builder = PlayerInfoProto.RefreshLuckWheelResponse.newBuilder();
|
||||
builder.addAllPosInfos(LuckWheelActivity.getLuckWheelReward(user,sGlobalActivity.getType()));
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.REFRESH_LUCKWHEEL_RESPONSE_VALUE, builder.build(), true);
|
||||
}
|
||||
}
|
|
@ -51,16 +51,6 @@ public class Cmd_changename extends GmRoleAbstract {
|
|||
RedisUtil.getInstence().zsetAddOne(key, String.valueOf(user.getId()), teamForce);
|
||||
}
|
||||
|
||||
if("userinfo".equals(args[2])){
|
||||
Gson gson = new Gson();
|
||||
PlayerManager playerManager = user.getPlayerInfoManager();
|
||||
|
||||
LOGGER.info("cmd_________userinfo:"+gson.toJson(playerManager));
|
||||
|
||||
|
||||
ActivityManager activityManager = user.getActivityManager();
|
||||
LOGGER.info("cmd_________userinfo_ac:"+gson.toJson(activityManager));
|
||||
}
|
||||
|
||||
if("reload".equals(args[2])){
|
||||
if (null != user) {
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.ljsd.jieling.kefu;
|
||||
|
||||
|
||||
/**
|
||||
* Description: 热修复全局信息 gm线程执行
|
||||
* Author: zsx
|
||||
* CreateDate: 2019/9/26 11:48
|
||||
*/
|
||||
public class Cmd_global_gm extends GmAbstract {
|
||||
@Override
|
||||
public boolean exec(String[] args) throws Exception {
|
||||
|
||||
// for (int i = 0; i <150 ; i++) {
|
||||
// String key = RedisKey.getKey(RedisKey.FORCE_RANK, "", false);
|
||||
// RedisUtil.getInstence().zsetAddOne(key, String.valueOf(10000+i), 10000+i);
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.ljsd.jieling.kefu;
|
||||
|
||||
/**
|
||||
* Description: 热修复玩家信息 分发到玩家线程
|
||||
* Author: zsx
|
||||
* CreateDate: 2019/9/26 11:48
|
||||
*/
|
||||
public class Cmd_role_gm extends GmRoleAbstract {
|
||||
@Override
|
||||
public boolean exec(String[] args) throws Exception {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.kefu;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.ljsd.jieling.logic.dao.ActivityManager;
|
||||
import com.ljsd.jieling.logic.dao.PlayerManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
||||
/**
|
||||
* Description: 输出玩家信息
|
||||
* Author: zsx
|
||||
* CreateDate: 2019/9/26 11:48
|
||||
*/
|
||||
public class Cmd_userinfo extends GmRoleAbstract {
|
||||
|
||||
@Override
|
||||
public boolean exec(String[] args) throws Exception {
|
||||
|
||||
User user = getUser();
|
||||
Gson gson = new Gson();
|
||||
PlayerManager playerManager = user.getPlayerInfoManager();
|
||||
LOGGER.info("cmd_________userinfo:"+gson.toJson(playerManager));
|
||||
ActivityManager activityManager = user.getActivityManager();
|
||||
LOGGER.info("cmd_________userinfo_ac:"+gson.toJson(activityManager));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ 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.InnerMessageUtil;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
|
@ -71,14 +72,14 @@ public abstract class AbstractActivity implements IActivity, IEventHandler {
|
|||
@Override
|
||||
public void update(User user, int count) {
|
||||
ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(id);
|
||||
updateProgress(user, activityMission, count);
|
||||
updateProgressWithUser(user, activityMission, count);
|
||||
//更新进度
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(user.getId());
|
||||
sendActivityProgress(sessionByUid, activityMission, null);
|
||||
|
||||
}
|
||||
|
||||
void updateProgress(User user, ActivityMission activityMission, int count) {
|
||||
void updateProgressWithUser(User user, ActivityMission activityMission, int count) {
|
||||
updateProgress(activityMission, count);
|
||||
}
|
||||
|
||||
|
@ -233,13 +234,22 @@ public abstract class AbstractActivity implements IActivity, IEventHandler {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绝对时间和相对开服结束回调
|
||||
*/
|
||||
@Override
|
||||
public void onActivityEnd() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 结束回调
|
||||
*/
|
||||
@Override
|
||||
public void onActivityEndOnMySelf(User user) throws Exception {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,10 +6,7 @@ import com.ljsd.jieling.core.VipPrivilegeType;
|
|||
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.activity.BlessInfoConfig;
|
||||
import com.ljsd.jieling.ktbeans.KtEventUtils;
|
||||
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
@ -18,13 +15,9 @@ import com.ljsd.jieling.logic.mission.event.MissionEventDistributor;
|
|||
import com.ljsd.jieling.logic.store.StoreLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MathUtils;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
import com.ljsd.jieling.util.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
|
@ -62,9 +55,22 @@ public class ActivityLogic {
|
|||
ActivityLogic.getInstance().resumeActivity(user, ActivityType.RECHARGE_SUM_DAY);
|
||||
user.getPlayerInfoManager().setRechargedaily(0);
|
||||
updateActivityMissionProgress(user, ActivityType.SevenLogin, 1);
|
||||
upFivePlayerActivity(user, ActivityType.SevenLogin, fBuilder);
|
||||
upFivePlayerActivity(user, ActivityType.RECHARGE_SUM_DAY, fBuilder);
|
||||
upFivePlayerActivity(user, ActivityType.DAILY_RECHARGE, fBuilder);
|
||||
|
||||
//幸运转盘活动刷新
|
||||
ActivityLogic.getInstance().resumeActivity(user, ActivityType.LUCK_WHEEL);
|
||||
ActivityLogic.getInstance().resumeActivity(user, ActivityType.LUCK_WHEEL_ADVANCE);
|
||||
|
||||
|
||||
Set<Integer> upFiveActivityTypes = new HashSet<>();
|
||||
upFiveActivityTypes.add(ActivityType.SevenLogin);
|
||||
upFiveActivityTypes.add(ActivityType.RECHARGE_SUM_DAY);
|
||||
upFiveActivityTypes.add(ActivityType.DAILY_RECHARGE);
|
||||
upFiveActivityTypes.add(ActivityType.LUCK_WHEEL);
|
||||
upFiveActivityTypes.add(ActivityType.LUCK_WHEEL_ADVANCE);
|
||||
upFivePlayerActivity(user, upFiveActivityTypes, fBuilder);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void flushForLogin(User user) throws Exception {
|
||||
|
@ -79,6 +85,8 @@ public class ActivityLogic {
|
|||
public void checkActiviyStatus() throws Exception {
|
||||
long now = System.currentTimeMillis();
|
||||
Map<Integer, SGlobalActivity> sGlobalActivityMap = SGlobalActivity.getsGlobalActivityMap();
|
||||
|
||||
//检查开启的活动 非相对创角时间
|
||||
for (SGlobalActivity sGlobalActivity : sGlobalActivityMap.values()) {
|
||||
int time = sGlobalActivity.getTime();
|
||||
ActivityTypeEnum.getActicityType(sGlobalActivity.getId());
|
||||
|
@ -110,28 +118,44 @@ public class ActivityLogic {
|
|||
openActivityIds.add(sGlobalActivity.getId());
|
||||
}
|
||||
|
||||
for (Map.Entry<Integer, ISession> entry : OnlineUserManager.sessionMap.entrySet()) {
|
||||
User user = UserManager.getUserInMem(entry.getKey());
|
||||
if(user==null){
|
||||
continue;
|
||||
//活动数据处理分发到角色线程
|
||||
InnerMessageUtil.broadcastWithRandom(user1 -> {
|
||||
if(user1==null){
|
||||
return;
|
||||
}
|
||||
ISession session = OnlineUserManager.sessionMap.get(user1.getId());
|
||||
if(null ==session){
|
||||
return;
|
||||
}
|
||||
PlayerInfoProto.ActivityUpateIndication.Builder builder = PlayerInfoProto.ActivityUpateIndication.newBuilder();
|
||||
MissionEventDistributor.requestStart();
|
||||
Set<Integer> openNews = checkActivityOfUser(user, builder);
|
||||
|
||||
Set<Integer> openNews = checkActivityOfUser(user1, builder);
|
||||
|
||||
//send new/close activity indication
|
||||
if (!openNews.isEmpty()) {
|
||||
Map<Integer, ActivityMission> activityMissionMap = user.getActivityManager().getActivityMissionMap();
|
||||
Map<Integer, ActivityMission> activityMissionMap = user1.getActivityManager().getActivityMissionMap();
|
||||
Map<Integer, ActivityMission> activityUpdateMap = new HashMap<>();
|
||||
boolean sendLuckWheelPool =false;
|
||||
for (Integer activityId : openNews) {
|
||||
if(ActivityType.LUCK_WHEEL == SGlobalActivity.getsGlobalActivityMap().get(activityId).getType()
|
||||
||ActivityType.LUCK_WHEEL_ADVANCE == SGlobalActivity.getsGlobalActivityMap().get(activityId).getType())
|
||||
sendLuckWheelPool=true;
|
||||
activityUpdateMap.put(activityId, activityMissionMap.get(activityId));
|
||||
}
|
||||
List<CommonProto.ActivityInfo> activityInfos = getActivityInfos(activityUpdateMap, user.getPlayerInfoManager().getCreateTime());
|
||||
List<CommonProto.ActivityInfo> activityInfos = getActivityInfos(activityUpdateMap, user1.getPlayerInfoManager().getCreateTime());
|
||||
builder.addAllActivityInfo(activityInfos);
|
||||
|
||||
if(sendLuckWheelPool){
|
||||
sendLuckWheelPool(user1,session);
|
||||
}
|
||||
}
|
||||
if (builder.getActivityInfoCount() > 0 || builder.getCloseActivityIdCount() > 0) {
|
||||
MessageUtil.sendIndicationMessage(entry.getValue(), 1, MessageTypeProto.MessageType.ACTIVITY_UPDATE_INDICATION_VALUE, builder.build(), true);
|
||||
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.ACTIVITY_UPDATE_INDICATION_VALUE, builder.build(), true);
|
||||
}
|
||||
MissionEventDistributor.requestEnd(entry.getValue(),true);
|
||||
}
|
||||
MissionEventDistributor.requestEnd(session,true);
|
||||
}, new LinkedList<>(OnlineUserManager.sessionMap.keySet()),5);
|
||||
|
||||
}
|
||||
|
||||
public void newPlayerOpenActivityMission(User user) throws Exception {
|
||||
|
@ -154,6 +178,8 @@ public class ActivityLogic {
|
|||
ActivityManager activityManager = user.getActivityManager();
|
||||
Map<Integer, SGlobalActivity> sGlobalActivityMap = SGlobalActivity.getsGlobalActivityMap();
|
||||
Set<Integer> openNewActivityIds = new HashSet<>();
|
||||
|
||||
//初始化活动 绝对时间和相对开服时间
|
||||
for (Integer openActivityId : openActivityIds) {
|
||||
SGlobalActivity sGlobalActivity = sGlobalActivityMap.get(openActivityId);
|
||||
|
||||
|
@ -241,6 +267,9 @@ public class ActivityLogic {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 不走通用活动进度奖励配置的活动单独初始化
|
||||
*/
|
||||
public boolean initOtherActivity(User user, SGlobalActivity sGlobalActivity) throws Exception {
|
||||
int type = sGlobalActivity.getType();
|
||||
switch (type) {
|
||||
|
@ -274,8 +303,20 @@ public class ActivityLogic {
|
|||
int rewardResponseValue = MessageTypeProto.MessageType.GET_ALL_ACTIVITY_RESPONSE_VALUE;
|
||||
checkActivityOfUser(user, null);
|
||||
List<CommonProto.ActivityInfo> activityInfoList = getActivityInfos(user.getActivityManager().getActivityMissionMap(), createTime);
|
||||
PlayerInfoProto.GetAllActivityResponse build = PlayerInfoProto.GetAllActivityResponse.newBuilder().addAllActivityInfo(activityInfoList).build();
|
||||
MessageUtil.sendMessage(session, 1, rewardResponseValue, build, true);
|
||||
PlayerInfoProto.GetAllActivityResponse.Builder builder = PlayerInfoProto.GetAllActivityResponse.newBuilder();
|
||||
builder.addAllActivityInfo(activityInfoList);
|
||||
sendLuckWheelPool(user,session);
|
||||
MessageUtil.sendMessage(session, 1, rewardResponseValue, builder.build(), true);
|
||||
}
|
||||
|
||||
private void sendLuckWheelPool(User user,ISession session){
|
||||
PlayerInfoProto.LuckWheelIndication.Builder builder = PlayerInfoProto.LuckWheelIndication.newBuilder();
|
||||
builder.addAllPosInfos(LuckWheelActivity.getLuckWheelReward(user,ActivityType.LUCK_WHEEL));
|
||||
builder.addAllPosInfos(LuckWheelActivity.getLuckWheelReward(user,ActivityType.LUCK_WHEEL_ADVANCE));
|
||||
if(builder.getPosInfosAdvanceCount()==0||builder.getPosInfosCount()==0){
|
||||
return;
|
||||
}
|
||||
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.LUCKWHEEL_POOL_INDICATION_VALUE, builder.build(), true);
|
||||
}
|
||||
|
||||
private List<CommonProto.ActivityInfo> getActivityInfos(Map<Integer, ActivityMission> activityMissionMap, long createTime) {
|
||||
|
@ -290,7 +331,7 @@ public class ActivityLogic {
|
|||
}
|
||||
int activityStatus = activityMission.getActivityState();
|
||||
|
||||
if (SGlobalActivity.getsGlobalActivityMap().get(activityId).getIsSaving()==0 && activityStatus != ActivityType.OPEN_STATE) {
|
||||
if (sGlobalActivityMap.get(activityId).getIsSaving()==0 && activityStatus != ActivityType.OPEN_STATE) {
|
||||
continue;
|
||||
}
|
||||
SGlobalActivity sGlobalActivity = sGlobalActivityMap.get(activityId);
|
||||
|
@ -304,6 +345,7 @@ public class ActivityLogic {
|
|||
missionInfos.add(CommonProto.ActivityInfo.MissionInfo.newBuilder().setMissionId(missionId).setProgress(activityProgressInfo.getProgrss()).setState(activityProgressInfo.getState()).build());
|
||||
}
|
||||
activityInfoList.add(CommonProto.ActivityInfo.newBuilder().setActivityId(activityId).addAllMission(missionInfos).setStartTime(startTime).setEndTime(endTime).setValue(activityMission.getValue()).setReallyOpen(activityMission.getOpenType()).build());
|
||||
|
||||
}
|
||||
return activityInfoList;
|
||||
}
|
||||
|
@ -367,7 +409,7 @@ public class ActivityLogic {
|
|||
}
|
||||
|
||||
|
||||
public void upFivePlayerActivity(User user, int activityType, PlayerInfoProto.FivePlayerUpdateIndication.Builder fBuilder) {
|
||||
public void upFivePlayerActivity(User user, Set<Integer> activityType, PlayerInfoProto.FivePlayerUpdateIndication.Builder fBuilder) {
|
||||
if (fBuilder == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -381,7 +423,7 @@ public class ActivityLogic {
|
|||
Integer activityId = item.getKey();
|
||||
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(activityId);
|
||||
int targetActivityType = sGlobalActivity.getType();
|
||||
if (targetActivityType != activityType) {
|
||||
if (!activityType.contains(targetActivityType)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -390,6 +432,11 @@ public class ActivityLogic {
|
|||
continue;
|
||||
}
|
||||
|
||||
if(abstractActivity instanceof LuckWheelActivity){
|
||||
fBuilder.addAllPosInfos(LuckWheelActivity.getLuckWheelReward(user,targetActivityType));
|
||||
continue;
|
||||
}
|
||||
|
||||
long createTime = user.getPlayerInfoManager().getCreateTime();
|
||||
int startTime = (int) (sGlobalActivity.getTimeLong(createTime, 1) / 1000);
|
||||
int endTime = (int) (sGlobalActivity.getTimeLong(createTime, 2) / 1000);
|
||||
|
|
|
@ -40,6 +40,9 @@ public interface ActivityType {
|
|||
int SIGN_IN = 23;//累计签到
|
||||
int RECHARGE_NUM = 24;//累计充值
|
||||
|
||||
int LUCK_WHEEL= 30;//幸运转盘
|
||||
int LUCK_WHEEL_ADVANCE= 31;//高级幸运转盘
|
||||
|
||||
int ESPECIALEQUIP_EXPERT = 37;//法宝达人
|
||||
int SOULEQUIP_EXPERT = 38;//魂印达人
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@ public enum ActivityTypeEnum {
|
|||
RECHARGE_NUM(ActivityType.RECHARGE_NUM, RechargeSumActivity::new),
|
||||
ESPECIALEQUIP_EXPERT(ActivityType.ESPECIALEQUIP_EXPERT, EspecialEquipExpectActivity::new),
|
||||
SOULEQUIP_EXPERT(ActivityType.SOULEQUIP_EXPERT, SoulEquipExpectActivity::new),
|
||||
LUCK_WHEEL(ActivityType.LUCK_WHEEL, LuckWheelNormalActivity::new),
|
||||
LUCK_WHEEL_ADVANCE(ActivityType.LUCK_WHEEL_ADVANCE, LuckWheelAdvancedActivity::new),
|
||||
;
|
||||
private int type;
|
||||
private Function<Integer, AbstractActivity> toActivityFunction;
|
||||
|
@ -61,36 +63,6 @@ public enum ActivityTypeEnum {
|
|||
}
|
||||
}
|
||||
return null;
|
||||
// switch (sGlobalActivity.getType()) {
|
||||
// case ActivityType.OnlineReward:
|
||||
// return ONLINEREWARD.toActivity(id);
|
||||
// case ActivityType.SevenLogin:
|
||||
// return SEVENLOGIN.toActivity(id);
|
||||
// case ActivityType.ChapterReward:
|
||||
// return CHAPTERREWARD.toActivity(id);
|
||||
// case ActivityType.FirstRecharge:
|
||||
// return FIRSTRECHARGE.toActivity(id);
|
||||
// case ActivityType.RechargeTotal:
|
||||
// return RECHARGETOTAL.toActivity(id);
|
||||
// case ActivityType.GrowthFund:
|
||||
// return GROWTHFUND.toActivity(id);
|
||||
// case ActivityType.BLESSACTIVITY:
|
||||
// return BLESSACTIVITY.toActivity(id);
|
||||
// case ActivityType.TREASURE:
|
||||
// return TREASUREACTIVITY.toActivity(id);
|
||||
// case ActivityType.LUCKYCAT:
|
||||
// return LUCKYCAT.toActivity(id);
|
||||
// case ActivityType.FORCERANK:
|
||||
// return FORCERANK.toActivity(id);
|
||||
// case ActivityType.FORCESTANDARD:
|
||||
// return FORCESTANDARD.toActivity(id);
|
||||
// case ActivityType.DAILY_RECHARGE:
|
||||
// return DAILY_RECHARGE.toActivity(id);
|
||||
// case ActivityType.RECHARGE_SUM:
|
||||
// return RECHARGE_SUM.toActivity(id);
|
||||
// default:
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
|
||||
public static Integer getActicityCacheSize() {
|
||||
|
|
|
@ -28,7 +28,7 @@ class ExpectRankActivity extends AbstractActivity {
|
|||
}
|
||||
|
||||
@Override
|
||||
void updateProgress(User user, ActivityMission activityMission, int count) {
|
||||
void updateProgressWithUser(User user, ActivityMission activityMission, int count) {
|
||||
activityMission.setValue(count + activityMission.getValue());
|
||||
String key = RedisKey.getKey(RedisKey.EXPERT_RANK, String.valueOf(id), false);
|
||||
RedisUtil.getInstence().zsetAddOne(key, String.valueOf(user.getId()), activityMission.getValue());
|
||||
|
|
|
@ -40,7 +40,7 @@ class ForceRankActivity extends AbstractActivity {
|
|||
}
|
||||
|
||||
@Override
|
||||
void updateProgress(User user, ActivityMission activityMission, int count) {
|
||||
void updateProgressWithUser(User user, ActivityMission activityMission, int count) {
|
||||
//历史最高
|
||||
if (count > activityMission.getValue()) {
|
||||
activityMission.setValue(count);
|
||||
|
|
|
@ -0,0 +1,146 @@
|
|||
package com.ljsd.jieling.logic.activity;
|
||||
|
||||
import com.ljsd.jieling.config.SDailyTasksConfig;
|
||||
import com.ljsd.jieling.config.SDialRewardConfig;
|
||||
import com.ljsd.jieling.config.SDialRewardSetting;
|
||||
import com.ljsd.jieling.config.SGlobalActivity;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.activity.event.IEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.LuckWheelAdvanceEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.LuckWheelEvent;
|
||||
import com.ljsd.jieling.logic.dao.ActivityMission;
|
||||
import com.ljsd.jieling.logic.dao.LuckWheelMission;
|
||||
import com.ljsd.jieling.logic.dao.LuckWheelPosInfo;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.util.MathUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Description: 幸运大转盘活动基类
|
||||
* Author: zsx
|
||||
* CreateDate: 2019/9/23 14:55
|
||||
*/
|
||||
public abstract class LuckWheelActivity extends AbstractActivity {
|
||||
|
||||
private static int Dial_PerScore;//每转一次获得的积分
|
||||
|
||||
@Override
|
||||
public void onResume(User user) throws Exception {
|
||||
randomReward(user);
|
||||
}
|
||||
|
||||
public LuckWheelActivity(int id) {
|
||||
super(id);
|
||||
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
|
||||
SDialRewardSetting sDialRewardSetting = SDialRewardSetting.getsDialRewardSettingMapByType().get(sGlobalActivity.getType());
|
||||
Dial_PerScore = sDialRewardSetting.getIntegral();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(IEvent event) throws Exception {
|
||||
super.onEvent(event);
|
||||
if (!(event instanceof LuckWheelEvent))
|
||||
return;
|
||||
update(UserManager.getUser(((LuckWheelEvent) event).getUid()), Dial_PerScore);
|
||||
}
|
||||
|
||||
@Override
|
||||
void updateProgressWithUser(User user, ActivityMission activityMission, int count) {
|
||||
activityMission.setValue(count + activityMission.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置奖励
|
||||
*/
|
||||
public void randomReward(User user) {
|
||||
|
||||
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
|
||||
LuckWheelMission luckWheelMission = user.getActivityManager().getLuckWheel(sGlobalActivity.getType());
|
||||
Map<Integer, Set<Integer>> posPools = SDialRewardConfig.getsRandPosMap().get(id);
|
||||
for (int i = 1; i <= posPools.size(); i++) {
|
||||
LuckWheelPosInfo luckWheelPosInfo = new LuckWheelPosInfo();
|
||||
Set<Integer> ids = posPools.get(i);
|
||||
int[][] weight = new int[ids.size()][2];
|
||||
int j = 0;
|
||||
for (Integer id : ids) {
|
||||
weight[j][0] = id;
|
||||
SDialRewardConfig sDialRewardConfig = SDialRewardConfig.getsDialRewardConfigMap().get(id);
|
||||
weight[j][1] = sDialRewardConfig.getInitializeWeight();
|
||||
j++;
|
||||
}
|
||||
int luckId = MathUtils.randomFromWeight(weight);
|
||||
luckWheelPosInfo.setLuckId(luckId);
|
||||
luckWheelMission.setPosInfo(i, luckWheelPosInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static List<CommonProto.LuckWheelRewardPosInfo> getLuckWheelReward(User user, int type) {
|
||||
List<CommonProto.LuckWheelRewardPosInfo> rewardPosInfoList = new LinkedList<>();
|
||||
// SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(activityId);
|
||||
LuckWheelMission luckWheelMission = user.getActivityManager().getLuckWheel(type);
|
||||
for (Map.Entry<Integer, LuckWheelPosInfo> entry : luckWheelMission.getPosInfoMap().entrySet()) {
|
||||
int luckId = entry.getValue().getLuckId();
|
||||
if (entry.getValue().getProgrss() >= SDialRewardConfig.getsDialRewardConfigMap().get(luckId).getLimitNum())
|
||||
continue;
|
||||
CommonProto.LuckWheelRewardPosInfo.Builder builder = CommonProto.LuckWheelRewardPosInfo.newBuilder();
|
||||
builder.setLuckId(entry.getValue().getLuckId());
|
||||
builder.setPos(entry.getKey());
|
||||
rewardPosInfoList.add(builder.build());
|
||||
}
|
||||
return rewardPosInfoList;
|
||||
}
|
||||
|
||||
|
||||
public static int[][] getCost(int buyTimes, int[][] costs) {
|
||||
int costItemId = costs[0][0];
|
||||
int[] ints = costs[1];
|
||||
int costNum = (int) (Math.ceil(Math.pow(ints[0], 3)) * buyTimes) + (int) (Math.ceil(Math.pow(ints[1], 2)) * buyTimes) + (int) (Math.ceil(Math.pow(ints[2], 1)) * buyTimes) + ints[3];
|
||||
int[][] value1 = new int[1][];
|
||||
int[] value2 = new int[2];
|
||||
value2[0] = costItemId;
|
||||
value2[1] = costNum;
|
||||
value1[0] = value2;
|
||||
return value1;
|
||||
}
|
||||
|
||||
public int getNewRewardPool(User user) {
|
||||
|
||||
Map<Integer, Integer> weightMap = new HashMap<>();
|
||||
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
|
||||
LuckWheelMission luckWheelMission = user.getActivityManager().getLuckWheel(sGlobalActivity.getType());
|
||||
int amount = 0;
|
||||
for (Map.Entry<Integer, LuckWheelPosInfo> entry : luckWheelMission.getPosInfoMap().entrySet()) {
|
||||
int luckId = entry.getValue().getLuckId();
|
||||
SDialRewardConfig sDialRewardConfig = SDialRewardConfig.getsDialRewardConfigMap().get(luckId);
|
||||
if (entry.getValue().getProgrss() >= sDialRewardConfig.getLimitNum())
|
||||
continue;
|
||||
weightMap.put(luckId, sDialRewardConfig.getExtractWeight());
|
||||
amount += sDialRewardConfig.getExtractWeight();
|
||||
}
|
||||
//random
|
||||
int result = 0;
|
||||
int rate = MathUtils.randomInt(amount);
|
||||
amount = 0;
|
||||
for (Map.Entry<Integer, Integer> entry : weightMap.entrySet()) {
|
||||
amount += entry.getValue();
|
||||
if (rate < amount) {
|
||||
result = entry.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityEndOnMySelf(User user) throws Exception {
|
||||
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
|
||||
user.getActivityManager().initLuckWheel(sGlobalActivity.getType());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.ljsd.jieling.logic.activity;
|
||||
|
||||
import com.ljsd.jieling.config.SSpecialConfig;
|
||||
import com.ljsd.jieling.logic.activity.event.IEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.LuckWheelAdvanceEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.LuckWheelEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
|
||||
/**
|
||||
* Description: 高级幸运大转盘活动
|
||||
* Author: zsx
|
||||
* CreateDate: 2019/9/23 15:13
|
||||
*/
|
||||
public class LuckWheelAdvancedActivity extends LuckWheelActivity {
|
||||
|
||||
public LuckWheelAdvancedActivity(int id) {
|
||||
super(id);
|
||||
Poster.getPoster().listenEvent(this, LuckWheelAdvanceEvent.class);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.ljsd.jieling.logic.activity;
|
||||
|
||||
import com.ljsd.jieling.config.SSpecialConfig;
|
||||
import com.ljsd.jieling.logic.activity.event.IEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.LuckWheelEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
|
||||
/**
|
||||
* Description: 幸运大转盘活动
|
||||
* Author: zsx
|
||||
* CreateDate: 2019/9/23 14:55
|
||||
*/
|
||||
public class LuckWheelNormalActivity extends LuckWheelActivity {
|
||||
|
||||
|
||||
public LuckWheelNormalActivity(int id) {
|
||||
super(id);
|
||||
Poster.getPoster().listenEvent(this, LuckWheelEvent.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.ljsd.jieling.logic.activity.event;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Description: 高级幸运转盘事件
|
||||
* Author: zsx
|
||||
* CreateDate: 2019/9/23 15:46
|
||||
*/
|
||||
public class LuckWheelAdvanceEvent extends LuckWheelEvent{
|
||||
|
||||
public LuckWheelAdvanceEvent(int uid) {
|
||||
super(uid);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.ljsd.jieling.logic.activity.event;
|
||||
|
||||
|
||||
/**
|
||||
* Description: 幸运转盘事件
|
||||
* Author: zsx
|
||||
* CreateDate: 2019/9/23 15:46
|
||||
*/
|
||||
public class LuckWheelEvent implements IEvent{
|
||||
private int uid;
|
||||
|
||||
public LuckWheelEvent(int uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(int uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
}
|
|
@ -8,34 +8,36 @@ import java.util.Map;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ActivityManager extends MongoBase {
|
||||
private Map<Integer,ActivityMission> activityMissionMap = new HashMap<>();
|
||||
private Map<Integer, ActivityMission> activityMissionMap = new HashMap<>();
|
||||
private long trsendTime; // 孙龙结束时间
|
||||
private long senvenTime; //七日狂欢结束时间
|
||||
private LuckWheelMission luckWheel;//幸运探宝奖池
|
||||
private LuckWheelMission luckWheelAdvance;//高级幸运探宝奖池
|
||||
|
||||
|
||||
public boolean initAllActivityMission(int activityId){
|
||||
if(activityMissionMap.containsKey(activityId)){
|
||||
public boolean initAllActivityMission(int activityId) {
|
||||
if (activityMissionMap.containsKey(activityId)) {
|
||||
return false;
|
||||
}
|
||||
ActivityMission activityMission = new ActivityMission();
|
||||
boolean b = activityMission.initMissionInfo(activityId);
|
||||
if(!b){
|
||||
if (!b) {
|
||||
return false;
|
||||
}
|
||||
activityMission.init(getRootId(),getMongoKey()+".activityMissionMap." + activityId);
|
||||
activityMissionMap.put(activityId,activityMission);
|
||||
activityMission.init(getRootId(), getMongoKey() + ".activityMissionMap." + activityId);
|
||||
activityMissionMap.put(activityId, activityMission);
|
||||
//开启活动
|
||||
updateString("activityMissionMap." + activityId,activityMission);
|
||||
updateString("activityMissionMap." + activityId, activityMission);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addActivity(int activityId,ActivityMission activityMission){
|
||||
activityMission.init(getRootId(),getMongoKey()+".activityMissionMap." + activityId);
|
||||
activityMissionMap.put(activityId,activityMission);
|
||||
updateString("activityMissionMap." + activityId,activityMission);
|
||||
public void addActivity(int activityId, ActivityMission activityMission) {
|
||||
activityMission.init(getRootId(), getMongoKey() + ".activityMissionMap." + activityId);
|
||||
activityMissionMap.put(activityId, activityMission);
|
||||
updateString("activityMissionMap." + activityId, activityMission);
|
||||
}
|
||||
|
||||
public void removeActivity(int activityId){
|
||||
public void removeActivity(int activityId) {
|
||||
activityMissionMap.remove(activityId);
|
||||
removeString(getMongoKey() + ".activityMissionMap." + activityId);
|
||||
}
|
||||
|
@ -46,7 +48,7 @@ public class ActivityManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setSenvenTime(long senvenTime) {
|
||||
updateString("senvenTime" ,senvenTime);
|
||||
updateString("senvenTime", senvenTime);
|
||||
this.senvenTime = senvenTime;
|
||||
}
|
||||
|
||||
|
@ -55,11 +57,34 @@ public class ActivityManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setTrsendTime(long trsendTime) {
|
||||
updateString("trsendTime" ,trsendTime);
|
||||
updateString("trsendTime", trsendTime);
|
||||
this.trsendTime = trsendTime;
|
||||
}
|
||||
|
||||
public Map<Integer, ActivityMission> getActivityMissionMap() {
|
||||
return activityMissionMap;
|
||||
}
|
||||
|
||||
public LuckWheelMission getLuckWheel(int type) {
|
||||
LuckWheelMission luckWheelMission = type == ActivityType.LUCK_WHEEL ? luckWheel : luckWheelAdvance;
|
||||
if (null == luckWheelMission) {
|
||||
String key = type == ActivityType.LUCK_WHEEL ? "luckWheel" : "luckWheelAdvance";
|
||||
luckWheelMission = new LuckWheelMission();
|
||||
luckWheelMission.init(getRootId(), getMongoKey() + "." + key);
|
||||
updateString(key, luckWheelMission);
|
||||
}
|
||||
return luckWheelMission;
|
||||
}
|
||||
|
||||
public void initLuckWheel(int type) {
|
||||
LuckWheelMission luckWheelMission = type == ActivityType.LUCK_WHEEL ? luckWheel : luckWheelAdvance;
|
||||
if (null != luckWheelMission) {
|
||||
String key = type == ActivityType.LUCK_WHEEL ? "luckWheel" : "luckWheelAdvance";
|
||||
luckWheelMission = new LuckWheelMission();
|
||||
luckWheelMission.init(getRootId(), getMongoKey() + "." + key);
|
||||
updateString(key, luckWheelMission);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Description: 幸运探宝数据
|
||||
* Author: zsx
|
||||
* CreateDate: 2019/9/24 11:22
|
||||
*/
|
||||
public class LuckWheelMission extends MongoBase {
|
||||
|
||||
private Map<Integer,LuckWheelPosInfo> posInfoMap = new HashMap<>();
|
||||
private int refreshTime;
|
||||
|
||||
|
||||
public void setPosInfo(int pos,LuckWheelPosInfo luckWheelPosInfo) {
|
||||
if(!posInfoMap.containsKey(pos)){
|
||||
return;
|
||||
}
|
||||
updateString("posInfoMap." + pos, luckWheelPosInfo);
|
||||
}
|
||||
|
||||
public void upPosInfo(int pos,LuckWheelPosInfo luckWheelPosInfo) {
|
||||
if(!posInfoMap.containsKey(pos)){
|
||||
return;
|
||||
}
|
||||
updateString("posInfoMap." + pos, luckWheelPosInfo);
|
||||
}
|
||||
|
||||
public Map<Integer, LuckWheelPosInfo> getPosInfoMap() {
|
||||
return posInfoMap;
|
||||
}
|
||||
|
||||
public int getRefreshTime() {
|
||||
return refreshTime;
|
||||
}
|
||||
|
||||
public void setRefreshTime(int refreshTime) {
|
||||
updateString("refreshTime", refreshTime);
|
||||
this.refreshTime = refreshTime;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
/**
|
||||
* Description: 幸运探宝数据
|
||||
* Author: zsx
|
||||
* CreateDate: 2019/9/24 11:22
|
||||
*/
|
||||
public class LuckWheelPosInfo {
|
||||
private int luckId;
|
||||
private int progrss;
|
||||
|
||||
public LuckWheelPosInfo() {
|
||||
}
|
||||
|
||||
public LuckWheelPosInfo(int luckId, int progrss) {
|
||||
this.luckId = luckId;
|
||||
this.progrss = progrss;
|
||||
}
|
||||
|
||||
public int getProgrss() {
|
||||
return progrss;
|
||||
}
|
||||
|
||||
public void setProgrss(int progrss) {
|
||||
this.progrss = progrss;
|
||||
}
|
||||
|
||||
public void addProgrss() {
|
||||
this.progrss = +1;
|
||||
}
|
||||
|
||||
public int getLuckId() {
|
||||
return luckId;
|
||||
}
|
||||
|
||||
public void setLuckId(int luckId) {
|
||||
this.luckId = luckId;
|
||||
}
|
||||
}
|
|
@ -331,20 +331,17 @@ public class FriendLogic {
|
|||
}
|
||||
|
||||
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());
|
||||
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();
|
||||
|
||||
AyyncWorker ayyncWorker = new AyyncWorker(friendUser, true, (user) ->
|
||||
{
|
||||
boolean isOnline = OnlineUserManager.checkUidOnline(user.getId());
|
||||
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);
|
||||
|
|
|
@ -1086,28 +1086,25 @@ public class HeroLogic {
|
|||
equipForce+=sEquipConfig.getScore();
|
||||
}
|
||||
if(needRemove){
|
||||
AyyncWorker ayyncWorker = new AyyncWorker(user,true) {
|
||||
@Override
|
||||
public void work(User user) throws Exception {
|
||||
Map<String, Hero> heroMap = user.getHeroManager().getHeroMap();
|
||||
for(Hero heroTmp : heroMap.values()){
|
||||
Iterator<Map.Entry<Integer, String>> iterator = heroTmp.getEquipByPositionMap().entrySet().iterator();
|
||||
boolean isUpate = false;
|
||||
while (iterator.hasNext()){
|
||||
Map.Entry<Integer, String> next = iterator.next();
|
||||
String equipId = next.getValue();
|
||||
Equip equip = equipManager.getEquipMap().get(equipId);
|
||||
if(equip == null){
|
||||
iterator.remove();
|
||||
isUpate = true;
|
||||
}
|
||||
}
|
||||
if(isUpate){
|
||||
heroTmp.setEquipByPositionMap(heroTmp.getEquipByPositionMap());
|
||||
AyyncWorker ayyncWorker = new AyyncWorker(user,true,user1 -> {
|
||||
Map<String, Hero> heroMap = user1.getHeroManager().getHeroMap();
|
||||
for(Hero heroTmp : heroMap.values()){
|
||||
Iterator<Map.Entry<Integer, String>> iterator1 = heroTmp.getEquipByPositionMap().entrySet().iterator();
|
||||
boolean isUpate = false;
|
||||
while (iterator1.hasNext()){
|
||||
Map.Entry<Integer, String> next = iterator1.next();
|
||||
String equipId = next.getValue();
|
||||
Equip equip = equipManager.getEquipMap().get(equipId);
|
||||
if(equip == null){
|
||||
iterator1.remove();
|
||||
isUpate = true;
|
||||
}
|
||||
}
|
||||
if(isUpate){
|
||||
heroTmp.setEquipByPositionMap(heroTmp.getEquipByPositionMap());
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
ProtocolsManager instance = ProtocolsManager.getInstance();
|
||||
HandlerLogicThread handlerThread = instance.handlerThreads[user.getId() % instance.HANDLER_THREAD_NUM];
|
||||
handlerThread.addAyyncWorker(ayyncWorker);
|
||||
|
|
|
@ -34,10 +34,10 @@ public class QuestionLogic {
|
|||
}
|
||||
|
||||
|
||||
public void onLogin(User user) throws Exception{
|
||||
public void onLogin(User user) throws Exception {
|
||||
GlobalSystemControl globalSystemControl = GlobalSystemControl.getGlobalSystemControl();
|
||||
if (user.getQuestionManager().getQuestId() != globalSystemControl.getQuestId()) {
|
||||
if(!user.getQuestionManager().getAnswerMap().containsKey(String.valueOf(globalSystemControl.getQuestId()))){
|
||||
if (!user.getQuestionManager().getAnswerMap().containsKey(String.valueOf(globalSystemControl.getQuestId()))) {
|
||||
user.getQuestionManager().setQuestId(globalSystemControl.getQuestId());
|
||||
user.getQuestionManager().setQuestState(0);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class QuestionLogic {
|
|||
TreeSet<CQuestionBean> last = new TreeSet<>((CQuestionBean o1, CQuestionBean o2) -> {
|
||||
if (Long.valueOf(o1.getStart()) > Long.valueOf(o2.getStart())) {
|
||||
return -1;
|
||||
} else if (Long.valueOf(o1.getStart()) .equals( Long.valueOf(o2.getStart()))) {
|
||||
} else if (Long.valueOf(o1.getStart()).equals(Long.valueOf(o2.getStart()))) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
|
@ -87,7 +87,7 @@ public class QuestionLogic {
|
|||
continue;
|
||||
}
|
||||
last.add(entry.getValue());
|
||||
// remove.add(entry.getKey());
|
||||
// remove.add(entry.getKey());
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,17 +96,15 @@ public class QuestionLogic {
|
|||
globalSystemControl.setQuestId(0);
|
||||
isNeedUp = true;
|
||||
PlayerInfoProto.QuestionIndication builder = PlayerInfoProto.QuestionIndication.newBuilder().setState(-1).build();
|
||||
InnerMessageUtil.broadcastWithRandom(new AyyncWorker() {
|
||||
@Override
|
||||
public void work(User user) throws Exception {
|
||||
user.getQuestionManager().setQuestId(0);
|
||||
user.getQuestionManager().setQuestState(0);
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(user.getId());
|
||||
if(null ==sessionByUid){
|
||||
return;
|
||||
}
|
||||
MessageUtil.sendIndicationMessage(sessionByUid, 1, MessageTypeProto.MessageType.QUESTION_INDICATION_VALUE, builder, true);
|
||||
InnerMessageUtil.broadcastWithRandom(user1 -> {
|
||||
user1.getQuestionManager().setQuestId(0);
|
||||
user1.getQuestionManager().setQuestState(0);
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(user1.getId());
|
||||
if (null == sessionByUid) {
|
||||
return;
|
||||
}
|
||||
MessageUtil.sendIndicationMessage(sessionByUid, 1, MessageTypeProto.MessageType.QUESTION_INDICATION_VALUE, builder, true);
|
||||
|
||||
}, new ArrayList<>(OnlineUserManager.sessionMap.keySet()), 120);
|
||||
|
||||
}
|
||||
|
@ -121,18 +119,16 @@ public class QuestionLogic {
|
|||
globalSystemControl.resetLast();
|
||||
isNeedUp = true;
|
||||
PlayerInfoProto.QuestionIndication builder = PlayerInfoProto.QuestionIndication.newBuilder().setState(1).build();
|
||||
InnerMessageUtil.broadcastWithRandom(new AyyncWorker() {
|
||||
@Override
|
||||
public void work(User user) throws Exception {
|
||||
user.getQuestionManager().setQuestId(qid);
|
||||
user.getQuestionManager().setQuestState(0);
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(user.getId());
|
||||
if(null ==sessionByUid){
|
||||
return;
|
||||
InnerMessageUtil.broadcastWithRandom(user1 -> {
|
||||
user1.getQuestionManager().setQuestId(qid);
|
||||
user1.getQuestionManager().setQuestState(0);
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(user1.getId());
|
||||
if (null == sessionByUid) {
|
||||
return;
|
||||
}
|
||||
MessageUtil.sendIndicationMessage(sessionByUid, 1, MessageTypeProto.MessageType.QUESTION_INDICATION_VALUE, builder, true);
|
||||
}
|
||||
MessageUtil.sendIndicationMessage(sessionByUid, 1, MessageTypeProto.MessageType.QUESTION_INDICATION_VALUE, builder, true);
|
||||
}
|
||||
}, new ArrayList<>(OnlineUserManager.sessionMap.keySet()), 120);
|
||||
, new ArrayList<>(OnlineUserManager.sessionMap.keySet()), 120);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -140,7 +136,7 @@ public class QuestionLogic {
|
|||
MongoUtil.getInstence().getMyMongoTemplate().save(globalSystemControl);
|
||||
}
|
||||
//remove
|
||||
for (Integer id:remove) {
|
||||
for (Integer id : remove) {
|
||||
RedisUtil.getInstence().removeMapEntrys(RedisKey.QUESTION_FROMBACK, "", String.valueOf(id));
|
||||
}
|
||||
|
||||
|
|
|
@ -70,13 +70,10 @@ public class StoreLogic {
|
|||
}
|
||||
|
||||
private static void updateUsersStoreAyync(User user,int id){
|
||||
AyyncWorker ayyncWorker = new AyyncWorker(user,true) {
|
||||
@Override
|
||||
public void work(User user) throws Exception {
|
||||
initOneStore(user,id);
|
||||
MongoUtil.getInstence().lastUpdate();
|
||||
}
|
||||
};
|
||||
AyyncWorker ayyncWorker = new AyyncWorker(user,true,user1 -> {
|
||||
initOneStore(user1,id);
|
||||
MongoUtil.getInstence().lastUpdate();
|
||||
});
|
||||
ProtocolsManager instance = ProtocolsManager.getInstance();
|
||||
HandlerLogicThread handlerThread = instance.handlerThreads[user.getId() % instance.HANDLER_THREAD_NUM];
|
||||
handlerThread.addAyyncWorker(ayyncWorker);
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.ljsd.jieling.logic.blood.BloodLogic;
|
|||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||
import com.ljsd.jieling.util.AyncWorkerRunnable;
|
||||
import com.ljsd.jieling.util.AyyncWorker;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -32,12 +33,9 @@ public class FetchBloodyEndDataThread extends Thread{
|
|||
for(SortDataBean sortDataBean : mapValues.values()){
|
||||
int uid = sortDataBean.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
AyyncWorker ayyncWorker = new AyyncWorker(user,true) {
|
||||
@Override
|
||||
public void work(User user) throws Exception {
|
||||
BloodLogic.getInstance().calBloodyMissionInfo(user,sortDataBean);
|
||||
}
|
||||
};
|
||||
AyyncWorker ayyncWorker = new AyyncWorker(user, true,(user1) ->
|
||||
BloodLogic.getInstance().calBloodyMissionInfo(user1,sortDataBean)
|
||||
);
|
||||
ProtocolsManager instance = ProtocolsManager.getInstance();
|
||||
HandlerLogicThread handlerThread = instance.handlerThreads[uid % instance.HANDLER_THREAD_NUM];
|
||||
handlerThread.addAyyncWorker(ayyncWorker);
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.ljsd.jieling.util;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
||||
/**
|
||||
* Description: 异步task
|
||||
* Author: zsx
|
||||
* CreateDate: 2019/9/26 10:25
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface AyncWorkerRunnable {
|
||||
void work(User user) throws Exception;
|
||||
}
|
|
@ -2,21 +2,24 @@ package com.ljsd.jieling.util;
|
|||
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
||||
public abstract class AyyncWorker {
|
||||
/**
|
||||
* 异步任务代理类
|
||||
*/
|
||||
public class AyyncWorker{
|
||||
private User user;
|
||||
private boolean isTask;
|
||||
private AyncWorkerRunnable ayncWorkerRunnable;
|
||||
|
||||
public AyyncWorker() {
|
||||
}
|
||||
|
||||
public AyyncWorker(User user, boolean isTask){
|
||||
public AyyncWorker(User user, boolean isTask, AyncWorkerRunnable ayncWorkerRunnable) {
|
||||
this.user = user;
|
||||
this.isTask = isTask;
|
||||
this.ayncWorkerRunnable = ayncWorkerRunnable;
|
||||
}
|
||||
|
||||
public void exec() throws Exception {
|
||||
work(user);
|
||||
ayncWorkerRunnable.work(user);
|
||||
}
|
||||
public abstract void work(User user) throws Exception;
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
|
|
|
@ -22,79 +22,72 @@ public class InnerMessageUtil {
|
|||
/**
|
||||
* 通知所有在线玩家 随机时间 /s
|
||||
*/
|
||||
public static void broadcastWithRandom(AyyncWorker ayyncWorker, List<Integer> sendId, int timeBound) throws InterruptedException {
|
||||
|
||||
|
||||
ThreadManager.getScheduledExecutor().schedule(() -> {
|
||||
try {
|
||||
int lastUid=0;
|
||||
for (Integer id : sendId) {
|
||||
User userInMem = UserManager.getUserInMem(id);
|
||||
if(userInMem == null){
|
||||
continue;
|
||||
}
|
||||
ProtocolsManager instance = ProtocolsManager.getInstance();
|
||||
if(lastUid!=0){
|
||||
HandlerLogicThread handlerThread = instance.handlerThreads[lastUid % instance.HANDLER_THREAD_NUM];
|
||||
int retryTimes = 30;
|
||||
while ( !handlerThread.ayyncWorkerConcurrentLinkedQueue.isEmpty()){
|
||||
Thread.sleep(50);
|
||||
retryTimes--;
|
||||
if(retryTimes<0){
|
||||
System.out.println("fail fail ---------------------->>>>>fail..");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Thread.sleep(50);
|
||||
}
|
||||
HandlerLogicThread handlerThread = instance.handlerThreads[id % instance.HANDLER_THREAD_NUM];
|
||||
ayyncWorker.setTask(true);
|
||||
ayyncWorker.setUser(userInMem);
|
||||
handlerThread.addAyyncWorker(ayyncWorker);
|
||||
lastUid =id;
|
||||
}
|
||||
}catch (Exception e){}
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
public static void broadcastWithRandom(AyncWorkerRunnable ayncWorkerRunnable, List<Integer> sendId, int timeBound) throws InterruptedException {
|
||||
|
||||
//
|
||||
//
|
||||
// ExecutorService executorService = Executors.newFixedThreadPool(1);
|
||||
// executorService.execute(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// try {
|
||||
// int lastUid=0;
|
||||
// for (Integer id : sendId) {
|
||||
// User userInMem = UserManager.getUserInMem(id);
|
||||
// if(userInMem == null){
|
||||
// continue;
|
||||
// }
|
||||
// ProtocolsManager instance = ProtocolsManager.getInstance();
|
||||
// if(lastUid!=0){
|
||||
// HandlerLogicThread handlerThread = instance.handlerThreads[lastUid % instance.HANDLER_THREAD_NUM];
|
||||
// int retryTimes = 30;
|
||||
// while ( !handlerThread.ayyncWorkerConcurrentLinkedQueue.isEmpty()){
|
||||
// Thread.sleep(50);
|
||||
// retryTimes--;
|
||||
// if(retryTimes<0){
|
||||
// System.out.println("fail fail ---------------------->>>>>fail..");
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// Thread.sleep(50);
|
||||
// }
|
||||
// HandlerLogicThread handlerThread = instance.handlerThreads[id % instance.HANDLER_THREAD_NUM];
|
||||
// ayyncWorker.setTask(true);
|
||||
// ayyncWorker.setUser(userInMem);
|
||||
// handlerThread.addAyyncWorker(ayyncWorker);
|
||||
// lastUid =id;
|
||||
// ThreadManager.getScheduledExecutor().schedule(() -> {
|
||||
// try {
|
||||
// int lastUid=0;
|
||||
// for (Integer id : sendId) {
|
||||
// User userInMem = UserManager.getUserInMem(id);
|
||||
// if(userInMem == null){
|
||||
// continue;
|
||||
// }
|
||||
// }catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// ProtocolsManager instance = ProtocolsManager.getInstance();
|
||||
// if(lastUid!=0){
|
||||
// HandlerLogicThread handlerThread = instance.handlerThreads[lastUid % instance.HANDLER_THREAD_NUM];
|
||||
// int retryTimes = 30;
|
||||
// while ( !handlerThread.ayyncWorkerConcurrentLinkedQueue.isEmpty()){
|
||||
// Thread.sleep(50);
|
||||
// retryTimes--;
|
||||
// if(retryTimes<0){
|
||||
// System.out.println("fail fail ---------------------->>>>>fail..");
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// Thread.sleep(50);
|
||||
// }
|
||||
// HandlerLogicThread handlerThread = instance.handlerThreads[id % instance.HANDLER_THREAD_NUM];
|
||||
// ayyncWorker.setTask(true);
|
||||
// ayyncWorker.setUser(userInMem);
|
||||
// handlerThread.addAyyncWorker(ayyncWorker);
|
||||
// lastUid =id;
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }catch (Exception e){}
|
||||
// }, 1, TimeUnit.SECONDS);
|
||||
|
||||
|
||||
|
||||
for (Integer id : sendId) {
|
||||
ThreadManager.getScheduledExecutor().schedule(new InnerTask(id){
|
||||
@Override
|
||||
public void run() {
|
||||
ProtocolsManager instance = ProtocolsManager.getInstance();
|
||||
HandlerLogicThread handlerThread = instance.handlerThreads[getUid() % instance.HANDLER_THREAD_NUM];
|
||||
User userInMem = UserManager.getUserInMem(getUid());
|
||||
if(userInMem == null){
|
||||
return;
|
||||
}
|
||||
AyyncWorker ayyncWorker = new AyyncWorker(userInMem,true,ayncWorkerRunnable);
|
||||
handlerThread.addAyyncWorker(ayyncWorker);
|
||||
}
|
||||
}
|
||||
, MathUtils.randomInt(timeBound), TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
static abstract class InnerTask implements Runnable{
|
||||
int uid;
|
||||
|
||||
public InnerTask(int uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue