back_recharge
parent
7ba0084c23
commit
eaa1767284
|
@ -8,6 +8,7 @@ import com.ljsd.jieling.db.redis.RedisUtil;
|
||||||
import com.ljsd.jieling.handler.BaseHandler;
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
import com.ljsd.jieling.handler.map.MapLogic;
|
import com.ljsd.jieling.handler.map.MapLogic;
|
||||||
import com.ljsd.jieling.logic.STableManager;
|
import com.ljsd.jieling.logic.STableManager;
|
||||||
|
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||||
import com.ljsd.jieling.logic.dao.MailingSystemManager;
|
import com.ljsd.jieling.logic.dao.MailingSystemManager;
|
||||||
import com.ljsd.jieling.logic.fight.CheckFight;
|
import com.ljsd.jieling.logic.fight.CheckFight;
|
||||||
import com.ljsd.jieling.logic.fight.CombatLogic;
|
import com.ljsd.jieling.logic.fight.CombatLogic;
|
||||||
|
@ -105,6 +106,7 @@ public class GameApplication {
|
||||||
serverConfig = serverConfigTmp;
|
serverConfig = serverConfigTmp;
|
||||||
}
|
}
|
||||||
KeyGenUtils.setMachineNum(serverConfiguration.getServerProperties().getNum());
|
KeyGenUtils.setMachineNum(serverConfiguration.getServerProperties().getNum());
|
||||||
|
ActivityLogic.getInstance().checkActiviyStatus();
|
||||||
try {
|
try {
|
||||||
LOGGER.info("main->CoreApplication start...");
|
LOGGER.info("main->CoreApplication start...");
|
||||||
ISessionFactory sessionFactory = new ISessionFactory();
|
ISessionFactory sessionFactory = new ISessionFactory();
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
package com.ljsd.jieling.config;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.logic.STableManager;
|
||||||
|
import com.ljsd.jieling.logic.Table;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Table(name ="ActivityRewardConfig")
|
||||||
|
public class SActivityRewardConfig implements BaseConfig {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private int activityId;
|
||||||
|
|
||||||
|
private int[][] values;
|
||||||
|
|
||||||
|
private int[][] reward;
|
||||||
|
|
||||||
|
private static Map<Integer, SActivityRewardConfig> sActivityRewardConfigMap;
|
||||||
|
|
||||||
|
private static Map<Integer, List<SActivityRewardConfig>> sActivityRewardConfigListMap;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() throws Exception {
|
||||||
|
Map<Integer, SActivityRewardConfig> config = STableManager.getConfig(SActivityRewardConfig.class);
|
||||||
|
Map<Integer, List<SActivityRewardConfig>> sActivityRewardConfigListMapTmp = new HashMap<>();
|
||||||
|
for(SActivityRewardConfig sActivityRewardConfig : config.values()){
|
||||||
|
int activityId = sActivityRewardConfig.getActivityId();
|
||||||
|
if(!sActivityRewardConfigListMapTmp.containsKey(activityId)){
|
||||||
|
sActivityRewardConfigListMapTmp.put(activityId,new ArrayList<>());
|
||||||
|
}
|
||||||
|
sActivityRewardConfigListMapTmp.get(activityId).add(sActivityRewardConfig);
|
||||||
|
}
|
||||||
|
sActivityRewardConfigMap = config;
|
||||||
|
sActivityRewardConfigListMap = sActivityRewardConfigListMapTmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SActivityRewardConfig getsActivityRewardConfigByMissionId(int missionId) {
|
||||||
|
return sActivityRewardConfigMap.get(missionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<SActivityRewardConfig> getsActivityRewardConfigByActivityId(int activityId) {
|
||||||
|
return sActivityRewardConfigListMap.get(activityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getActivityId() {
|
||||||
|
return activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[][] getValues() {
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[][] getReward() {
|
||||||
|
return reward;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
package com.ljsd.jieling.config;
|
||||||
|
|
||||||
|
import com.ljsd.GameApplication;
|
||||||
|
import com.ljsd.jieling.logic.STableManager;
|
||||||
|
import com.ljsd.jieling.logic.Table;
|
||||||
|
import com.ljsd.jieling.logic.activity.ActivityType;
|
||||||
|
import com.ljsd.jieling.logic.player.PlayerLogic;
|
||||||
|
import com.ljsd.jieling.util.TimeUtils;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Table(name ="GlobalActivity")
|
||||||
|
public class SGlobalActivity implements BaseConfig {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private int type;
|
||||||
|
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
private String endtime;
|
||||||
|
|
||||||
|
private int time;
|
||||||
|
|
||||||
|
private long startTimeLong;
|
||||||
|
|
||||||
|
private long endTimeLong;
|
||||||
|
|
||||||
|
private static Map<Integer, SGlobalActivity> sGlobalActivityMap;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() throws Exception {
|
||||||
|
Map<Integer, SGlobalActivity> config = STableManager.getConfig(SGlobalActivity.class);
|
||||||
|
for(SGlobalActivity sGlobalActivity : config.values()){
|
||||||
|
int time = sGlobalActivity.getTime();
|
||||||
|
String startTime = sGlobalActivity.getStartTime();
|
||||||
|
String endtime = sGlobalActivity.getEndtime();
|
||||||
|
if(time == 1 ){
|
||||||
|
if("0".equals(endtime)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
setStartTimeLong(TimeUtils.parseTimeToMiles(startTime,"YYYYMMdd hh:mm:ss"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
setStartTimeLong(Long.parseLong(startTime));
|
||||||
|
setStartTimeLong(Long.parseLong(endtime));
|
||||||
|
}
|
||||||
|
sGlobalActivityMap = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<Integer, SGlobalActivity> getsGlobalActivityMap() {
|
||||||
|
return sGlobalActivityMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEndtime() {
|
||||||
|
return endtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTimeLong(long createUserTime,int type) {
|
||||||
|
long baseTime = startTimeLong;
|
||||||
|
if(type == 2){
|
||||||
|
baseTime = endTimeLong;
|
||||||
|
}
|
||||||
|
long startTime=0;
|
||||||
|
if(time == ActivityType.OPEN_TYPE_TIME){
|
||||||
|
startTime = baseTime;
|
||||||
|
}else if(time == ActivityType.OPEN_TYPE_SERVER){
|
||||||
|
long serverOpenTime = GameApplication.serverConfig.getCacheOpenTime();
|
||||||
|
startTime = serverOpenTime + baseTime*1000;
|
||||||
|
}else if(time == ActivityType.OPEN_TYPE_ROLE){
|
||||||
|
startTime =createUserTime+baseTime*1000;
|
||||||
|
}
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTimeLong(long startTimeLong) {
|
||||||
|
this.startTimeLong = startTimeLong;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTimeLong(long endTimeLong) {
|
||||||
|
this.endTimeLong = endTimeLong;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -26,4 +26,6 @@ public class MongoKey {
|
||||||
|
|
||||||
public final static String levelDifficultyManager = "levelDifficultyManager";
|
public final static String levelDifficultyManager = "levelDifficultyManager";
|
||||||
|
|
||||||
|
public final static String activityManager = "activityManager";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.ljsd.jieling.handler;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||||
|
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class GetAllActivityInfoHandler extends BaseHandler{
|
||||||
|
@Override
|
||||||
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
|
return MessageTypeProto.MessageType.GET_ALL_ACTIVITY_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||||
|
ActivityLogic.getInstance().getAllActivityInfo(iSession);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.ljsd.jieling.handler;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||||
|
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
|
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class TakeActivityRewardHandler extends BaseHandler{
|
||||||
|
@Override
|
||||||
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
|
return MessageTypeProto.MessageType.TAKE_ACTIVITY_REWARD_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||||
|
byte[] bytes = netData.parseClientProtoNetData();
|
||||||
|
PlayerInfoProto.TakeActivityRewardRequest takeActivityRewardRequest = PlayerInfoProto.TakeActivityRewardRequest.parseFrom(bytes);
|
||||||
|
int missionId = takeActivityRewardRequest.getMissionId();
|
||||||
|
ActivityLogic.getInstance().takeReward(iSession,missionId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,18 +1,158 @@
|
||||||
package com.ljsd.jieling.logic.activity;
|
package com.ljsd.jieling.logic.activity;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.config.SActivityRewardConfig;
|
||||||
|
import com.ljsd.jieling.config.SGlobalActivity;
|
||||||
|
import com.ljsd.jieling.logic.dao.ActivityManager;
|
||||||
|
import com.ljsd.jieling.logic.dao.ActivityMission;
|
||||||
|
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;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class ActivityLogic {
|
public class ActivityLogic {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ActivityLogic.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ActivityLogic.class);
|
||||||
|
|
||||||
private ActivityLogic(){}
|
private ActivityLogic(){}
|
||||||
|
|
||||||
|
private Set<Integer> openActivityIds =new HashSet<>();
|
||||||
|
|
||||||
|
|
||||||
public static class Instance {
|
public static class Instance {
|
||||||
public final static ActivityLogic instance = new ActivityLogic();
|
public final static ActivityLogic instance = new ActivityLogic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkActiviyStatus() {
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
Map<Integer, SGlobalActivity> sGlobalActivityMap = SGlobalActivity.getsGlobalActivityMap();
|
||||||
|
for(SGlobalActivity sGlobalActivity:sGlobalActivityMap.values()){
|
||||||
|
int time = sGlobalActivity.getTime();
|
||||||
|
if(time ==3 ){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
long startTime = sGlobalActivity.getTimeLong(0,1);
|
||||||
|
long endTime = sGlobalActivity.getTimeLong(0,2);
|
||||||
|
if(now<startTime){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(now>endTime && openActivityIds.contains(sGlobalActivity.getId())){
|
||||||
|
openActivityIds.remove(sGlobalActivity.getId());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
openActivityIds.add(sGlobalActivity.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkActivityOfUser(User user){
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
ActivityManager activityManager = user.getActivityManager();
|
||||||
|
Map<Integer, Integer> activityState = activityManager.getActivityState();
|
||||||
|
Map<Integer, SGlobalActivity> sGlobalActivityMap = SGlobalActivity.getsGlobalActivityMap();
|
||||||
|
for(Integer openActivityId : openActivityIds){
|
||||||
|
activityManager.initAllActivityMission(openActivityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
long userCreateTime = user.getPlayerInfoManager().getCreateTime();
|
||||||
|
for(SGlobalActivity sGlobalActivity:sGlobalActivityMap.values()){
|
||||||
|
int activityId = sGlobalActivity.getId();
|
||||||
|
if(!openActivityIds.contains(activityId)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int time = sGlobalActivity.getTime();
|
||||||
|
if(time ==3 ){
|
||||||
|
long startTime = sGlobalActivity.getTimeLong(userCreateTime,1);
|
||||||
|
long endTime = sGlobalActivity.getTimeLong(userCreateTime,2);
|
||||||
|
if(now<startTime){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
activityManager.initAllActivityMission(activityId);
|
||||||
|
}else{
|
||||||
|
activityState.put(activityId,ActivityType.CLOSE_STATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static ActivityLogic getInstance() {
|
public static ActivityLogic getInstance() {
|
||||||
return ActivityLogic.Instance.instance;
|
return ActivityLogic.Instance.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void takeReward(ISession session,int missionId) throws Exception {
|
||||||
|
int uid = session.getUid();
|
||||||
|
User user = UserManager.getUser(uid);
|
||||||
|
int rewardResponseValue = MessageTypeProto.MessageType.TAKE_ACTIVITY_REWARD_RESPONSE_VALUE;
|
||||||
|
SActivityRewardConfig sActivityRewardConfig = SActivityRewardConfig.getsActivityRewardConfigByMissionId(missionId);
|
||||||
|
if(sActivityRewardConfig == null){
|
||||||
|
MessageUtil.sendErrorResponse(session,0,rewardResponseValue,"");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int activityId = sActivityRewardConfig.getActivityId();
|
||||||
|
ActivityManager activityManager = user.getActivityManager();
|
||||||
|
ActivityMission activityMission = activityManager.getActivityMissionMap().get(activityId);
|
||||||
|
Integer missionState = activityMission.getAllMissionStatus().get(missionId);
|
||||||
|
if( null == missionState || missionState == ActivityType.HAD_TAKED){
|
||||||
|
MessageUtil.sendErrorResponse(session,0,rewardResponseValue,"had taked");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(activityId);
|
||||||
|
int[][] values = sActivityRewardConfig.getValues();
|
||||||
|
if(sGlobalActivity.getType() == ActivityType.ChapterReward){
|
||||||
|
|
||||||
|
/* LevelDifficulty levelDifficulty = user.getLevelDifficultyManager().getLevelDifficultyInfosMap().get(values[0][0]);
|
||||||
|
if(levelDifficulty == null || levelDifficulty.getState()!= Global.FIGHT_CLEARANCE){
|
||||||
|
MessageUtil.sendErrorResponse(session,0,rewardResponseValue,"not pass");
|
||||||
|
return;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
int[][] reward = sActivityRewardConfig.getReward();
|
||||||
|
CommonProto.Drop.Builder drop = ItemUtil.drop(user, reward);
|
||||||
|
activityMission.updateMissionStatus(missionId,ActivityType.HAD_TAKED);
|
||||||
|
PlayerInfoProto.TakeActivityRewardResponse build = PlayerInfoProto.TakeActivityRewardResponse.newBuilder().setDrop(drop).build();
|
||||||
|
MessageUtil.sendMessage(session,1,rewardResponseValue,build,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getAllActivityInfo(ISession session) throws Exception {
|
||||||
|
int uid = session.getUid();
|
||||||
|
User user = UserManager.getUser(uid);
|
||||||
|
long createTime = user.getPlayerInfoManager().getCreateTime();
|
||||||
|
int rewardResponseValue = MessageTypeProto.MessageType.GET_ALL_ACTIVITY_RESPONSE_VALUE;
|
||||||
|
checkActivityOfUser(user);
|
||||||
|
ActivityManager activityManager = user.getActivityManager();
|
||||||
|
Map<Integer, Integer> activityStateMap = activityManager.getActivityState();
|
||||||
|
Map<Integer, SGlobalActivity> sGlobalActivityMap = SGlobalActivity.getsGlobalActivityMap();
|
||||||
|
Map<Integer, ActivityMission> activityMissionMap = activityManager.getActivityMissionMap();
|
||||||
|
List<CommonProto.ActivityInfo> activityInfoList = new ArrayList<>(activityStateMap.size());
|
||||||
|
for(Map.Entry<Integer,Integer> activityState : activityStateMap.entrySet()){
|
||||||
|
Integer activityId = activityState.getKey();
|
||||||
|
Integer activityStatus = activityState.getValue();
|
||||||
|
if(activityStatus != ActivityType.OPEN_STATE){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
SGlobalActivity sGlobalActivity = sGlobalActivityMap.get(activityId);
|
||||||
|
int startTime = (int)(sGlobalActivity.getTimeLong(createTime, 1)/1000);
|
||||||
|
int endTime = (int)(sGlobalActivity.getTimeLong(createTime, 2)/1000);
|
||||||
|
ActivityMission activityMission = activityMissionMap.get(activityId);
|
||||||
|
Map<Integer, Integer> allMissionProgress = activityMission.getAllMissionProgress();
|
||||||
|
Map<Integer, Integer> allMissionStatus = activityMission.getAllMissionStatus();
|
||||||
|
List<CommonProto.ActivityInfo.MissionInfo> missionInfos = new ArrayList<>(allMissionProgress.size());
|
||||||
|
for( Map.Entry<Integer, Integer> missionProgress : allMissionProgress.entrySet()){
|
||||||
|
Integer missionId = missionProgress.getKey();
|
||||||
|
Integer value = missionProgress.getValue();
|
||||||
|
missionInfos.add(CommonProto.ActivityInfo.MissionInfo.newBuilder().setMissionId(missionId).setProgress(value).setState(allMissionStatus.get(missionId)).build());
|
||||||
|
}
|
||||||
|
activityInfoList.add(CommonProto.ActivityInfo.newBuilder().setActivityId(activityId).addAllMission(missionInfos).setStartTime(startTime).setEndTime(endTime).build());
|
||||||
|
}
|
||||||
|
PlayerInfoProto.GetAllActivityResponse build = PlayerInfoProto.GetAllActivityResponse.newBuilder().addAllActivityInfo(activityInfoList).build();
|
||||||
|
MessageUtil.sendMessage(session,1,rewardResponseValue,build,true);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.ljsd.jieling.logic.activity;
|
||||||
|
|
||||||
|
public interface ActivityType {
|
||||||
|
|
||||||
|
int CLOSE_STATE = 0;
|
||||||
|
int OPEN_STATE =1;
|
||||||
|
int FINISH_STATE =2;
|
||||||
|
|
||||||
|
int OPEN_TYPE_TIME = 1; // 活动开启类型:绝对时间
|
||||||
|
int OPEN_TYPE_SERVER = 2; // 活动开启类型:开服时间
|
||||||
|
int OPEN_TYPE_ROLE = 3; // 活动开启类型:创角时间
|
||||||
|
|
||||||
|
|
||||||
|
int WILL_TAKE = 0; //未领取
|
||||||
|
int HAD_TAKED =1; //已领取
|
||||||
|
|
||||||
|
int OnlineReward =1; //在线奖励
|
||||||
|
int SevenLogin = 2; //七日登陆
|
||||||
|
int ChapterReward = 3; //七日登陆
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.ljsd.jieling.logic.dao;
|
||||||
|
|
||||||
|
import com.ljsd.common.mogodb.MongoBase;
|
||||||
|
import com.ljsd.jieling.logic.activity.ActivityType;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public class ActivityManager extends MongoBase {
|
||||||
|
private Map<Integer,Integer> activityState = new ConcurrentHashMap<>(); //活动状态
|
||||||
|
private Map<Integer,ActivityMission> activityMissionMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public void updateActivityState(int activityId,int state){
|
||||||
|
updateString("activityState." + activityId,state);
|
||||||
|
activityState.put(activityId,state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initAllActivityMission(int activityId){
|
||||||
|
if(activityMissionMap.containsKey(activityId)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ActivityMission activityMission = new ActivityMission();
|
||||||
|
activityMission.initMissionInfo(activityId);
|
||||||
|
activityMission.init(getRootId(),getMongoKey()+".activityMissionMap." + activityId);
|
||||||
|
activityMissionMap.put(activityId,activityMission);
|
||||||
|
updateString("activityState." + activityId, ActivityType.OPEN_STATE);
|
||||||
|
updateString("activityMissionMap." + activityId,activityMission);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Integer, Integer> getActivityState() {
|
||||||
|
return activityState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Integer, ActivityMission> getActivityMissionMap() {
|
||||||
|
return activityMissionMap;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.ljsd.jieling.logic.dao;
|
||||||
|
|
||||||
|
import com.ljsd.common.mogodb.MongoBase;
|
||||||
|
import com.ljsd.jieling.config.SActivityRewardConfig;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public class ActivityMission extends MongoBase {
|
||||||
|
|
||||||
|
private Map<Integer,Integer> allMissionProgress = new ConcurrentHashMap<>();
|
||||||
|
private Map<Integer,Integer> allMissionStatus = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public void updateMissionStatus(int missionId,int status){
|
||||||
|
updateString("allMissionStatus."+missionId,status);
|
||||||
|
allMissionStatus.put(missionId,status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initMissionInfo(int activityId){
|
||||||
|
List<SActivityRewardConfig> sActivityRewardConfigs = SActivityRewardConfig.getsActivityRewardConfigByActivityId(activityId);
|
||||||
|
for(SActivityRewardConfig sActivityRewardConfig : sActivityRewardConfigs){
|
||||||
|
allMissionStatus.put(sActivityRewardConfig.getId(), 0);
|
||||||
|
allMissionProgress.put(sActivityRewardConfig.getId(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Integer, Integer> getAllMissionProgress() {
|
||||||
|
return allMissionProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Integer, Integer> getAllMissionStatus() {
|
||||||
|
return allMissionStatus;
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,7 +45,7 @@ public class HeroManager extends MongoBase {
|
||||||
|
|
||||||
public void removeHero(String heroId) {
|
public void removeHero(String heroId) {
|
||||||
if (heroMap.containsKey(heroId)){
|
if (heroMap.containsKey(heroId)){
|
||||||
removeString("heroMap." + heroId);
|
removeString(getMongoKey()+".heroMap." + heroId);
|
||||||
heroMap.remove(heroId);
|
heroMap.remove(heroId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@ public class User {
|
||||||
|
|
||||||
private LevelDifficultyManager levelDifficultyManager; // 关卡信息
|
private LevelDifficultyManager levelDifficultyManager; // 关卡信息
|
||||||
|
|
||||||
|
private ActivityManager activityManager;
|
||||||
|
|
||||||
//构造函数必须要声明,否则从mongodb读出来反编译成类不通过
|
//构造函数必须要声明,否则从mongodb读出来反编译成类不通过
|
||||||
public User(){
|
public User(){
|
||||||
}
|
}
|
||||||
|
@ -51,6 +53,7 @@ public class User {
|
||||||
this.pokemonManager = new PokemonManager();
|
this.pokemonManager = new PokemonManager();
|
||||||
this.workShopController = new WorkShopController();
|
this.workShopController = new WorkShopController();
|
||||||
this.levelDifficultyManager = new LevelDifficultyManager();
|
this.levelDifficultyManager = new LevelDifficultyManager();
|
||||||
|
this.activityManager = new ActivityManager();
|
||||||
|
|
||||||
//綁定关系
|
//綁定关系
|
||||||
this.playerManager.init(id, MongoKey.playerManager);
|
this.playerManager.init(id, MongoKey.playerManager);
|
||||||
|
@ -64,6 +67,7 @@ public class User {
|
||||||
this.pokemonManager.init(id, MongoKey.pokemonManager);
|
this.pokemonManager.init(id, MongoKey.pokemonManager);
|
||||||
this.workShopController.init(id, MongoKey.workShopController);
|
this.workShopController.init(id, MongoKey.workShopController);
|
||||||
this.levelDifficultyManager.init(id, MongoKey.levelDifficultyManager);
|
this.levelDifficultyManager.init(id, MongoKey.levelDifficultyManager);
|
||||||
|
this.activityManager.init(id, MongoKey.activityManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -149,4 +153,8 @@ public class User {
|
||||||
public void setLevelDifficultyManager(LevelDifficultyManager levelDifficultyManager) {
|
public void setLevelDifficultyManager(LevelDifficultyManager levelDifficultyManager) {
|
||||||
this.levelDifficultyManager = levelDifficultyManager;
|
this.levelDifficultyManager = levelDifficultyManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActivityManager getActivityManager() {
|
||||||
|
return activityManager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -848,7 +848,7 @@ public class HeroLogic {
|
||||||
|
|
||||||
hero.updateMutliEquipPositionMap(equipInfoTmp);
|
hero.updateMutliEquipPositionMap(equipInfoTmp);
|
||||||
|
|
||||||
LOGGER.info("the heroTid={},the force={}",hero.getTemplateId(),calHeoForce(user,hero));
|
// LOGGER.info("the heroTid={},the force={}",hero.getTemplateId(),calHeoForce(user,hero));
|
||||||
|
|
||||||
//发送成功消息
|
//发送成功消息
|
||||||
MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.EQUIP_WEAR_RESPONSE_VALUE,null,true);
|
MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.EQUIP_WEAR_RESPONSE_VALUE,null,true);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ljsd.jieling.thread;
|
package com.ljsd.jieling.thread;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.thread.task.MinuteTask;
|
||||||
import com.ljsd.jieling.thread.task.PlatConfigureTask;
|
import com.ljsd.jieling.thread.task.PlatConfigureTask;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -63,6 +64,7 @@ public class ThreadManager {
|
||||||
|
|
||||||
// testTask 已秒为单位 延迟10s, 间隔30s为周期执行
|
// testTask 已秒为单位 延迟10s, 间隔30s为周期执行
|
||||||
scheduledExecutor.scheduleAtFixedRate(platConfigureTask, 10, PlatConfigureTask.SLEEP_INTEVAL_TIME, TimeUnit.SECONDS);
|
scheduledExecutor.scheduleAtFixedRate(platConfigureTask, 10, PlatConfigureTask.SLEEP_INTEVAL_TIME, TimeUnit.SECONDS);
|
||||||
|
scheduledExecutor.scheduleAtFixedRate(new MinuteTask(), 10, 60, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScheduledThreadPoolExecutor getScheduledExecutor() {
|
public ScheduledThreadPoolExecutor getScheduledExecutor() {
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.ljsd.jieling.thread.task;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class MinuteTask extends Thread {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(MinuteTask.class);
|
||||||
|
|
||||||
|
public MinuteTask(){
|
||||||
|
this.setName("MinuteTask");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ActivityLogic.getInstance().checkActiviyStatus();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1143,4 +1143,9 @@ public class TimeUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long parseTimeToMiles(String date, String datePattern) throws ParseException {
|
||||||
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(datePattern);
|
||||||
|
return simpleDateFormat.parse(date).getTime();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue