活动:战力冲刺
parent
0d5a19339b
commit
54f6e06a74
|
@ -382,6 +382,11 @@ public class RedisKey {
|
|||
* key:
|
||||
*/
|
||||
public final static String FOUR_CHALLENGE_TIER_RANK = "FOUR_CHALLENGE_TIER_RANK";
|
||||
/**
|
||||
* 战力冲刺排行榜
|
||||
* key:
|
||||
*/
|
||||
public final static String POWER_RICE_RANK = "POWER_RICE_RANK";
|
||||
|
||||
/**
|
||||
* 助战
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.ljsd.jieling.logic.activity.event.*;
|
|||
import com.ljsd.jieling.logic.dao.PlayerManager;
|
||||
import com.ljsd.jieling.logic.dao.SecretBoxManager;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.GlobalSystemControl;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||
import com.ljsd.jieling.logic.mission.event.MissionEventDistributor;
|
||||
|
@ -209,6 +210,21 @@ public class ActivityLogic implements IEventHandler{
|
|||
openActivityIds.remove(sGlobalActivity.getId());
|
||||
}
|
||||
AbstractActivity abstractActivity = ActivityTypeEnum.getActicityType(sGlobalActivity.getId());
|
||||
if (null == abstractActivity) {
|
||||
continue;
|
||||
}
|
||||
//活動結束 預約的展示期間
|
||||
if(now<gapEndTime){
|
||||
GlobalSystemControl globalSystemControl = GlobalSystemControl.getGlobalSystemControl();
|
||||
HashMap<Integer, Long> activityPreMap = globalSystemControl.getActivityPreEnd();
|
||||
if(activityPreMap.containsKey(sGlobalActivity.getId())){
|
||||
if(activityPreMap.get(sGlobalActivity.getId())>endTime && activityPreMap.get(sGlobalActivity.getId())<gapEndTime){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
abstractActivity.onActivityPreEnd();
|
||||
}
|
||||
|
||||
if (null == abstractActivity) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -115,6 +115,7 @@ public interface ActivityType {
|
|||
int HERO_UP_STAR_ACTIVITY=94;//限时升星活动
|
||||
int fESTIVAL_LOGIN_ACTIVITY=95;//节日登录活动
|
||||
int EXPLORE_EXPECT_ACTIVITY=96;//探索达人活动
|
||||
int POWER_RICE_ACTIVITY = 97;//战力冲刺
|
||||
|
||||
|
||||
int NEW_GENERAL_ATTACK = 200;//新将来袭
|
||||
|
|
|
@ -105,7 +105,8 @@ public enum ActivityTypeEnum {
|
|||
HERO_UP_STAR_ACTIVITY(ActivityType.HERO_UP_STAR_ACTIVITY,HeroUpStarActivity::new),
|
||||
DAILY_SPECIAL(ActivityType.DAILY_SPECIAL,DefaultEmptyActivity::new),//每日特惠
|
||||
fESTIVAL_LOGIN_ACTIVITY(ActivityType.fESTIVAL_LOGIN_ACTIVITY,NewEightActivity::new),//节日登录活动
|
||||
EXPLORE_EXPECT_ACTIVITY(ActivityType.EXPLORE_EXPECT_ACTIVITY,ExploreExpectActivity::new)
|
||||
EXPLORE_EXPECT_ACTIVITY(ActivityType.EXPLORE_EXPECT_ACTIVITY,ExploreExpectActivity::new),
|
||||
POWER_RICE_ACTIVITY(ActivityType.POWER_RICE_ACTIVITY,PowerRiceActivity::new)//战力冲刺
|
||||
;
|
||||
|
||||
private int type;
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
package com.ljsd.jieling.logic.activity;
|
||||
|
||||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.jbean.ActivityProgressInfo;
|
||||
import com.ljsd.jieling.logic.activity.event.IEvent;
|
||||
import com.ljsd.jieling.logic.dao.TeamEnum;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.GlobalSystemControl;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||
import com.ljsd.jieling.logic.rank.RankContext;
|
||||
import com.ljsd.jieling.logic.rank.RankEnum;
|
||||
import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import config.SActivityRankingReward;
|
||||
import config.SActivityRewardConfig;
|
||||
import config.SErrorCodeEerverConfig;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class PowerRiceActivity extends AbstractActivity{
|
||||
|
||||
|
||||
public PowerRiceActivity(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(IEvent event) throws Exception{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStart() throws Exception {
|
||||
//初始化 排行榜
|
||||
AbstractRank rank = RankContext.getRankEnum(RankEnum.FORCE_CURR_RANK.getType());
|
||||
AbstractRank powerRank = RankContext.getRankEnum(RankEnum.POWER_RICE_RANK.getType());
|
||||
//取出实时排行榜数据 存到另一个redis字段中
|
||||
Set<ZSetOperations.TypedTuple<String>> rankInfos = rank.getRankByKey("", 0,-1);
|
||||
for(ZSetOperations.TypedTuple<String> rankInfo:rankInfos){
|
||||
if(powerRank.getScoreById(Integer.parseInt(rankInfo.getValue()),"") == 0){
|
||||
powerRank.addRank(Integer.parseInt(rankInfo.getValue()),"",rankInfo.getScore());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* @Override
|
||||
void updateProgress(ActivityMission activityMission, int count){
|
||||
|
||||
|
||||
}*/
|
||||
@Override
|
||||
boolean takeRewardsProcess(ISession session, SActivityRewardConfig sActivityRewardConfig, ActivityProgressInfo activityProgressInfo) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
int force = HeroLogic.getInstance().calTeamTotalForce(user, TeamEnum.FORMATION_NORMAL.getTeamId(), false);
|
||||
int[][] values = sActivityRewardConfig.getValues();
|
||||
return force >= values[0][0];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 活动结束后 固定排行榜 发奖
|
||||
*/
|
||||
@Override
|
||||
public void onActivityEnd() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityPreEnd() throws Exception {
|
||||
AbstractRank powerRank = RankContext.getRankEnum(RankEnum.POWER_RICE_RANK.getType());
|
||||
Set<ZSetOperations.TypedTuple<String>> rankInfos = powerRank.getRankByKey("", 0,-1);
|
||||
|
||||
List<SActivityRankingReward> sActivityRankingReward = SActivityRankingReward.getsActivityRankingRewardMapByActivityId(id);
|
||||
if(sActivityRankingReward == null || sActivityRankingReward.size() ==0 ){
|
||||
return;
|
||||
}
|
||||
int index = 1;
|
||||
for(ZSetOperations.TypedTuple<String> rankInfo:rankInfos){
|
||||
String title = SErrorCodeEerverConfig.getI18NMessage("battlecapacityrank_mail_title");
|
||||
String content = SErrorCodeEerverConfig.getFormatMessage("battlecapacityrank_mail_txt", new Object[]{index});
|
||||
final int rankIndex = index;
|
||||
SActivityRankingReward activityReward =sActivityRankingReward.stream().filter(n->rankIndex>=n.getMinRank() && rankIndex>=n.getMaxRank()).findFirst().orElse(null);
|
||||
if(activityReward == null){
|
||||
continue;
|
||||
}
|
||||
MailLogic.getInstance().sendMail(Integer.parseInt(rankInfo.getValue()), title, content, StringUtil.parseArrayToString(activityReward.getRankingReward()), TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
||||
index++;
|
||||
}
|
||||
GlobalSystemControl globalSystemControl = GlobalSystemControl.getGlobalSystemControl();
|
||||
//HashMap<Integer, Integer> activityPreMap = globalSystemControl.getActivityPreEnd();
|
||||
//activityPreMap.put(id,TimeUtils.nowInt());
|
||||
globalSystemControl.addActivityPreEnd(id,TimeUtils.now());
|
||||
GlobalSystemControl.save(globalSystemControl);
|
||||
}
|
||||
}
|
|
@ -24,6 +24,8 @@ public class GlobalSystemControl {
|
|||
private int questId;//本服开启的问卷id
|
||||
private HashMap<Integer,Integer> activityOpenValue= new HashMap<>();
|
||||
|
||||
private HashMap<Integer,Long> activityPreEnd= new HashMap<>();//<活動id,執行日期>
|
||||
|
||||
@Transient
|
||||
private boolean dirty = false;
|
||||
|
||||
|
@ -62,6 +64,15 @@ public class GlobalSystemControl {
|
|||
this.activityOpenValue = activityOpenValue;
|
||||
}
|
||||
|
||||
public HashMap<Integer, Long> getActivityPreEnd() {
|
||||
return activityPreEnd;
|
||||
}
|
||||
|
||||
public void addActivityPreEnd(int key,Long val) {
|
||||
this.dirty = true;
|
||||
this.activityPreEnd.put(key,val);
|
||||
}
|
||||
|
||||
public Question getQuestionMap(String key) {
|
||||
return questionMap.get(key);
|
||||
}
|
||||
|
|
|
@ -45,6 +45,9 @@ public enum RankEnum {
|
|||
TA_SUI_LING_XIAO_RANK(31,RedisKey.TA_SUI_LING_XIAO_RANK,TaSuiLingXiaoRank::new,false),
|
||||
|
||||
FOUR_CHALLENGE_TIER_RANK(38,RedisKey.FOUR_CHALLENGE_TIER_RANK,SituationRank::new,false),//四灵试炼排行榜,param1:层数 param2:无 param3:无
|
||||
POWER_RICE_RANK(42,RedisKey.POWER_RICE_RANK,PowerRiceRank::new,false),//战力冲刺排行榜
|
||||
|
||||
|
||||
|
||||
// 以下为跨服排行榜
|
||||
WARLD_DIS_ARENA_RANK(28,RedisKey.WARLD_DIS_ARENA_RANK,ArenaRank::new,true),//世界服排行
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
package com.ljsd.jieling.logic.rank.rankImpl;
|
||||
|
||||
|
||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
import com.ljsd.jieling.logic.activity.ActivityType;
|
||||
import com.ljsd.jieling.logic.activity.IEventHandler;
|
||||
import com.ljsd.jieling.logic.activity.event.IEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.activity.event.UserMainTeamForceEvent;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import config.SGlobalActivity;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PowerRiceRank extends AbstractRank implements IEventHandler {
|
||||
|
||||
public PowerRiceRank(int type, String redisKey) {
|
||||
super(type, redisKey);
|
||||
Poster.getPoster().listenEvent(this, UserMainTeamForceEvent.class);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long[] getDataByScore(Double score) {
|
||||
return new long[]{score.longValue()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getScore(double... data) {
|
||||
return data[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(IEvent event) throws Exception {
|
||||
//固定排名
|
||||
List<SGlobalActivity> powerRice = SGlobalActivity.getsGlobalActivityMapByType(ActivityType.POWER_RICE_ACTIVITY);
|
||||
int activityId = 0;
|
||||
for (SGlobalActivity activity : powerRice) {
|
||||
if (ActivityLogic.getInstance().checkGlobleActivityOpen(activity.getId())) {
|
||||
activityId = activity.getId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (activityId == 0) {
|
||||
return;
|
||||
}
|
||||
//判斷是否在展示期
|
||||
Map<Integer, SGlobalActivity> sGlobalActivityMap = SGlobalActivity.getsGlobalActivityMap();
|
||||
SGlobalActivity sGlobalActivity = sGlobalActivityMap.get(activityId);
|
||||
if (sGlobalActivity == null) {
|
||||
return;
|
||||
}
|
||||
long[] startAndEndTime = ActivityLogic.getStartAndEndTime(null, activityId);
|
||||
if (TimeUtils.now() > startAndEndTime[0] && TimeUtils.now() < startAndEndTime[1]) {
|
||||
if (event instanceof UserMainTeamForceEvent) {
|
||||
int uid = ((UserMainTeamForceEvent) event).getUid();
|
||||
User user = UserManager.getUserNotCache(uid);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
int currentForce = HeroLogic.getInstance().calTeamTotalForce(user, 1, false);
|
||||
int historyForce = (int) getScoreById(uid, "");
|
||||
if (currentForce > historyForce) {
|
||||
addRank(uid, "", currentForce);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue