back_recharge
wangyuan 2019-02-25 20:53:38 +08:00
parent 47e04c5d51
commit cdcff252ab
1 changed files with 32 additions and 5 deletions

View File

@ -2,6 +2,7 @@ package com.ljsd.jieling.logic.item;
import com.ljsd.jieling.config.*;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.globals.GlobalItemType;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.network.session.ISession;
@ -119,9 +120,28 @@ public class WorkShopLogic {
}
}
private boolean checkIsUnlock(User user,int[] openRules){
private boolean checkIsUnlock(int optType,int type,WorkShopController workShopController,int[] openRules){
int openType = openRules[0];
int openParm = openRules[1];
if(openType == GlobalsDef.LEVLE_LOCK){
int myLevle = 0;
if(type == GlobalsDef.WORK_SHOP_TYPE){
myLevle = workShopController.getWorkShopLevel();
}
if(type == GlobalsDef.COOK_SHOP_TYPE){
myLevle = workShopController.getCookLevel();
}
if(openParm>myLevle){
return false;
}
}
if(openType == GlobalsDef.BLUE_LOCK){
List<Integer> openIds = workShopController.getOpenBlueStateMap().get(optType);
if(openIds == null || !openIds.contains(openParm)){
return false;
}
}
return true;
}
@ -181,8 +201,8 @@ public class WorkShopLogic {
workShopBaseInfoList.add(CommonProto.WorkShopBaseInfo.newBuilder().setType(GlobalsDef.WORK_SHOP_TYPE).setLevle(workShopLevel).setExp(workShopExp).build());
workShopBaseInfoList.add(CommonProto.WorkShopBaseInfo.newBuilder().setType(GlobalsDef.COOK_SHOP_TYPE).setLevle(cookLevel).setExp(cookExp).build());
List<CommonProto.WorkShopUnLockInfo> workShopUnLockInfoList = new ArrayList<>(2);
workShopUnLockInfoList.add(CommonProto.WorkShopUnLockInfo.newBuilder().setType(GlobalsDef.WORK_BASE_TYPE).addAllId(workShopList).build());
workShopUnLockInfoList.add(CommonProto.WorkShopUnLockInfo.newBuilder().setType(GlobalsDef.WORK_CREATE_TYPE).addAllId(cookShopList).build());
workShopUnLockInfoList.add(CommonProto.WorkShopUnLockInfo.newBuilder().setType(GlobalsDef.WORK_BASE_TYPE).addAllId(workShopList == null ?new ArrayList<>(1):workShopList).build());
workShopUnLockInfoList.add(CommonProto.WorkShopUnLockInfo.newBuilder().setType(GlobalsDef.WORK_CREATE_TYPE).addAllId(cookShopList==null?new ArrayList<>(1):cookShopList).build());
PlayerInfoProto.GetWorkShopInfoResponse build = PlayerInfoProto.GetWorkShopInfoResponse.newBuilder().addAllWorkShopBaseInfo(workShopBaseInfoList).addAllWorkShopUnLockInfo(workShopUnLockInfoList).build();
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.GET_WORKSHOP_INFO_RESPONSE_VALUE,build,true);
@ -195,7 +215,10 @@ public class WorkShopLogic {
int uid = session.getUid();
User user = UserManager.getUser(uid);
SWorkShopFoundationConfig sWorkShopFoundationConfig = SWorkShopFoundationConfig.getShopFoundationConfigMap().get(materialId);
checkIsUnlock(user,sWorkShopFoundationConfig.getOpenRules());
if(!checkIsUnlock(GlobalsDef.WORK_BASE_TYPE,sWorkShopFoundationConfig.getType(),user.getWorkShopController(),sWorkShopFoundationConfig.getOpenRules())){
MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_RESPONSE_VALUE,"未开");
return;
}
int[][] cost = sWorkShopFoundationConfig.getCost();
times2Array(cost,nums);
if( !ItemUtil.itemCost(user, cost)){
@ -208,7 +231,7 @@ public class WorkShopLogic {
//熟练度提升
int type = sWorkShopFoundationConfig.getType();
int addExp = sWorkShopFoundationConfig.getExp();
int addExp = sWorkShopFoundationConfig.getExp()*nums;
if(type == GlobalsDef.WORK_SHOP_TYPE){
user.getWorkShopController().addWorkShopExp(addExp);
}else if( type == GlobalsDef.COOK_SHOP_TYPE){
@ -223,6 +246,10 @@ public class WorkShopLogic {
int uid=session.getUid();
User user = UserManager.getUser(uid);
SWorkShopEquipmentConfig sWorkShopEquipmentConfig = SWorkShopEquipmentConfig.getsWorkShopEquipmentConfigMap().get(equipTid);
if(!checkIsUnlock(GlobalsDef.WORK_CREATE_TYPE,sWorkShopEquipmentConfig.getType(),user.getWorkShopController(),sWorkShopEquipmentConfig.getOpenRules())){
MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_RESPONSE_VALUE,"未开");
return;
}
int runesNum = sWorkShopEquipmentConfig.getRunesNum();
int[][] specialRunes = sWorkShopEquipmentConfig.getSpecialRunes();
int needNums = runesNum - specialRunes.length;