连续礼包优化
parent
c91b204bdc
commit
2717cdefec
|
@ -369,4 +369,7 @@ public interface BIReason {
|
|||
int WEEK_CARD_REWARD =1222;//周卡奖励
|
||||
|
||||
int FABAO_SOUL_UP_COST =1223;//法宝之魂升级消耗
|
||||
|
||||
int BUY_GOOD_ITEM_COST =1225;//妖晶购买道具消耗
|
||||
int BUY_GOOD_ITEM_GET =1226;//妖晶购买道具获得
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.ljsd.jieling.handler.goods;
|
||||
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.activity.event.SuperBoxEvent;
|
||||
import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic;
|
||||
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.SGoodsConfig;
|
||||
import manager.STableManager;
|
||||
import rpc.protocols.ActivityProto;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author hj
|
||||
*/
|
||||
public class BuyGoodsToItemHandler extends BaseHandler<ActivityProto.BuyGoodsToItemRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.BuyGoodsToItemRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, ActivityProto.BuyGoodsToItemRequest proto) throws Exception {
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
// 客户端参数
|
||||
int goodId = proto.getGoodId();
|
||||
int goodsNum = proto.getGoodsNum();
|
||||
if (goodsNum <= 0 || goodsNum > 999){
|
||||
throw new ErrorCodeException(ErrorCode.HERO_MAX);
|
||||
}
|
||||
// 配置表获取数据
|
||||
Map<Integer, SGoodsConfig> config = STableManager.getConfig(SGoodsConfig.class);
|
||||
SGoodsConfig goodsConfig = config.get(goodId);
|
||||
if (goodsConfig == null){
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL);
|
||||
}
|
||||
// 消耗道具
|
||||
boolean cost = ItemUtil.itemCost(user, new int[][]{goodsConfig.getPrice()},goodsNum,BIReason.BUY_GOOD_ITEM_COST,0);
|
||||
if (!cost){
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
// 领取奖励
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, goodsConfig.getGoods(), goodsNum, BIReason.BUY_GOOD_ITEM_GET);
|
||||
// 消息发送
|
||||
Poster.getPoster().dispatchEvent(new SuperBoxEvent(user.getId(),goodId,goodsNum));
|
||||
// 返回
|
||||
ActivityProto.BuyGoodsToItemResponse build = ActivityProto.BuyGoodsToItemResponse.newBuilder().setDrop(drop).build();
|
||||
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.BuyGoodsToItemResponse_VALUE,build,true);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.ljsd.jieling.logic.activity;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public interface ActivityType {
|
||||
|
||||
int UNOPEN_STATE = -1;
|
||||
|
@ -99,6 +100,7 @@ public interface ActivityType {
|
|||
int SEVEN_WORLD_TREASURE = 83;//七界秘宝
|
||||
int RIDING_SWARD = 84;//御剑飞行
|
||||
int CONTINUOUS_GIFT = 85;//连续礼包
|
||||
int CONTINUOUS_GIFT_NEW = 87;//新连续礼包
|
||||
int SPECIAL_MONSTER_RANDOM_ACTIVITY = 100;//灵兽宝阁活动
|
||||
int SPECIAL_MONSTER_GIFT_ACTIVITY = 101;//灵兽礼包
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import config.SGlobalActivity;
|
|||
import java.util.HashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public enum ActivityTypeEnum {
|
||||
|
||||
ONLINEREWARD(ActivityType.OnlineReward, OnlineRewardActivity::new),
|
||||
|
@ -90,6 +91,7 @@ public enum ActivityTypeEnum {
|
|||
ITEMS_STORE_NEW(ActivityType.ITEMS_STORE_NEW,SuperBoxActivity::new),
|
||||
TRUMP_GACHA_ACTIVITY(ActivityType.TRUMP_GACHA_ACTIVITY,LimitRandomCardActivity::new),
|
||||
CONTINUOUS_GIFT(ActivityType.CONTINUOUS_GIFT,SuperBoxActivity::new),//连续礼包
|
||||
CONTINUOUS_GIFT_NEW(ActivityType.CONTINUOUS_GIFT_NEW,ContinuousGiftActivity::new),//新连续礼包
|
||||
;
|
||||
|
||||
private int type;
|
||||
|
|
|
@ -0,0 +1,364 @@
|
|||
package com.ljsd.jieling.logic.activity;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.jbean.ActivityMission;
|
||||
import com.ljsd.jieling.jbean.ActivityProgressInfo;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.activity.AbstractActivity;
|
||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
import com.ljsd.jieling.logic.activity.ActivityType;
|
||||
import com.ljsd.jieling.logic.activity.event.ActivityStateChangeEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.IEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.activity.event.SuperBoxEvent;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
|
||||
import com.ljsd.jieling.logic.store.newRechargeInfo.bean.AbstractWelfareBag;
|
||||
import com.ljsd.jieling.logic.store.newRechargeInfo.rechargeHandler.RechargeHandler;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import config.*;
|
||||
import manager.STableManager;
|
||||
import rpc.protocols.CommonProto;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author hj
|
||||
* 新连续礼包活动
|
||||
*
|
||||
* 礼包状态:
|
||||
* 1:已解锁,可购买
|
||||
* 2:已解锁,不可买,未到购买天数
|
||||
* 3:已解锁,不可买,未购买前置礼包
|
||||
* 4:已解锁,不可买,未激活特权
|
||||
* 5:未解锁,不可见
|
||||
* 6:未解锁,可见,可预览
|
||||
* 7:未解锁,可见,不可预览
|
||||
* 8:已购买
|
||||
*/
|
||||
@SuppressWarnings("ALL")
|
||||
public class ContinuousGiftActivity extends AbstractActivity {
|
||||
|
||||
ContinuousGiftActivity(int id) {
|
||||
super(id);
|
||||
Poster.getPoster().listenEvent(this, SuperBoxEvent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initActivity(User user) throws Exception {
|
||||
ActivityMission mission = new ActivityMission();
|
||||
// 初始化阶段奖励
|
||||
ActivityLogic.getInstance().initOtherMission(mission, new ArrayList<>());
|
||||
user.getActivityManager().getActivityMissionMap().put(id, mission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(IEvent event) throws Exception {
|
||||
// 类型验证
|
||||
if (!(event instanceof SuperBoxEvent)) {
|
||||
return;
|
||||
}
|
||||
// 获取信息
|
||||
SuperBoxEvent event1 = (SuperBoxEvent) event;
|
||||
User user = UserManager.getUser(event1.getUserId());
|
||||
// 礼包处理
|
||||
giftHandle(user, event1.getGiftId(), event1.getNum());
|
||||
|
||||
// 客户端推送
|
||||
ISession session = OnlineUserManager.getSessionByUid(user.getId());
|
||||
sendActivityProgress(session, user.getActivityManager().getActivityMissionMap().get(id), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 礼包处理
|
||||
* @param user
|
||||
* @param giftId
|
||||
* @param missionMap
|
||||
*/
|
||||
private void giftHandle(User user, int giftId, int giftNum){
|
||||
if (giftId < 0 || giftNum <= 0){
|
||||
// 非礼包处理
|
||||
return;
|
||||
}
|
||||
|
||||
ActivityMission mission = user.getActivityManager().getActivityMissionMap().get(id);
|
||||
if (mission == null){
|
||||
return;
|
||||
}
|
||||
Map<Integer, ActivityProgressInfo> missionMap = mission.getActivityMissionMap();
|
||||
Collection<SThemeActivityShop> themeShops = SThemeActivityShop.themeMap.getOrDefault(id, new HashMap<>(0)).values();
|
||||
|
||||
for (SThemeActivityShop theme : themeShops) {
|
||||
if (theme.getGoodId() == giftId){
|
||||
// 记录礼包购买次数
|
||||
ActivityProgressInfo current = missionMap.getOrDefault(theme.getId(),new ActivityProgressInfo());
|
||||
current.setProgrss(current.getProgrss() + giftNum);
|
||||
// 当前礼包状态处理
|
||||
if (checkBuyGiftLimit(user,theme.getId(),current.getProgrss())){
|
||||
current.setState(8);
|
||||
missionMap.put(theme.getId(),current);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* 次数代码非必要不要进行修改,包含N多的嵌套if
|
||||
* 不要问我为啥写的这么恶心,因为我自己也不知怎么写出来的
|
||||
* @param user
|
||||
*/
|
||||
private int getProgress(User user,int missionId){
|
||||
// 活动信息是否为null
|
||||
ActivityMission mission = user.getActivityManager().getActivityMissionMap().get(id);
|
||||
int days = mission.getV();
|
||||
// 库
|
||||
ActivityProgressInfo progressInfo = Optional.ofNullable(mission.getActivityMissionMap()).map(v->v.get(missionId)).orElse(null);
|
||||
// 表
|
||||
SThemeActivityShop theme = Optional.ofNullable(SThemeActivityShop.themeMap.get(id)).map(v -> v.get(missionId)).orElse(null);
|
||||
// 返回值
|
||||
int result = 0;
|
||||
// 极为恶心的循环,包含超多的if-else
|
||||
if (theme != null){
|
||||
if (progressInfo != null && progressInfo.getState() == 8){
|
||||
// 已购买
|
||||
result = 8;
|
||||
}else {
|
||||
// 未购买, 是否解锁
|
||||
if (days >= theme.getUnlockDay()){
|
||||
// 已解锁, 可买天数
|
||||
if (days >= theme.getBuyDay()){
|
||||
// 可买, 是否购买前置礼包
|
||||
if (checkBuyAgo(user,theme.getId())){
|
||||
// 可买
|
||||
result = 1;
|
||||
}else {
|
||||
// 未购买前置
|
||||
result = 3;
|
||||
}
|
||||
}else {
|
||||
// 不可买
|
||||
result = 2;
|
||||
}
|
||||
}else {
|
||||
// 未解锁, 是否可见
|
||||
if (days >= theme.getVisibleDay()){
|
||||
// 可见, 是否可预览
|
||||
result = days >= theme.getViewDay()?6:7;
|
||||
}else {
|
||||
// 不可见
|
||||
result = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<CommonProto.ActivityInfo.MissionInfo> getAllMissInfo(User user,ActivityMission activityMission, Set<Integer> filter) {
|
||||
long now = TimeUtils.now();
|
||||
long start = getSrartTime();
|
||||
long end = getEndTime();
|
||||
// 验证活动是否开启
|
||||
if (now < start || now > end){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
if (activityMission == null){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// 更新记录天数
|
||||
activityMission.setV(TimeUtils.getSoFarWentDays(start, now)+1);
|
||||
// 库里存储的活动档位信息
|
||||
Map<Integer, ActivityProgressInfo> progressInfoMap = activityMission.getActivityMissionMap();
|
||||
// 返回对象
|
||||
List<CommonProto.ActivityInfo.MissionInfo> missionInfos = new ArrayList<>(progressInfoMap.size());
|
||||
// 策划表的配置
|
||||
Map<Integer, SThemeActivityShop> themeMap = SThemeActivityShop.themeMap.getOrDefault(id,new HashMap<>());
|
||||
for (Map.Entry<Integer, SThemeActivityShop> entry : themeMap.entrySet()) {
|
||||
// 参数初始化
|
||||
int missionId = entry.getKey();
|
||||
int progress = getProgress(user,missionId);
|
||||
if (progress == 0){
|
||||
continue;
|
||||
}
|
||||
int state = progress==8?1:0;
|
||||
// 封装proto并返回
|
||||
CommonProto.ActivityInfo.MissionInfo build = CommonProto.ActivityInfo.MissionInfo.newBuilder()
|
||||
.setMissionId(missionId)
|
||||
.setProgress(progress)
|
||||
.setState(state)
|
||||
.build();
|
||||
missionInfos.add(build);
|
||||
}
|
||||
return missionInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查活动是否完成或者可以领取
|
||||
* @param uid
|
||||
* @param activityId
|
||||
* @param activityMission
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean checkActivityMissionFinishAndTake(int uid, int activityId, ActivityMission activityMission) {
|
||||
Map<Integer, ActivityProgressInfo> activityProgressInfoMap = activityMission.getActivityMissionMap();
|
||||
if (activityProgressInfoMap.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 策划表的配置
|
||||
Map<Integer, SThemeActivityShop> themeMap = SThemeActivityShop.themeMap.getOrDefault(id,new HashMap<>());
|
||||
for (Map.Entry<Integer, SThemeActivityShop> entry : themeMap.entrySet()) {
|
||||
ActivityProgressInfo progressInfo = activityProgressInfoMap.get(entry.getKey());
|
||||
if (progressInfo == null || progressInfo.getState() != 8){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(activityId);
|
||||
if(sGlobalActivity.getResetGrade()==0){
|
||||
activityMission.setActivityState(ActivityType.FINISH_STATE);
|
||||
Poster.getPoster().dispatchEvent(new ActivityStateChangeEvent(uid,activityId,ActivityType.FINISH_STATE));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
* @return
|
||||
*/
|
||||
public long getSrartTime(){
|
||||
long startTime = 0;
|
||||
SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(id);
|
||||
// 绝对时间
|
||||
if (activity.getTime() == ActivityType.OPEN_TYPE_TIME){
|
||||
startTime = activity.getStartTimeLong();
|
||||
}
|
||||
// 开服时间
|
||||
else if (activity.getTime() == ActivityType.OPEN_TYPE_SERVER) {
|
||||
String openTime = GameApplication.serverConfig.getOpenTime();
|
||||
long timeLong2 = TimeUtils.stringToTimeLong2(openTime);
|
||||
startTime = timeLong2 + activity.getStartTimeLong() * 1000;
|
||||
}
|
||||
return startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
* @return
|
||||
*/
|
||||
public long getEndTime(){
|
||||
long endTime = 0;
|
||||
SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(id);
|
||||
// 绝对时间
|
||||
if (activity.getTime() == ActivityType.OPEN_TYPE_TIME){
|
||||
endTime = activity.getEndTimeLong();
|
||||
}
|
||||
// 开服时间
|
||||
else if (activity.getTime() == ActivityType.OPEN_TYPE_SERVER) {
|
||||
String openTime = GameApplication.serverConfig.getOpenTime();
|
||||
long timeLong2 = TimeUtils.stringToTimeLong2(openTime);
|
||||
endTime = timeLong2 + activity.getEndTimeLong() * 1000;
|
||||
}
|
||||
return endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证前置礼包购买状态
|
||||
* @param user
|
||||
* @param boxId
|
||||
* @return
|
||||
*/
|
||||
private boolean checkBuyAgo(User user, int boxId){
|
||||
// 获取消息
|
||||
Map<Integer, ActivityProgressInfo> missionMap = user.getActivityManager().getActivityMissionMap().get(id).getActivityMissionMap();
|
||||
SThemeActivityShop themes = STableManager.getConfig(SThemeActivityShop.class).get(boxId);
|
||||
// 非空
|
||||
if (missionMap.isEmpty() || themes == null){
|
||||
return false;
|
||||
}
|
||||
// 0表示没有前置条件
|
||||
if (themes.getLimitPackFId() == 0){
|
||||
return true;
|
||||
}
|
||||
// 前置礼包状态验证
|
||||
ActivityProgressInfo info = missionMap.get(themes.getLimitPackFId());
|
||||
// info为null代表没有前置条件, state==1代表已买过
|
||||
if (info != null && info.getState() == 8){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验礼包购买次数
|
||||
* @param user
|
||||
* @param indexId
|
||||
* @return
|
||||
*/
|
||||
private boolean checkBuyGiftLimit(User user, int indexId, int count){
|
||||
Map<Integer, SThemeActivityShop> themeActivityShopMap = STableManager.getConfig(SThemeActivityShop.class);
|
||||
SThemeActivityShop shop = themeActivityShopMap.get(indexId);
|
||||
if (shop != null){
|
||||
if (shop.getGoodType() == 1){
|
||||
// 礼包不存在
|
||||
SRechargeCommodityNewConfig config = SRechargeCommodityNewConfig.getConfigById(shop.getGoodId());
|
||||
if (config == null){
|
||||
return true;
|
||||
}
|
||||
RechargeHandler rechargeHandler = BuyGoodsNewLogic.getRechargeHandler(config.getOtype());
|
||||
AbstractWelfareBag bag = rechargeHandler.getRechargeMap(user).get(shop.getGoodId());
|
||||
// 可继续购买
|
||||
if (bag != null && bag.checkBuy()){
|
||||
return false;
|
||||
}
|
||||
}else if (shop.getGoodType() == 2){
|
||||
Map<Integer, SGoodsConfig> goodsConfigMap = STableManager.getConfig(SGoodsConfig.class);
|
||||
SGoodsConfig goodsConfig = goodsConfigMap.get(shop.getGoodId());
|
||||
if (goodsConfig == null){
|
||||
return true;
|
||||
}
|
||||
// 可继续购买
|
||||
if (goodsConfig.getLimit() != 0 && goodsConfig.getLimit() < count){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部不能购买的礼包
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Set<Integer> getCloseGoods(User user){
|
||||
HashSet<Integer> set = new HashSet<>();
|
||||
ActivityMission mission = user.getActivityManager().getActivityMissionMap().get(id);
|
||||
if (mission == null){
|
||||
return set;
|
||||
}
|
||||
// 活动页签
|
||||
Map<Integer, ActivityProgressInfo> map = mission.getActivityMissionMap();
|
||||
Map<Integer, SThemeActivityShop> themes = SThemeActivityShop.themeMap.get(id);
|
||||
|
||||
for (Map.Entry<Integer, SThemeActivityShop> entry : themes.entrySet()) {
|
||||
int progress = getProgress(user, entry.getKey());
|
||||
// 不可购买的礼包
|
||||
if (progress != 1 || progress == 0){
|
||||
set.add(entry.getValue().getGoodId());
|
||||
}
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
}
|
|
@ -22,11 +22,26 @@ public class SuperBoxEvent implements IEvent {
|
|||
public static int fund_old_user = -3;
|
||||
|
||||
private int userId;
|
||||
private int giftId = default_id;//礼包id
|
||||
/**
|
||||
* 礼包id
|
||||
*/
|
||||
private int giftId = default_id;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private int num;
|
||||
|
||||
|
||||
public SuperBoxEvent(int userId, int giftId) {
|
||||
this.userId = userId;
|
||||
this.giftId = giftId;
|
||||
this.num = 1;
|
||||
}
|
||||
|
||||
public SuperBoxEvent(int userId, int giftId, int num) {
|
||||
this.userId = userId;
|
||||
this.giftId = giftId;
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
|
@ -45,4 +60,11 @@ public class SuperBoxEvent implements IEvent {
|
|||
this.giftId = giftId;
|
||||
}
|
||||
|
||||
public int getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(int num) {
|
||||
this.num = num;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,6 +98,23 @@ public class ItemUtil {
|
|||
return dropBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取道具
|
||||
* @param user
|
||||
* @param itemArr
|
||||
* @param count
|
||||
* @param reason
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static CommonProto.Drop.Builder drop(User user, int[][] itemArr, float count, int reason) throws Exception {
|
||||
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
|
||||
ItemMap itemObj = new ItemMap();
|
||||
selectItemArr(itemArr,itemObj,count);
|
||||
mapToAdd(user,itemObj,dropBuilder,reason);
|
||||
return dropBuilder;
|
||||
}
|
||||
|
||||
|
||||
//注:此方法只用于会超过int最大值的掉落,不会超过最大值的用上面方法
|
||||
public static CommonProto.Drop.Builder drop(User user, long[][] itemArr,int reason) throws Exception {
|
||||
|
@ -198,8 +215,8 @@ public class ItemUtil {
|
|||
*
|
||||
* @param user
|
||||
* @param dropGroupIds
|
||||
* @param dropRatio
|
||||
* @param isMapping 是否地图探索掉落,1:是
|
||||
* @param dropRatio 计算几次
|
||||
* @param isMapping 是否地图探索掉落,1:是(暂时不用)
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
|
@ -367,6 +384,12 @@ public class ItemUtil {
|
|||
}
|
||||
}
|
||||
|
||||
private static void selectItemArr(int[][] itemArr,ItemMap itemObj,float count) throws ErrorCodeException{
|
||||
for (int[] items : itemArr){
|
||||
getMap(items[0],items[1],itemObj,count);
|
||||
}
|
||||
}
|
||||
|
||||
private static void selectLongItemArr(long[][] itemArr,ItemMap itemObj) throws ErrorCodeException{
|
||||
for (long[] items : itemArr){
|
||||
getMap((int)items[0],items[1],itemObj,1);
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="GoodsConfig")
|
||||
public class SGoodsConfig implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int[][] goods;
|
||||
|
||||
private int[] price;
|
||||
|
||||
private int limit;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int[][] getGoods() {
|
||||
return goods;
|
||||
}
|
||||
|
||||
public int[] getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="ThemeActivityShop")
|
||||
public class SThemeActivityShop implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int activityId;
|
||||
|
||||
private int type;
|
||||
|
||||
private int goodType;
|
||||
|
||||
private int goodId;
|
||||
|
||||
private int unlockDay;
|
||||
|
||||
private int visibleDay;
|
||||
|
||||
private int viewDay;
|
||||
|
||||
private int buyDay;
|
||||
|
||||
private int limitPackFId;
|
||||
|
||||
private int limitPackBId;
|
||||
|
||||
/**
|
||||
* key: 活动id value: <key: 索引id, value:对象>
|
||||
*/
|
||||
public static Map<Integer, Map<Integer,SThemeActivityShop>> themeMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
Map<Integer, SThemeActivityShop> config = STableManager.getConfig(SThemeActivityShop.class);
|
||||
config.values().forEach(v->{
|
||||
Map<Integer, SThemeActivityShop> themeActivityShopMap = themeMap.getOrDefault(v.getActivityId(), new HashMap<>());
|
||||
themeActivityShopMap.put(v.getId(),v);
|
||||
themeMap.put(v.getActivityId(),themeActivityShopMap);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getActivityId() {
|
||||
return activityId;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getGoodType() {
|
||||
return goodType;
|
||||
}
|
||||
|
||||
public int getGoodId() {
|
||||
return goodId;
|
||||
}
|
||||
|
||||
public int getUnlockDay() {
|
||||
return unlockDay;
|
||||
}
|
||||
|
||||
public int getVisibleDay() {
|
||||
return visibleDay;
|
||||
}
|
||||
|
||||
public int getViewDay() {
|
||||
return viewDay;
|
||||
}
|
||||
|
||||
public int getBuyDay() {
|
||||
return buyDay;
|
||||
}
|
||||
|
||||
public int getLimitPackFId() {
|
||||
return limitPackFId;
|
||||
}
|
||||
|
||||
public int getLimitPackBId() {
|
||||
return limitPackBId;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue