装备升星(云游商人)

back_recharge
mengchengzhen 2021-04-16 17:16:30 +08:00
parent 29ae290630
commit 92d850c470
6 changed files with 104 additions and 34 deletions

View File

@ -326,4 +326,6 @@ public interface BIReason {
int ACTIVE_USERSKIN = 1089;// 激活玩家皮肤
int ACTIVE_TITLE = 1090;// 激活玩家称号
int ACTIVE_MOUNT = 1091;// 激活玩家坐骑
int EQUIP_UPLEVEL_COST = 1092;//装备升星消耗
int EQUIP_UPLEVEL_REWARD = 1093;//装备升星获得
}

View File

@ -1,23 +1,38 @@
package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.logic.activity.event.EquipUpLevelEvent;
import com.ljsd.jieling.logic.activity.event.IEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.jbean.ActivityMission;
import com.ljsd.jieling.jbean.ActivityProgressInfo;
import com.ljsd.jieling.logic.dao.root.User;
import config.SComposeActivity;
import java.util.HashMap;
import java.util.Map;
public class EquipUpLevelActivity extends AbstractActivity {
public EquipUpLevelActivity(int id) {
super(id);
Poster.getPoster().listenEvent(this, EquipUpLevelEvent.class);
}
@Override
public void onEvent(IEvent event) throws Exception {
if (!(event instanceof EquipUpLevelEvent)){
return;
public void initActivity(User user) throws Exception {
ActivityMission mission = new ActivityMission();
Map<Integer, Map<Integer,SComposeActivity>> configMap = SComposeActivity.getConfigMap();
Map<Integer,Integer> useTypeMap = new HashMap<>();
for(Map.Entry<Integer,SComposeActivity> entry : configMap.get(id).entrySet()){
useTypeMap.put(entry.getKey(),entry.getValue().getCount());
}
User user = UserManager.getUser(((EquipUpLevelEvent) event).getuId());
for(Map.Entry<Integer,Integer> entry : useTypeMap.entrySet()){
ActivityProgressInfo activityProgressInfo = new ActivityProgressInfo();
activityProgressInfo.setProgrss(entry.getValue());
activityProgressInfo.setState(0);
mission.getActivityMissionMap().put(entry.getKey(), activityProgressInfo);
}
mission.setOpenType(1);
mission.setV(0);
mission.setActivityState(ActivityType.OPEN_STATE);
user.getActivityManager().getActivityMissionMap().put(id, mission);
}
}

View File

@ -1,22 +0,0 @@
package com.ljsd.jieling.logic.activity.event;
public class EquipUpLevelEvent implements IEvent {
private int uId;
private int equipId;
public int getuId() {
return uId;
}
public void setuId(int uId) {
this.uId = uId;
}
public int getEquipId() {
return equipId;
}
public void setEquipId(int equipId) {
this.equipId = equipId;
}
}

View File

@ -9,6 +9,8 @@ import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.globals.GlobalItemType;
import com.ljsd.jieling.handler.map.MapManager;
import com.ljsd.jieling.jbean.ActivityMission;
import com.ljsd.jieling.jbean.ActivityProgressInfo;
import com.ljsd.jieling.ktbeans.ReportEventEnum;
import com.ljsd.jieling.ktbeans.ReportUtil;
import com.ljsd.jieling.logic.activity.event.EspecialEquipUpEvent;
@ -888,4 +890,59 @@ public class ItemLogic {
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.JEWEL_BUILD_RESPONSE_VALUE,null,true);
}
/**
*
*/
public void equipUpLevel(ISession session, int activityId,int equipId,int itemId,int itemNum,
MessageTypeProto.MessageType messageType) throws Exception{
PlayerInfoProto.EquipUpLevelResponse.Builder response = PlayerInfoProto.EquipUpLevelResponse.newBuilder();
response.setResult(false);
User user = UserManager.getUser(session.getUid());
int type = SComposeActivity.getTypeById(activityId,equipId);
if(type == -1){
LOGGER.error("type找不到配置活动id:{}装备id:{}",activityId,equipId);
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
SComposeBook config = SComposeBook.getBookById(type,equipId);
if(config == null){
LOGGER.error("config找不到配置type:{}装备id:{}",type,equipId);
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
int[] itemC = config.getNeedCost();
if(itemC[0] != itemId || itemC[1] != itemNum){
LOGGER.error("itemCost不匹配item:{}num:{},conItem:{},conNum:{}",itemId,itemNum,itemC[0],itemC[1]);
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
ActivityMission misson = user.getActivityManager().getActivityMissionMap().get(activityId);
if(misson == null){
LOGGER.error("misson为空activityId:{}",activityId);
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN);
}
ActivityProgressInfo progress = misson.getActivityMissionMap().get(type);
if(progress == null){
LOGGER.error("progress为空type:{}",type);
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN);
}
if(progress.getProgrss() <= 0){
LOGGER.error("progress次数不足num:{}",progress.getProgrss());
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
throw new ErrorCodeException(ErrorCode.REFRESH_WHEL_TIME_NOT);
}
boolean itemCost = ItemUtil.itemCost(user, new int[][]{{equipId, 1},{itemId, itemNum}}, BIReason.EQUIP_UPLEVEL_COST, equipId);
if(!itemCost){
LOGGER.error("item不足equipId:{},itemId:{},itemNum:{}",equipId,itemId,itemNum);
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
CommonProto.Drop.Builder drop = ItemUtil.drop(user,new int[][]{{config.getGoalItems()[0],config.getGoalItems()[1]}},BIReason.EQUIP_UPLEVEL_REWARD);
response.setResult(true);
response.setDrop(drop);
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
}
}

View File

@ -17,8 +17,8 @@ public class SComposeActivity implements BaseConfig {
private int count;
private int composeType;
private Map<Integer, Map<Integer,SComposeActivity>> configMap;
private Map<Integer, Map<Integer, List<Integer>>> itemMap;
private static Map<Integer, Map<Integer,SComposeActivity>> configMap;
private static Map<Integer, Map<Integer, List<Integer>>> itemMap;
@Override
public void init() throws Exception {
@ -46,6 +46,20 @@ public class SComposeActivity implements BaseConfig {
}
}
public static Map<Integer, Map<Integer,SComposeActivity>> getConfigMap(){
return configMap;
}
public static int getTypeById(int actId,int equipId){
for(Map.Entry<Integer,List<Integer>> entry : itemMap.get(actId).entrySet()){
if(entry.getValue().contains(equipId)){
return entry.getKey();
}
}
return -1;
}
public int getId() {
return id;
}

View File

@ -15,7 +15,7 @@ public class SComposeBook implements BaseConfig {
private int type;
private String desc;
private Map<Integer,Map<Integer,SComposeBook>> typeMap;
private static Map<Integer,Map<Integer,SComposeBook>> typeMap;
@Override
public void init() throws Exception {
@ -35,6 +35,10 @@ public class SComposeBook implements BaseConfig {
}
}
public static SComposeBook getBookById(int type,int equipId){
return typeMap.get(type).get(equipId);
}
public int getId() {
return id;
}