天地洪炉活动脚本提交
parent
e944250fb8
commit
7709b634fd
|
@ -0,0 +1,40 @@
|
|||
package com.ljsd.jieling.handler.activity;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.activity.activityLogic.WeekCardLogic;
|
||||
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.MessageUtil;
|
||||
import rpc.protocols.ActivityProto;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class GetTrumpSelectItemHandler extends BaseHandler<ActivityProto.GetTrumpSelectItemRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.GET_TRUMP_SELECT_ITEM_REQUEST;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取天地洪炉抽奖选择up道具协议
|
||||
* @param session
|
||||
* @param proto
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void processWithProto(ISession session, ActivityProto.GetTrumpSelectItemRequest proto) throws Exception{
|
||||
ActivityProto.GetTrumpSelectItemResponse.Builder builder = ActivityProto.GetTrumpSelectItemResponse.newBuilder();
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
List<Integer>selectList=new ArrayList<>();
|
||||
for (Map.Entry<Integer, Integer> entry : user.getHeroManager().getTrumpSelectItemMap().entrySet()) {
|
||||
selectList.add(entry.getValue());
|
||||
}
|
||||
builder.addAllSelectIds(selectList);
|
||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.GET_TRUMP_SELECT_ITEM_RESPONSE_VALUE, builder.build(), true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.ljsd.jieling.handler.activity;
|
||||
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.jbean.ActivityMission;
|
||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
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.MessageUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.ActivityProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/11/11
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class TrumpGachaSelectItemRequestHandler extends BaseHandler<ActivityProto.TrumpGachaSelectItemRequest>{
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.TRUMP_GACHA_SELECT_ITEM_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, ActivityProto.TrumpGachaSelectItemRequest proto) throws Exception {
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
Map<Integer, ActivityMission> activityMissionMap = user.getActivityManager().getActivityMissionMap();
|
||||
ActivityMission activityMission = activityMissionMap.get(proto.getActivityId());
|
||||
if(activityMission==null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
HashMap<Integer, Integer> map = new HashMap<>();
|
||||
for (int i = 0; i < proto.getSelectIdsList().size(); i++) {
|
||||
map.put(i+1,proto.getSelectIdsList().get(i));
|
||||
}
|
||||
user.getHeroManager().setTrumpSelectItemMap(map);
|
||||
MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.TRUMP_GACHA_SELECT_ITEM_RESPONSE_VALUE,null,true);
|
||||
}
|
||||
}
|
|
@ -88,6 +88,7 @@ public enum ActivityTypeEnum {
|
|||
LING_LONG_PAVILION(ActivityType.LING_LONG_PAVILION,DefaultEmptyActivity::new),
|
||||
RIDING_SWARD(ActivityType.RIDING_SWARD,RidingSwardActivity::new),
|
||||
ITEMS_STORE_NEW(ActivityType.ITEMS_STORE_NEW,SuperBoxActivity::new),
|
||||
TRUMP_GACHA_ACTIVITY(ActivityType.TRUMP_GACHA_ACTIVITY,LimitRandomCardActivity::new),
|
||||
;
|
||||
|
||||
private int type;
|
||||
|
|
|
@ -159,7 +159,7 @@ public class LimitRandomSpecialMonsterActivityNew extends LimitRandomCardActivit
|
|||
* 检查活动是否完成或者可以领取
|
||||
* @param uid
|
||||
* @param activityId
|
||||
* @param activityMission4
|
||||
* @param activityMission
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -94,6 +94,10 @@ public class HeroManager extends MongoBase {
|
|||
*/
|
||||
private HashMap<Integer,Integer> beautyBagCardInfoMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 天地洪炉-许愿道具
|
||||
*/
|
||||
private HashMap<Integer,Integer> trumpSelectItemMap = new HashMap<>();
|
||||
/**
|
||||
* 抽奖次数记录
|
||||
* key: 招募类型 value: 次数
|
||||
|
@ -601,6 +605,17 @@ public class HeroManager extends MongoBase {
|
|||
this.beautyBagCardInfoMap = beautyBagCardInfoMap;
|
||||
updateString("beautyBagCardInfoMap", beautyBagCardInfoMap);
|
||||
}
|
||||
|
||||
public HashMap<Integer, Integer> getTrumpSelectItemMap() {
|
||||
return trumpSelectItemMap;
|
||||
}
|
||||
|
||||
public void setTrumpSelectItemMap(HashMap<Integer, Integer> trumpSelectItemMap) {
|
||||
this.trumpSelectItemMap = trumpSelectItemMap;
|
||||
updateString("trumpSelectItemMap", trumpSelectItemMap);
|
||||
}
|
||||
|
||||
|
||||
public void putBeautyBagCardInfoMap(Integer key,Integer val) {
|
||||
this.beautyBagCardInfoMap.put(key,val);
|
||||
updateString("beautyBagCardInfoMap", beautyBagCardInfoMap);
|
||||
|
|
|
@ -422,7 +422,10 @@ public class HeroLogic {
|
|||
} else if (sLotterySetting.getLotteryType() == 3 &&
|
||||
isActivityBeautyBag(sLotterySetting.getActivityId())) {//乾坤宝盒-许愿魂印
|
||||
result = BeautyBagDrawCard(user, sLotteryRewardConfig);
|
||||
} else {
|
||||
}else if(isActivityByIdAndType(sLotterySetting.getActivityId(),ActivityType.TRUMP_GACHA_ACTIVITY)){
|
||||
result = TrumpGachaDrawCard(user, sLotteryRewardConfig);
|
||||
}
|
||||
else {
|
||||
result = reward;
|
||||
}
|
||||
//活动抽奖计数
|
||||
|
@ -432,6 +435,9 @@ public class HeroLogic {
|
|||
} else if (isActivityByIdAndType(sLotterySetting.getActivityId(), ActivityType.SPECIAL_MONSTER_RANDOM_ACTIVITY)) {
|
||||
//灵兽招募 计次数
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.SOUL_RECRUIT, 1);
|
||||
}else if(isActivityByIdAndType(sLotterySetting.getActivityId(),ActivityType.TRUMP_GACHA_ACTIVITY)){
|
||||
//天地洪炉抽奖 计次数
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.TRUMP_GACHA, 1);
|
||||
}
|
||||
//记录卡池抽奖次数
|
||||
heroManager.putRandomType(type, num + result[1]);
|
||||
|
@ -466,6 +472,30 @@ public class HeroLogic {
|
|||
return result;
|
||||
}
|
||||
|
||||
///天地洪炉抽奖处理
|
||||
private int[] TrumpGachaDrawCard(User user, SLotteryRewardConfig sLotteryRewardConfig) {
|
||||
int count = 4;
|
||||
List<SLotteryRewardConfig> list = SLotteryRewardConfig.getSLotteryRewardConfigListByPoolId(sLotteryRewardConfig.getPool());
|
||||
if (list == null) {
|
||||
return sLotteryRewardConfig.getReward();
|
||||
}
|
||||
|
||||
int index = list.indexOf(sLotteryRewardConfig);
|
||||
if (index >= count) {
|
||||
return sLotteryRewardConfig.getReward();
|
||||
}
|
||||
|
||||
if (!user.getHeroManager().getTrumpSelectItemMap().containsKey(index + 1)) {
|
||||
return sLotteryRewardConfig.getReward();
|
||||
}
|
||||
|
||||
int[] result = new int[2];
|
||||
result[0] = user.getHeroManager().getTrumpSelectItemMap().get(index + 1);
|
||||
result[1] = sLotteryRewardConfig.getReward()[1];
|
||||
LOGGER.info("天地洪炉抽到了UP---->" + sLotteryRewardConfig.getReward()[0] + "替换为---->" + result[0]);
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isActivityBeautyBag(int activityId) {
|
||||
SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(activityId);
|
||||
if (activity == null) {
|
||||
|
|
|
@ -137,5 +137,6 @@ public enum GameEvent {
|
|||
DAILY_CHALLENGE_COUNT,//日常副本挑战次数
|
||||
HARSTAGE_PARTICIPATION_REWARD,//山河社稷图参与奖励
|
||||
NEW_HERO_ZHAOMU,//新将招募次数
|
||||
TRUMP_GACHA,//天地洪炉
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue