送无限抽活动
parent
5aee8e8d6b
commit
73a0b91d3e
|
@ -1726,6 +1726,21 @@ public class TimeUtils {
|
||||||
calendar.set(Calendar.MILLISECOND, 0);
|
calendar.set(Calendar.MILLISECOND, 0);
|
||||||
return calendar.getTimeInMillis();
|
return calendar.getTimeInMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getZeroInt(int time){
|
||||||
|
return (int) (getZeroLong(time*1000)/1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getZeroLong(long time){
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTimeInMillis(time);
|
||||||
|
calendar.set(Calendar.SECOND, 0);
|
||||||
|
calendar.set(Calendar.MINUTE, 0);
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
calendar.set(Calendar.MILLISECOND, 0);
|
||||||
|
return calendar.getTimeInMillis();
|
||||||
|
}
|
||||||
|
|
||||||
//周几的零点
|
//周几的零点
|
||||||
public static long getWeekZero(int weekDay){
|
public static long getWeekZero(int weekDay){
|
||||||
if(weekDay ==7){
|
if(weekDay ==7){
|
||||||
|
|
|
@ -138,4 +138,6 @@ public interface ActivityType {
|
||||||
int WEEK_CARD = 102;//月卡
|
int WEEK_CARD = 102;//月卡
|
||||||
|
|
||||||
int ALL_PEOPLE_WELFARE = 105;//全民福利
|
int ALL_PEOPLE_WELFARE = 105;//全民福利
|
||||||
|
|
||||||
|
int GIVE_ENDLESS_DRAW = 106;//送无限抽
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,7 @@ public enum ActivityTypeEnum {
|
||||||
WEEK_CARD(ActivityType.WEEK_CARD,WeekCardActivity::new),//月卡
|
WEEK_CARD(ActivityType.WEEK_CARD,WeekCardActivity::new),//月卡
|
||||||
// bt
|
// bt
|
||||||
ALL_PEOPLE_WELFARE(ActivityType.ALL_PEOPLE_WELFARE,AllPeopleWelfareActivity::new),//全民福利
|
ALL_PEOPLE_WELFARE(ActivityType.ALL_PEOPLE_WELFARE,AllPeopleWelfareActivity::new),//全民福利
|
||||||
|
GIVE_ENDLESS_DRAW(ActivityType.GIVE_ENDLESS_DRAW, GiveEndlessDrawActivity::new),//送无限抽
|
||||||
;
|
;
|
||||||
|
|
||||||
private int type;
|
private int type;
|
||||||
|
|
|
@ -0,0 +1,154 @@
|
||||||
|
package com.ljsd.jieling.logic.activity;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.exception.ErrorCode;
|
||||||
|
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||||
|
import com.ljsd.jieling.globals.BIReason;
|
||||||
|
import com.ljsd.jieling.jbean.ActivityMission;
|
||||||
|
import com.ljsd.jieling.jbean.ActivityProgressInfo;
|
||||||
|
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.util.ItemUtil;
|
||||||
|
import com.ljsd.jieling.util.MessageUtil;
|
||||||
|
import config.SActivityRewardConfig;
|
||||||
|
import config.SMainLevelConfig;
|
||||||
|
import rpc.protocols.CommonProto;
|
||||||
|
import rpc.protocols.PlayerInfoProto;
|
||||||
|
import util.TimeUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hj
|
||||||
|
* 送无限抽活动-bt版
|
||||||
|
* 2022-9-6
|
||||||
|
*/
|
||||||
|
public class GiveEndlessDrawActivity extends AbstractActivity {
|
||||||
|
|
||||||
|
GiveEndlessDrawActivity(int id) {
|
||||||
|
super(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initActivity(User user) throws Exception {
|
||||||
|
// 活动信息初始化
|
||||||
|
ActivityMission mission = new ActivityMission();
|
||||||
|
ActivityLogic.getInstance().initOtherMission(mission, new ArrayList<>());
|
||||||
|
user.getActivityManager().getActivityMissionMap().put(id, mission);
|
||||||
|
LOGGER.info("送无限抽活动-bt版...uid={},activityId={}",user.getId(), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CommonProto.ActivityInfo.MissionInfo> getAllMissInfo(User user,ActivityMission activityMission, Set<Integer> filter) {
|
||||||
|
if (activityMission == null){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
// 库里存储的活动档位信息
|
||||||
|
Map<Integer, ActivityProgressInfo> progressInfoMap = activityMission.getActivityMissionMap();
|
||||||
|
// 策划表的配置
|
||||||
|
List<SActivityRewardConfig> rewardConfigList = SActivityRewardConfig.getsActivityRewardConfigByActivityId(id);
|
||||||
|
// 返回对象
|
||||||
|
List<CommonProto.ActivityInfo.MissionInfo> missionInfos = new ArrayList<>(rewardConfigList.size());
|
||||||
|
|
||||||
|
for (SActivityRewardConfig config : rewardConfigList) {
|
||||||
|
// 参数初始化
|
||||||
|
int missionId = config.getId();
|
||||||
|
ActivityProgressInfo info = progressInfoMap.get(missionId);
|
||||||
|
int state = getState(user,config,info);
|
||||||
|
// 封装proto并返回
|
||||||
|
CommonProto.ActivityInfo.MissionInfo build = CommonProto.ActivityInfo.MissionInfo.newBuilder()
|
||||||
|
.setMissionId(missionId)
|
||||||
|
.setProgress(0)
|
||||||
|
.setState(state)
|
||||||
|
.build();
|
||||||
|
missionInfos.add(build);
|
||||||
|
}
|
||||||
|
return missionInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取状态
|
||||||
|
* @param progress
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private int getState(User user, SActivityRewardConfig reward, ActivityProgressInfo progress){
|
||||||
|
// 当前关卡id
|
||||||
|
int mainLvId = user.getMainLevelManager().getFightId();
|
||||||
|
// 任务类型,0:一次性奖励,1:每日奖励
|
||||||
|
int type = reward.getValues()[0][0];
|
||||||
|
// 任务条件(关卡id)
|
||||||
|
int valueId = reward.getValues()[1][0];
|
||||||
|
int state = 0;
|
||||||
|
// 已领取
|
||||||
|
if (progress != null && progress.getState() == 2){
|
||||||
|
int time = TimeUtils.getZeroInt(progress.getProgrss());
|
||||||
|
int now = TimeUtils.getZeroInt(TimeUtils.nowInt());
|
||||||
|
// 每日领取,并且时间条件满足
|
||||||
|
if (type == 1 && now > time){
|
||||||
|
state = 1;
|
||||||
|
}else {
|
||||||
|
state = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 首次领取
|
||||||
|
else {
|
||||||
|
SMainLevelConfig value = SMainLevelConfig.config.get(valueId);
|
||||||
|
SMainLevelConfig mainLv = SMainLevelConfig.config.get(mainLvId);
|
||||||
|
if (value != null && mainLv != null){
|
||||||
|
//关卡满足
|
||||||
|
if (mainLv.getVirtureId() >= value.getVirtureId()){
|
||||||
|
state = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 领取奖励
|
||||||
|
* @param session
|
||||||
|
* @param missionId
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean takeReward(ISession session, int missionId) throws Exception {
|
||||||
|
User user = UserManager.getUser(session.getUid());
|
||||||
|
// activity check
|
||||||
|
ActivityMission mission = user.getActivityManager().getActivityMissionMap().get(id);
|
||||||
|
if (mission == null){
|
||||||
|
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"活动信息不存在:"+id);
|
||||||
|
}
|
||||||
|
|
||||||
|
SActivityRewardConfig rewardConfig = SActivityRewardConfig.getsActivityRewardConfigByMissionId(missionId);
|
||||||
|
ActivityProgressInfo progressInfo = mission.getActivityMissionMap().get(missionId);
|
||||||
|
int state = getState(user, rewardConfig, progressInfo);
|
||||||
|
if (state != 1){
|
||||||
|
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"领取条件不满足,活动id ==> 挡位id:"+id+"==>"+missionId);
|
||||||
|
}
|
||||||
|
// reward
|
||||||
|
CommonProto.Drop.Builder drop = ItemUtil.drop(user, rewardConfig.getReward(), BIReason.TAKE_ACTIVITY_REWARD);
|
||||||
|
// 更新数据库
|
||||||
|
ActivityProgressInfo info = new ActivityProgressInfo();
|
||||||
|
info.setState(2);
|
||||||
|
info.setProgrss(TimeUtils.nowInt());
|
||||||
|
mission.getActivityMissionMap().put(missionId,info);
|
||||||
|
|
||||||
|
PlayerInfoProto.TakeActivityRewardResponse build = PlayerInfoProto.TakeActivityRewardResponse.newBuilder().setDrop(drop).build();
|
||||||
|
MessageUtil.sendMessage(session, 1, rewardResponseValue, build, true);
|
||||||
|
// 状态推送
|
||||||
|
sendActivityProgress(session, mission, null);
|
||||||
|
// 打点上报
|
||||||
|
reportTakeActivityReward(user,rewardConfig.getReward(),missionId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkActivityMissionFinishAndTake(int uid, int activityId, ActivityMission activityMission) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -48,28 +48,53 @@ public class SMainLevelConfig implements BaseConfig {
|
||||||
|
|
||||||
private int storyId; // 大于 0 表示剧情关,无需战斗
|
private int storyId; // 大于 0 表示剧情关,无需战斗
|
||||||
|
|
||||||
public static Map<Integer, SMainLevelConfig> config;
|
/**
|
||||||
public static Map<Integer, SMainLevelConfig> sMainLevelConfigByVirtureIdMap;
|
* 默认map
|
||||||
public static Map<Integer,SMainLevelConfig> fightPreMap;
|
*/
|
||||||
|
public static Map<Integer, SMainLevelConfig> config = new HashMap<>();
|
||||||
|
|
||||||
|
private static Map<Integer, SMainLevelConfig> virtualMap = new HashMap<>();
|
||||||
|
/**
|
||||||
|
* key:下一层id
|
||||||
|
*/
|
||||||
|
public static Map<Integer,SMainLevelConfig> fightPreMap = new HashMap<>();
|
||||||
|
/**
|
||||||
|
* key:难度,key:id,value:对象
|
||||||
|
*/
|
||||||
|
private static Map<Integer, Map<Integer, SMainLevelConfig>> difficultyMap = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
Map<Integer, SMainLevelConfig> configTmp = STableManager.getConfig(SMainLevelConfig.class);
|
Map<Integer, SMainLevelConfig> configTmp = STableManager.getConfig(SMainLevelConfig.class);
|
||||||
Map<Integer, SMainLevelConfig> SMainLevelConfigByVirtureIdMapTmp =new HashMap<>();
|
Map<Integer, SMainLevelConfig> SMainLevelConfigByVirtureIdMapTmp =new HashMap<>();
|
||||||
Map<Integer, SMainLevelConfig> fightPreMapTmp =new HashMap<>();
|
Map<Integer, SMainLevelConfig> fightPreMapTmp =new HashMap<>();
|
||||||
|
Map<Integer, Map<Integer, SMainLevelConfig>> mapByDifficulty = new HashMap<>();
|
||||||
for(SMainLevelConfig sMainLevelConfig : configTmp.values()){
|
for(SMainLevelConfig sMainLevelConfig : configTmp.values()){
|
||||||
int id = sMainLevelConfig.getId();
|
int id = sMainLevelConfig.getId();
|
||||||
sMainLevelConfig.setVirtureId(10_000_000*(id%10) + id);
|
sMainLevelConfig.setVirtureId(10_000_000*(id%10) + id);
|
||||||
SMainLevelConfigByVirtureIdMapTmp.put(sMainLevelConfig.getVirtureId(),sMainLevelConfig);
|
SMainLevelConfigByVirtureIdMapTmp.put(sMainLevelConfig.getVirtureId(),sMainLevelConfig);
|
||||||
|
|
||||||
fightPreMapTmp.put(sMainLevelConfig.getNextLevel(),sMainLevelConfig);
|
fightPreMapTmp.put(sMainLevelConfig.getNextLevel(),sMainLevelConfig);
|
||||||
|
|
||||||
|
Map<Integer, SMainLevelConfig> byDifficultyOrDefault = mapByDifficulty.getOrDefault(sMainLevelConfig.getDifficulty(), new HashMap<>());
|
||||||
|
byDifficultyOrDefault.put(sMainLevelConfig.getId(), sMainLevelConfig);
|
||||||
|
mapByDifficulty.put(sMainLevelConfig.getDifficulty(), byDifficultyOrDefault);
|
||||||
|
|
||||||
}
|
}
|
||||||
config=configTmp;
|
config = configTmp;
|
||||||
sMainLevelConfigByVirtureIdMap=SMainLevelConfigByVirtureIdMapTmp;
|
virtualMap = SMainLevelConfigByVirtureIdMapTmp;
|
||||||
fightPreMap=fightPreMapTmp;
|
fightPreMap = fightPreMapTmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Map<Integer, Map<Integer, SMainLevelConfig>> getDifficultyMap() {
|
||||||
|
return difficultyMap;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean biggerThanFight(int soureFight,int targetFight){
|
public static Map<Integer, SMainLevelConfig> getVirtualMap() {
|
||||||
|
return virtualMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean biggerThanFight(int soureFight, int targetFight){
|
||||||
if(targetFight==0){return true;}
|
if(targetFight==0){return true;}
|
||||||
SMainLevelConfig mineLevelConfig = SMainLevelConfig.config.get(soureFight);
|
SMainLevelConfig mineLevelConfig = SMainLevelConfig.config.get(soureFight);
|
||||||
SMainLevelConfig otherLevelConfig = SMainLevelConfig.config.get(targetFight);
|
SMainLevelConfig otherLevelConfig = SMainLevelConfig.config.get(targetFight);
|
||||||
|
|
Loading…
Reference in New Issue