寻宝迷踪
parent
e7f5d7dcfd
commit
c5b9927feb
|
@ -0,0 +1,52 @@
|
|||
package com.ljsd.jieling.handler.activity;
|
||||
|
||||
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.jbean.ActivityMission;
|
||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
import com.ljsd.jieling.logic.activity.ActivityTypeEnum;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.activity.event.UserLevelEvent;
|
||||
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.SLotterySetting;
|
||||
import manager.STableManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class XunBaoMiZongHandler extends BaseHandler<PlayerInfoProto.XunBaoMiZongEnterRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.XUN_BAO_MI_ZONG_ENTER_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, PlayerInfoProto.XunBaoMiZongEnterRequest proto) throws Exception {
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
SLotterySetting sLotterySetting = STableManager.getConfig(SLotterySetting.class).get(166);
|
||||
boolean enoughCost = false;
|
||||
for (int[] cost:sLotterySetting.getCostItem()){
|
||||
int [][] costItems = new int[][]{cost};
|
||||
Map<Integer, Integer> cost1 = new HashMap<>(1);
|
||||
cost1.put(cost[0], cost[1]);
|
||||
enoughCost = ItemUtil.checkCost(user, cost1);
|
||||
}
|
||||
if(!enoughCost){
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
Poster.getPoster().dispatchEvent(new UserLevelEvent(user.getId(),1));
|
||||
PlayerInfoProto.XunBaoMiZongEnterResponse.Builder response = PlayerInfoProto.XunBaoMiZongEnterResponse.newBuilder();
|
||||
response.setIsEnter(true);
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.XUN_BAO_MI_ZONG_ENTER_RESPONSE.getNumber(), response.build(), true);
|
||||
}
|
||||
}
|
|
@ -108,4 +108,5 @@ public interface ActivityType {
|
|||
int SUPERFUND328 = 79;//超值基金328
|
||||
int PREPARE_FIFTEEN_ACTIVITY = 80;//15日登陆预告
|
||||
int THEME_ACTIVITY_SHOP = 81;//ThemeActivityTask活动商店
|
||||
int XUN_BAO_MI_ZONG = 82;//寻宝迷踪
|
||||
}
|
||||
|
|
|
@ -81,7 +81,9 @@ public enum ActivityTypeEnum {
|
|||
SUPERFUND128(ActivityType.SUPERFUND128,SuperFundActivity::new),//超值基金128
|
||||
SUPERFUND328(ActivityType.SUPERFUND328,SuperFundActivity::new),//超值基金328
|
||||
PREPARE_FIFTEEN_ACTIVITY(ActivityType.PREPARE_FIFTEEN_ACTIVITY,DefaultEmptyActivity::new),//超值基金328
|
||||
THEME_ACTIVITY_SHOP(ActivityType.THEME_ACTIVITY_SHOP,DefaultEmptyActivity::new);
|
||||
THEME_ACTIVITY_SHOP(ActivityType.THEME_ACTIVITY_SHOP,DefaultEmptyActivity::new),
|
||||
XUN_BAO_MI_ZONG(ActivityType.XUN_BAO_MI_ZONG,XunBaoMiZongActivity::new)
|
||||
;
|
||||
|
||||
private int type;
|
||||
private Function<Integer, AbstractActivity> toActivityFunction;
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.ljsd.jieling.logic.activity;
|
||||
|
||||
import com.ljsd.jieling.jbean.ActivityMission;
|
||||
import com.ljsd.jieling.logic.activity.event.IEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.activity.event.XunBaoMiZongEvent;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
||||
public class XunBaoMiZongActivity extends AbstractActivity {
|
||||
|
||||
public XunBaoMiZongActivity(int id) {
|
||||
super(id);
|
||||
Poster.getPoster().listenEvent(this, XunBaoMiZongEvent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(IEvent event) throws Exception {
|
||||
if (!(event instanceof XunBaoMiZongEvent)) {
|
||||
return;
|
||||
}
|
||||
XunBaoMiZongEvent xunBaoMiZongEvent = (XunBaoMiZongEvent) event;
|
||||
User user = xunBaoMiZongEvent.getUser();
|
||||
ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(id);
|
||||
if (null == activityMission) {
|
||||
return;
|
||||
}
|
||||
if (activityMission.getActivityState() == 1 && xunBaoMiZongEvent.getType() == 0) {
|
||||
if (null == activityMission) {
|
||||
return;
|
||||
}
|
||||
//最大伤害更新
|
||||
activityMission.setV(0);
|
||||
ActivityLogic.getInstance().sendActivityInfo(user, id);
|
||||
}
|
||||
if (activityMission.getActivityState() == 0 && xunBaoMiZongEvent.getType() == 1) {
|
||||
if (null == activityMission) {
|
||||
return;
|
||||
}
|
||||
//最大伤害更新
|
||||
activityMission.setV(1);
|
||||
ActivityLogic.getInstance().sendActivityInfo(user, id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.ljsd.jieling.logic.activity.event;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
||||
public class XunBaoMiZongEvent implements IEvent{
|
||||
private User user;
|
||||
private int type;
|
||||
|
||||
public XunBaoMiZongEvent(User user, int type) {
|
||||
this.user = user;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
|
@ -365,6 +365,9 @@ public class HeroLogic{
|
|||
//只记录新将招募次数
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.NEW_HERO_ZHAOMU,sLotterySetting.getPerCount());
|
||||
}
|
||||
if(sLotterySetting.getActivityId() == 8201){
|
||||
Poster.getPoster().dispatchEvent(new UserLevelEvent(user.getId(),0));
|
||||
}
|
||||
heroManager.updateRandCount(type,perCount);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.dropPer(user, resultRandom,BIReason.HERO_RANDOM);
|
||||
fiveStarPushByRandom(user,resultRandom);
|
||||
|
|
Loading…
Reference in New Issue