master_ob2
parent
513b3b68e1
commit
242799ffe2
|
|
@ -9,7 +9,7 @@ import rpc.protocols.PlayerInfoProto;
|
|||
public class GetGemNewInfoHandler extends BaseHandler<PlayerInfoProto.GemNewDrawRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.GemNewDrawRequest;
|
||||
return MessageTypeProto.MessageType.GemNewInfoRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -136,6 +136,9 @@ public interface ActivityType {
|
|||
int TIAN_JIANG_GIFT = 120;//天降礼包
|
||||
int DA_NAO_TIAN_GONG = 121;//大闹天宫
|
||||
|
||||
int NOVICE_GEM_CHEST = 123;//初级宝石宝箱
|
||||
int ADVANCED_GEM_CHEST = 124;//高级宝石宝箱
|
||||
|
||||
int LINGLONG_BAOJING_TASK = 20014;//玲珑宝镜任务
|
||||
|
||||
//***************************************bt活动=====================================//
|
||||
|
|
|
|||
|
|
@ -117,9 +117,11 @@ public enum ActivityTypeEnum {
|
|||
DRAW_LV_CHEST(ActivityType.DRAW_HERO_LV_CHEST,DrawLvChestActivity::new),//抽卡等级宝箱
|
||||
FABAO_BOOK_REWARD(ActivityType.FABAO_BOOK_REWARD,FabaoBookRewardActivity::new),//法宝图鉴宝箱
|
||||
DRAW_FABAO_LV_CHEST(ActivityType.DRAW_FABAO_LV_CHEST,DrawLvChestActivity::new),//抽卡等级宝箱
|
||||
TIAN_JIANG_GIFT(ActivityType.TIAN_JIANG_GIFT,DefaultEmptyActivity::new),//抽卡等级宝箱
|
||||
TIAN_JIANG_GIFT(ActivityType.TIAN_JIANG_GIFT,DefaultEmptyActivity::new),//天降礼包
|
||||
DA_NAO_TIAN_GONG(ActivityType.DA_NAO_TIAN_GONG, ExpeditionActivity::new),//大闹天宫
|
||||
LINGLONG_BAOJING_TASK(ActivityType.LINGLONG_BAOJING_TASK, DefaultEmptyActivity::new),//玲珑宝镜任务
|
||||
NOVICE_GEM_CHEST(ActivityType.NOVICE_GEM_CHEST, GemChestActivity::new),//初级命石宝箱
|
||||
ADVANCED_GEM_CHEST(ActivityType.ADVANCED_GEM_CHEST, GemChestActivity::new),//高级命石宝箱
|
||||
|
||||
/****************************************************** bt **********************************************************/
|
||||
BRUSH_PRIVILEGE(ActivityType.BRUSH_PRIVILEGE, BrushPrivilegeActivity::new),//刷充特权
|
||||
|
|
|
|||
|
|
@ -0,0 +1,128 @@
|
|||
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.SGemLotteryConfig;
|
||||
import config.SGlobalActivity;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author hj
|
||||
* 超值基金活动新
|
||||
* 2022-1-24
|
||||
*/
|
||||
public class GemChestActivity extends AbstractActivity {
|
||||
|
||||
GemChestActivity(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("命石等级宝箱...uid={} activityId={}",user.getId(), id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommonProto.ActivityInfo.MissionInfo> getAllMissInfo(User user, ActivityMission activityMission, Set<Integer> filter) {
|
||||
List<CommonProto.ActivityInfo.MissionInfo> missionInfo = new ArrayList<>();
|
||||
SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(id);
|
||||
// 验证活动是否开启
|
||||
if (activityMission == null || activity == null){
|
||||
return missionInfo;
|
||||
}
|
||||
Map<Integer, SGemLotteryConfig> lotteryConfigMap = SGemLotteryConfig.libraryMap.get(activity.getLotteryType());
|
||||
if (lotteryConfigMap == null){
|
||||
return missionInfo;
|
||||
}
|
||||
Integer count = user.getPlayerInfoManager().getGemDrawCountMap().getOrDefault(activity.getLotteryType(), 0);
|
||||
Map<Integer, ActivityProgressInfo> progressInfoMap = activityMission.getActivityMissionMap();
|
||||
for (SGemLotteryConfig config : lotteryConfigMap.values()) {
|
||||
int missionId = config.getId();
|
||||
Integer state = Optional.ofNullable(progressInfoMap.get(missionId)).map(ActivityProgressInfo::getState).orElse(0);
|
||||
// 封装proto并返回
|
||||
CommonProto.ActivityInfo.MissionInfo build = CommonProto.ActivityInfo.MissionInfo.newBuilder()
|
||||
.setMissionId(missionId)
|
||||
.setProgress(count)
|
||||
.setState(state)
|
||||
.build();
|
||||
missionInfo.add(build);
|
||||
}
|
||||
return missionInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean takeReward(ISession session, int missionId) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
// 开始校验数据正确性
|
||||
SGemLotteryConfig gemLotteryConfig = SGemLotteryConfig.map.get(missionId);
|
||||
if (gemLotteryConfig == null) {
|
||||
String format = MessageFormat.format("宝石等级宝箱退出,表数据错误,uid:{0},活动id:{1},档位id:{2}", user.getId(), id, missionId);
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
ActivityMission mission = user.getActivityManager().getActivityMissionMap().get(id);
|
||||
if (mission == null || mission.getActivityState() != ActivityType.OPEN_STATE){
|
||||
String format = MessageFormat.format("抽卡等级宝箱退出,活动数据未开启,uid:{0},活动id:{1}", user.getId(), id);
|
||||
throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN, format);
|
||||
}
|
||||
ActivityProgressInfo progressInfo = mission.getActivityMissionMap().get(missionId);
|
||||
if (progressInfo != null && progressInfo.getState() == ActivityType.HAD_TAKED) {
|
||||
String format = MessageFormat.format("抽卡等级宝箱退出,活动奖励已经领取,uid:{0},活动id:{1},档位id:{2}", user.getId(), id, missionId);
|
||||
throw new ErrorCodeException(ErrorCode.HAD_TAKE_REWARD, format);
|
||||
}
|
||||
if (!checkRewardsProcess(user,gemLotteryConfig)) {
|
||||
String format = MessageFormat.format("抽卡等级宝箱退出,未达到领取条件,uid:{0},活动id:{1},档位id:{2}", user.getId(), id, missionId);
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
|
||||
checkAndSetProgress(mission,missionId,ActivityType.HAD_TAKED);
|
||||
// reward
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, gemLotteryConfig.getReward(), BIReason.TAKE_ACTIVITY_REWARD);
|
||||
PlayerInfoProto.TakeActivityRewardResponse build = PlayerInfoProto.TakeActivityRewardResponse.newBuilder().setDrop(drop).build();
|
||||
MessageUtil.sendMessage(session, 1, rewardResponseValue, build, true);
|
||||
// 状态推送
|
||||
sendActivityProgress(session, null);
|
||||
// 打点上报
|
||||
reportTakeActivityReward(user,gemLotteryConfig.getReward(),missionId);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 领奖后更新奖励进度
|
||||
*/
|
||||
public void checkAndSetProgress(ActivityMission activityMission, int missionId, int state) {
|
||||
ActivityProgressInfo progressInfo = new ActivityProgressInfo();
|
||||
progressInfo.setState(state);
|
||||
activityMission.getActivityMissionMap().put(missionId, progressInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证奖励是否可以领取
|
||||
*/
|
||||
boolean checkRewardsProcess(User user, SGemLotteryConfig config) {
|
||||
SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(id);
|
||||
int count = user.getPlayerInfoManager().getGemDrawCountMap().getOrDefault(activity.getLotteryType(), 0);
|
||||
return count >= config.getLibraryNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkActivityMissionFinishAndTake(int uid, int activityId, ActivityMission activityMission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -24,13 +24,9 @@ public class NewEightActivity extends AbstractActivity {
|
|||
User user = UserManager.getUser(session.getUid());
|
||||
SGlobalActivity globalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
|
||||
if (globalActivity.getTime()==1){
|
||||
if(TimeUtils.getOverTimeCount(globalActivity.getStartTimeLong(),System.currentTimeMillis(),0)<sActivityRewardConfig.getValues()[0][0]-1){
|
||||
return false;
|
||||
}
|
||||
return TimeUtils.getOverTimeCount(globalActivity.getStartTimeLong(), System.currentTimeMillis(), 0) >= sActivityRewardConfig.getValues()[0][0] - 1;
|
||||
}else if (globalActivity.getTime()==2){
|
||||
if(TimeUtils.getOverTimeCount(user.getPlayerInfoManager().getCreateTime(),System.currentTimeMillis(),0)<sActivityRewardConfig.getValues()[0][0]-1){
|
||||
return false;
|
||||
}
|
||||
return TimeUtils.getOverTimeCount(user.getPlayerInfoManager().getCreateTime(), System.currentTimeMillis(), 0) >= sActivityRewardConfig.getValues()[0][0] - 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ public class EquipLogic {
|
|||
int num = user.getPlayerInfoManager().getGemDrawCountMap().getOrDefault(libraryId, 0);
|
||||
SGemLotteryConfig config = null;
|
||||
for (SGemLotteryConfig value : lotteryConfigMap.values()) {
|
||||
if (num > value.getLibraryNumber() && (config == null || value.getLibraryNumber() > config.getLibraryNumber())){
|
||||
if (num >= value.getLibraryNumber() && (config == null || value.getLibraryNumber() > config.getLibraryNumber())){
|
||||
config = value;
|
||||
}
|
||||
}
|
||||
|
|
@ -382,7 +382,7 @@ public class EquipLogic {
|
|||
int qualityResult = RandomUtils.nextInt(0, qualityTotalWeight);
|
||||
int indexOfQuality = 0;
|
||||
for (int i = 0; i < quality.length; i++) {
|
||||
if (qualityResult > quality[i]){
|
||||
if (quality[i] != 0 && qualityResult > quality[i]){
|
||||
indexOfQuality = i;
|
||||
}
|
||||
}
|
||||
|
|
@ -436,7 +436,7 @@ public class EquipLogic {
|
|||
User user = UserManager.getUser(iSession.getUid());
|
||||
List<CommonProto.GemNew> gemNews = CBean2Proto.toBeanGemNew(user);
|
||||
PlayerInfoProto.GemNewInfoResponse.Builder builder = PlayerInfoProto.GemNewInfoResponse.newBuilder().addAllGems(gemNews);
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GemNewInfoRequest_VALUE, builder.build(), true);
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GemNewInfoResponse_VALUE, builder.build(), true);
|
||||
}
|
||||
|
||||
public void sendGemNewIndication(ISession iSession) throws Exception {
|
||||
|
|
@ -457,7 +457,11 @@ public class EquipLogic {
|
|||
}
|
||||
|
||||
public int getDayLotteryCount(int uid, int libraryId){
|
||||
return RedisUtil.getInstence().getMapValue2(getDayLotteryKey(uid), String.valueOf(libraryId), Integer.class);
|
||||
Integer value = RedisUtil.getInstence().getMapValue2(getDayLotteryKey(uid), String.valueOf(libraryId), Integer.class);
|
||||
if (value == null){
|
||||
return 0;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,9 @@ public class ItemUtil {
|
|||
|
||||
public static void drop(User user, GemNew gemNew, CommonProto.Drop.Builder dropBuilder, int reason) throws Exception {
|
||||
ItemMap itemObj = new ItemMap();
|
||||
itemObj.getGemNewMap().put(gemNew.getId(), gemNew);
|
||||
Map<Integer, GemNew> map = new HashMap<>();
|
||||
map.put(gemNew.getId(), gemNew);
|
||||
itemObj.setGemNewMap(map);
|
||||
mapToAdd(user,itemObj,dropBuilder,reason);
|
||||
}
|
||||
|
||||
|
|
@ -1993,15 +1995,17 @@ public class ItemUtil {
|
|||
|
||||
int propertyId = gemConfigNew.getProperty();
|
||||
int dropProperty = dropGemNew.getAttribute().getOrDefault(propertyId, 0);
|
||||
int property = gemNew.getAttribute().getOrDefault(propertyId, 0);
|
||||
Integer property = Optional.ofNullable(gemNew).map(GemNew::getAttribute).orElse(new HashMap<>()).getOrDefault(propertyId, 0);
|
||||
|
||||
CommonProto.GemNew.Builder gemNewBuilder = CommonProto.GemNew.newBuilder();
|
||||
if (dropProperty > property){
|
||||
equipManager.putGemNewMap(type, dropGemNew);
|
||||
property = dropProperty;
|
||||
gemNewBuilder.setIsReplace(1);
|
||||
}
|
||||
|
||||
CommonProto.Attribute.Builder attrBuilder = CommonProto.Attribute.newBuilder().setId(propertyId).setValue(property);
|
||||
CommonProto.GemNew.Builder gemNewBuilder = CommonProto.GemNew.newBuilder().setId(dropGemNew.getId()).addAttr(attrBuilder);
|
||||
gemNewBuilder.setId(dropGemNew.getId()).addAttr(attrBuilder);
|
||||
dropBuilder.addGemNew(gemNewBuilder);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ public class SGemConfigNew implements BaseConfig {
|
|||
|
||||
private int[] proportion;
|
||||
|
||||
private int[] reward;
|
||||
|
||||
public static Map<Integer, Map<Integer, SGemConfigNew>> typeMap = new HashMap<>();
|
||||
|
||||
public static Map<Integer, SGemConfigNew> map = new HashMap<>();
|
||||
|
|
@ -70,9 +68,4 @@ public class SGemConfigNew implements BaseConfig {
|
|||
return proportion;
|
||||
}
|
||||
|
||||
public int[] getReward() {
|
||||
return reward;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -29,18 +29,23 @@ public class SGemLotteryConfig implements BaseConfig {
|
|||
|
||||
private int[] quality;
|
||||
|
||||
private int[][] reward;
|
||||
|
||||
public static Map<Integer, SGemLotteryConfig> map = new HashMap<>();
|
||||
|
||||
public static Map<Integer, Map<Integer, SGemLotteryConfig>> libraryMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
Map<Integer, SGemLotteryConfig> config = STableManager.getConfig(SGemLotteryConfig.class);
|
||||
Map<Integer, Map<Integer, SGemLotteryConfig>> map = new HashMap<>();
|
||||
for (SGemLotteryConfig value : config.values()) {
|
||||
Map<Integer, SGemLotteryConfig> map1 = map.getOrDefault(value.getLibrary(), new HashMap<>());
|
||||
map = STableManager.getConfig(SGemLotteryConfig.class);
|
||||
Map<Integer, Map<Integer, SGemLotteryConfig>> cloneLMap = new HashMap<>();
|
||||
for (SGemLotteryConfig value : map.values()) {
|
||||
Map<Integer, SGemLotteryConfig> map1 = cloneLMap.getOrDefault(value.getLibrary(), new HashMap<>());
|
||||
map1.put(value.getLevel(), value);
|
||||
map.put(value.getLibrary(), map1);
|
||||
cloneLMap.put(value.getLibrary(), map1);
|
||||
}
|
||||
libraryMap = map;
|
||||
libraryMap.clear();
|
||||
libraryMap = cloneLMap;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -84,5 +89,7 @@ public class SGemLotteryConfig implements BaseConfig {
|
|||
return quality;
|
||||
}
|
||||
|
||||
|
||||
public int[][] getReward() {
|
||||
return reward;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue