back_recharge
jiahuiwen 2019-02-25 13:48:49 +08:00
parent 007a004f01
commit d8db472845
13 changed files with 499 additions and 91 deletions

View File

@ -1,2 +1,2 @@
Id AddRate FailExp
int mut,float#float,1 int
Id AddRate FailExp FoodNum
int mut,float#float,2 int int

View File

@ -3,6 +3,9 @@ package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Table(name ="MysteryFoodPoolConfig")
@ -18,14 +21,33 @@ public class SMysteryFoodPoolConfig implements BaseConfig {
private int pool;
@Override
private static Map<Integer,List<SMysteryFoodPoolConfig>> sMysteryFoodPoolConfigByPoolMap;
private static Map<Integer,Integer> totalWeightByPoolMap;
@Override
public void init() throws Exception {
Map<Integer, List<SMysteryFoodPoolConfig>> result = new HashMap<>();
Map<Integer, SMysteryFoodPoolConfig> config = STableManager.getConfig(SMysteryFoodPoolConfig.class);
for(SMysteryFoodPoolConfig sMysteryFoodPoolConfig : config.values()){
int pool = sMysteryFoodPoolConfig.getPool();
if(result.containsKey(pool)){
result.put(pool,new ArrayList<>());
}
result.get(pool).add(sMysteryFoodPoolConfig);
}
sMysteryFoodPoolConfigByPoolMap = result;
}
public static List<SMysteryFoodPoolConfig> getsMysteryFoodPoolConfigByPoold(int poolId) {
return sMysteryFoodPoolConfigByPoolMap.get(poolId);
}
public int getId() {
public static int getTotalWeightByPool(int pool) {
return totalWeightByPoolMap.get(pool);
}
public int getId() {
return id;
}

View File

@ -3,6 +3,7 @@ package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.HashMap;
import java.util.Map;
@Table(name ="MysteryFoodSetting")
@ -10,28 +11,63 @@ public class SMysteryFoodSetting implements BaseConfig {
private int id;
private float[] addRate;
private float[][] addRate;
private int failExp;
private int num;
private int foodNum;
private Map<Integer,Float> addRateByQuality;
private static SMysteryFoodSetting sMysteryFoodSetting;
@Override
public void init() throws Exception {
/* Map<Integer, SMysteryFoodSetting> config = STableManager.getConfig(SMysteryFoodSetting.class);
SMysteryFoodSetting sMysteryFoodSettingTmp = config.get(1);
Map<Integer,Float> result = new HashMap<>();
float[][] addRate = sMysteryFoodSettingTmp.getAddRate();
if(addRate!=null&&addRate.length>0){
for(float[] qulity : addRate){
result.put((int)qulity[0],qulity[1]);
}
sMysteryFoodSettingTmp.setAddRateByQuality(result);
}
sMysteryFoodSetting = sMysteryFoodSettingTmp;*/
}
public static SMysteryFoodSetting getsMysteryFoodSetting() {
return sMysteryFoodSetting;
}
public int getId() {
public int getId() {
return id;
}
public float[] getAddRate() {
public float[][] getAddRate() {
return addRate;
}
public int getFailExp() {
public int getFailExp() {
return failExp;
}
public int getNum() {
return num;
}
public Map<Integer, Float> getAddRateByQuality() {
return addRateByQuality;
}
public void setAddRateByQuality(Map<Integer, Float> addRateByQuality) {
this.addRateByQuality = addRateByQuality;
}
public int getFoodNum() {
return foodNum;
}
}

View File

@ -18,7 +18,7 @@ public class SWorkShopEquipmentConfig implements BaseConfig {
private int runesNum;
private int[] specialRunes;
private int[][] specialRunes;
private int exp;
@ -50,7 +50,7 @@ public class SWorkShopEquipmentConfig implements BaseConfig {
return runesNum;
}
public int[] getSpecialRunes() {
public int[][] getSpecialRunes() {
return specialRunes;
}

View File

@ -15,10 +15,22 @@ public class SWorkShopSetting implements BaseConfig {
private int[] promote;
private int foodExp;
private float addNum;
private int[][] poolRate;
private float addSuccessRate;
private Map<Integer,Integer> promoteMap;
private int cookTotalWeight;
private static int maxExp;
private static int maxCookExp;
private static Map<Integer,SWorkShopSetting> sWorkShopSettingMap;
@ -28,26 +40,42 @@ public class SWorkShopSetting implements BaseConfig {
Map<Integer, SWorkShopSetting> sWorkShopSettingMapTmp = sWorkShopSettingMap = STableManager.getConfig(SWorkShopSetting.class);
Map<Integer,Integer> promoteMapTmp = new HashMap<>();
int maxExpTmp = 0;
int maxCookExpTmp = 0;
int exp =0;
for(SWorkShopSetting sWorkShopSetting : sWorkShopSettingMapTmp.values()){
if(sWorkShopSetting.getId() == 0){
continue;
}
exp+=sWorkShopSetting.getExp();
int[] promote = sWorkShopSetting.getPromote();
promoteMapTmp.put(promote[0],promote[1]);
sWorkShopSetting.setPromoteMap(promoteMapTmp);
if(promote!=null&&promote.length>0){
promoteMapTmp.put(promote[0],promote[1]);
sWorkShopSetting.setPromoteMap(promoteMapTmp);
}
maxExpTmp+=sWorkShopSetting.getExp();
maxExpTmp+=sWorkShopSetting.getFoodExp();
sWorkShopSetting.setExp(exp);
int[][] poolWeight = sWorkShopSetting.getPoolRate();
if(poolWeight!=null && poolWeight.length>0){
int totalWeight = 0;
for(int[] poolWeightTmp : poolWeight){
totalWeight+=poolWeightTmp[1];
}
sWorkShopSetting.setCookTotalWeight(totalWeight);
}
}
sWorkShopSettingMap = sWorkShopSettingMapTmp;
maxExp = maxExpTmp;
maxCookExp = maxCookExpTmp;
}
public static int getMaxExp() {
return maxExp;
}
public static int getMaxCookExp() {
return maxCookExp;
}
public static SWorkShopSetting getsWorkShopSettingByLevel(int levle) {
return sWorkShopSettingMap.get(levle);
}
@ -75,4 +103,28 @@ public class SWorkShopSetting implements BaseConfig {
public void setExp(int exp) {
this.exp = exp;
}
public int getFoodExp() {
return foodExp;
}
public float getAddNum() {
return addNum;
}
public int[][] getPoolRate() {
return poolRate;
}
public float getAddSuccessRate() {
return addSuccessRate;
}
public int getCookTotalWeight() {
return cookTotalWeight;
}
public void setCookTotalWeight(int cookTotalWeight) {
this.cookTotalWeight = cookTotalWeight;
}
}

View File

@ -25,4 +25,8 @@ public interface GlobalsDef {
int WORK_SHOP_TYPE = 1; // 1工坊
int COOK_SHOP_TYPE = 2; //2百味居
//作坊解锁条件
int LEVLE_LOCK = 1; //1工坊熟练度等级解锁
int BLUE_LOCK = 2; //蓝图解锁
}

View File

@ -0,0 +1,26 @@
package com.ljsd.jieling.handler.workshop;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.item.WorkShopLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.protocols.PlayerInfoProto;
import org.springframework.stereotype.Component;
@Component
public class ActiviteWorkShopHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return null;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
byte[] bytes = netData.parseClientProtoNetData();
PlayerInfoProto.ActiviteWorkShopReqeust activiteWorkShopReqeust = PlayerInfoProto.ActiviteWorkShopReqeust.parseFrom(bytes);
int activiteId = activiteWorkShopReqeust.getActiviteId();
int type = activiteWorkShopReqeust.getType();
WorkShopLogic.getInstance().activeBlue(iSession,type,activiteId);
}
}

View File

@ -0,0 +1,21 @@
package com.ljsd.jieling.handler.workshop;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.item.WorkShopLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class GetWorkShopInfoHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.GET_WORKSHOP_INFO_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
WorkShopLogic.getInstance().getWorkShopInfo(iSession);
}
}

View File

@ -29,38 +29,11 @@ public class PlayerManager extends MongoBase {
private int mapId;
private int workShopLevel;
private int workShopExp;
private long createTime; //创建时间
private String clientVersion;
public void addWorkShopExp(int addExp) throws Exception {
int maxExp = SWorkShopSetting.getMaxExp();
if(this.workShopExp >= maxExp){
return;
}
SWorkShopSetting sWorkShopSetting = SWorkShopSetting.getsWorkShopSettingByLevel(this.workShopLevel + 1);
int needLevelExp;
if (sWorkShopSetting == null) {
needLevelExp = maxExp;
} else {
needLevelExp = sWorkShopSetting.getExp();
}
int curExp = MathUtils.setBetweenWithMax(this.workShopExp + addExp, 0, maxExp);
while(curExp>=needLevelExp && curExp <= maxExp){
setWorkShopLevel(this.workShopLevel++);
sWorkShopSetting = SWorkShopSetting.getsWorkShopSettingByLevel(this.workShopLevel + 1);
if(null == sWorkShopSetting){
needLevelExp = Integer.MAX_VALUE;
continue;
}
needLevelExp = sWorkShopSetting.getExp();
}
setWorkShopExp(curExp);
}
public String getOpenId() {
@ -179,21 +152,4 @@ public class PlayerManager extends MongoBase {
this.clientVersion = clientVersion;
}
public int getWorkShopLevel() {
return workShopLevel;
}
public void setWorkShopLevel(int workShopLevel) throws Exception {
updateString("workShopLevel", workShopLevel);
this.workShopLevel = workShopLevel;
}
public int getWorkShopExp() {
return workShopExp;
}
public void setWorkShopExp(int workShopExp) throws Exception {
updateString("workShopExp", workShopExp);
this.workShopExp = workShopExp;
}
}

View File

@ -0,0 +1,125 @@
package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.config.SWorkShopSetting;
import com.ljsd.jieling.util.MathUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class WorkShopController extends MongoBase {
private Map<Integer, List<Integer>> openBlueStateMap;
private int workShopLevel;
private int workShopExp;
private int cookLevel;
private int cookExp;
public WorkShopController(){
this.openBlueStateMap = new HashMap<>();
}
public void add(int type,int openId) throws Exception {
if(openBlueStateMap.containsKey(type)){
openBlueStateMap.put(type,new ArrayList<>());
}
openBlueStateMap.get(type).add(openId);
updateString("openBlueStateMap." + type,1);
}
public void addWorkShopExp(int addExp) throws Exception {
int maxExp = SWorkShopSetting.getMaxExp();
if(this.workShopExp >= maxExp){
return;
}
SWorkShopSetting sWorkShopSetting = SWorkShopSetting.getsWorkShopSettingByLevel(this.workShopLevel + 1);
int needLevelExp;
if (sWorkShopSetting == null) {
needLevelExp = maxExp;
} else {
needLevelExp = sWorkShopSetting.getExp();
}
int curExp = MathUtils.setBetweenWithMax(this.workShopExp + addExp, 0, maxExp);
while(curExp>=needLevelExp && curExp <= maxExp){
setWorkShopLevel(this.workShopLevel++);
sWorkShopSetting = SWorkShopSetting.getsWorkShopSettingByLevel(this.workShopLevel + 1);
if(null == sWorkShopSetting){
needLevelExp = Integer.MAX_VALUE;
continue;
}
needLevelExp = sWorkShopSetting.getExp();
}
setWorkShopExp(curExp);
}
public void addCookExp(int addExp) throws Exception {
int maxExp = SWorkShopSetting.getMaxCookExp();
if(this.cookExp >= maxExp){
return;
}
SWorkShopSetting sWorkShopSetting = SWorkShopSetting.getsWorkShopSettingByLevel(this.cookLevel + 1);
int needLevelExp;
if (sWorkShopSetting == null) {
needLevelExp = maxExp;
} else {
needLevelExp = sWorkShopSetting.getExp();
}
int curExp = MathUtils.setBetweenWithMax(this.cookExp + addExp, 0, maxExp);
while(curExp>=needLevelExp && curExp <= maxExp){
setWorkShopLevel(this.cookLevel++);
sWorkShopSetting = SWorkShopSetting.getsWorkShopSettingByLevel(this.cookLevel + 1);
if(null == sWorkShopSetting || sWorkShopSetting.getExp() == 0){
needLevelExp = Integer.MAX_VALUE;
continue;
}
needLevelExp = sWorkShopSetting.getExp();
}
setWorkShopExp(curExp);
}
public int getWorkShopLevel() {
return workShopLevel;
}
public void setWorkShopLevel(int workShopLevel) throws Exception {
updateString("workShopLevel", workShopLevel);
this.workShopLevel = workShopLevel;
}
public int getWorkShopExp() {
return workShopExp;
}
public void setWorkShopExp(int workShopExp) throws Exception {
updateString("workShopExp", workShopExp);
this.workShopExp = workShopExp;
}
public void setCookLevel(int cookLevel) throws Exception {
updateString("cookLevel", cookLevel);
this.cookLevel = cookLevel;
}
public void setCookExp(int cookExp) throws Exception {
updateString("cookExp", cookExp);
this.cookExp = cookExp;
}
public Map<Integer, List<Integer>> getOpenBlueStateMap() {
return openBlueStateMap;
}
public int getCookLevel() {
return cookLevel;
}
public int getCookExp() {
return cookExp;
}
}

View File

@ -1,17 +1,17 @@
package com.ljsd.jieling.logic.item;
import com.ljsd.jieling.config.SEquipConfig;
import com.ljsd.jieling.config.SWorkShopEquipmentConfig;
import com.ljsd.jieling.config.SWorkShopFoundationConfig;
import com.ljsd.jieling.config.SWorkShopRebuildConfig;
import com.ljsd.jieling.config.*;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.globals.GlobalItemType;
import com.ljsd.jieling.logic.dao.Equip;
import com.ljsd.jieling.logic.dao.EquipManager;
import com.ljsd.jieling.logic.dao.User;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.HeroInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.protocols.PlayerInfoProto;
import com.ljsd.jieling.util.CBean2Proto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MathUtils;
import com.ljsd.jieling.util.MessageUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory;
import java.util.*;
/**
*
*
*/
public class WorkShopLogic {
private static final Logger LOGGER = LoggerFactory.getLogger(WorkShopLogic.class);
@ -34,7 +34,78 @@ public class WorkShopLogic {
return WorkShopLogic.Instance.instance;
}
private SMysteryFoodPoolConfig randomFromFoodPool(int poolId){
List<SMysteryFoodPoolConfig> sMysteryFoodPoolConfigs = SMysteryFoodPoolConfig.getsMysteryFoodPoolConfigByPoold(poolId);
int totalWeightByPool = SMysteryFoodPoolConfig.getTotalWeightByPool(poolId);
int randomWeight = MathUtils.randomInt(totalWeightByPool) + 1;
int weight=0;
for(SMysteryFoodPoolConfig sMysteryFoodPoolConfig:sMysteryFoodPoolConfigs){
weight += sMysteryFoodPoolConfig.getWeight();
if(randomWeight>=weight){
return sMysteryFoodPoolConfig;
}
}
return null;
}
public void makeFood(ISession session,List<Integer> materials,int nums) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
SMysteryFoodSetting sMysteryFoodSetting = SMysteryFoodSetting.getsMysteryFoodSetting();
if(sMysteryFoodSetting.getNum() != materials.size()){
return;
}
PlayerManager playerInfoManager = user.getPlayerInfoManager();
SWorkShopSetting sWorkShopSetting = SWorkShopSetting.getsWorkShopSettingByLevel(playerInfoManager.getLevel());
float baseLevelRate = sWorkShopSetting.getAddSuccessRate();
float addRate =0.0f;
Map<Integer, Float> addRateByQuality = sMysteryFoodSetting.getAddRateByQuality();
for(Integer id : materials){
Map<Integer, SItem> integerSItemMap = SItem.getsItemMap();
SItem sItem = integerSItemMap.get(id);
if(!addRateByQuality.containsKey(sItem.getQuantity())){
continue;
}
addRate += addRateByQuality.get(sItem.getQuantity());
}
//算出概率
float myRate =baseLevelRate + addRate;
int poolTotalWeight = sWorkShopSetting.getCookTotalWeight() ;
int totalFailExp=0;
int[][] drop = new int[nums][];
int i=0;
while(nums--<0){
if(MathUtils.randomInt(100) < 100*myRate){
//筛选池子
int[][] poolWeight = sWorkShopSetting.getPoolRate();
int randomWeight = MathUtils.randomInt(poolTotalWeight)+1;
int weight=0;
for(int[] poolWeightInfo : poolWeight){
weight+=poolWeightInfo[1];
if(randomWeight>weight){
SMysteryFoodPoolConfig sMysteryFoodPoolConfig = randomFromFoodPool(poolWeightInfo[0]);
int itemId = sMysteryFoodPoolConfig.getItemId();
drop[i++] = new int[]{itemId,1};
totalFailExp+=sMysteryFoodPoolConfig.getExp();
}
}
}
//失败 熟练度加成
int failExp = sMysteryFoodSetting.getFailExp();
totalFailExp+=failExp;
}
CommonProto.Drop.Builder dropThing = ItemUtil.drop(user, drop);
if(totalFailExp>0){
user.getWorkShopController().addCookExp(totalFailExp);
}
}
private void times2Array(int [][] array,int times){
for(int[] a :array){
@ -42,11 +113,87 @@ public class WorkShopLogic {
}
}
private boolean checkIsUnlock(User user,int[] openRules){
int openType = openRules[0];
int openParm = openRules[1];
return true;
}
public void activeBlue(ISession session,int type,int functionId) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
//基础打造
if(type ==1){
SWorkShopFoundationConfig sWorkShopFoundationConfig = SWorkShopFoundationConfig.getShopFoundationConfigMap().get(functionId);
if(!checkForActiveUseBlue(user,sWorkShopFoundationConfig.getOpenRules())){
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ACTIVITE_WORKSHOP_RESPONSE_VALUE,"参数有误");
return;
}
}
//装备打造
if(type == 2){
SWorkShopEquipmentConfig sWorkShopEquipmentConfig = SWorkShopEquipmentConfig.getsWorkShopEquipmentConfigMap().get(functionId);
if(!checkForActiveUseBlue(user,sWorkShopEquipmentConfig.getOpenRules())){
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ACTIVITE_WORKSHOP_RESPONSE_VALUE,"参数有误");
return;
}
}
user.getWorkShopController().add(type,functionId);
//发送成功消息
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ACTIVITE_WORKSHOP_RESPONSE_VALUE,null,true);
}
private boolean checkForActiveUseBlue(User user,int[] openRules) throws Exception {
int openType = openRules[0];
int openParm = openRules[1];
if(openType!=GlobalsDef.BLUE_LOCK){
return false;
}
boolean enough = ItemUtil.itemCost(user, new int[][]{{openParm, 1}});
if(!enough){
return false;
}
return true;
}
public void getWorkShopInfo(ISession session) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
WorkShopController workShopController = user.getWorkShopController();
Map<Integer, List<Integer>> openBlueStateMap = workShopController.getOpenBlueStateMap();
int workShopLevel = workShopController.getWorkShopLevel();
int workShopExp = workShopController.getWorkShopExp();
int cookLevel = workShopController.getCookLevel();
int cookExp = workShopController.getCookExp();
List<Integer> workShopList = openBlueStateMap.get(GlobalsDef.WORK_SHOP_TYPE);
List<Integer> cookShopList = openBlueStateMap.get(GlobalsDef.COOK_SHOP_TYPE);
List<CommonProto.WorkShopInfo> workShopInfos = new ArrayList<>(2);
workShopInfos.add( CommonProto.WorkShopInfo.newBuilder().setType(GlobalsDef.WORK_SHOP_TYPE)
.setLevle(workShopLevel)
.setExp(workShopExp)
.addAllId(workShopList == null ? new ArrayList<>(1):workShopList)
.build());
workShopInfos.add( CommonProto.WorkShopInfo.newBuilder().setType(GlobalsDef.COOK_SHOP_TYPE)
.setLevle(cookLevel)
.setExp(cookExp)
.addAllId(cookShopList == null ? new ArrayList<>(1):cookShopList)
.build());
PlayerInfoProto.GetWorkShopInfoResponse build = PlayerInfoProto.GetWorkShopInfoResponse.newBuilder().addAllWorkShopInfo(workShopInfos).build();
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.GET_WORKSHOP_INFO_RESPONSE_VALUE,build,true);
}
//基础打造
public void createMaterialByUser(ISession session, int materialId, int nums) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
SWorkShopFoundationConfig sWorkShopFoundationConfig = SWorkShopFoundationConfig.getShopFoundationConfigMap().get(materialId);
checkIsUnlock(user,sWorkShopFoundationConfig.getOpenRules());
int[][] cost = sWorkShopFoundationConfig.getCost();
times2Array(cost,nums);
if( !ItemUtil.itemCost(user, cost)){
@ -57,51 +204,72 @@ public class WorkShopLogic {
finalMaterial.put(materialId,nums*sWorkShopFoundationConfig.getNum());
ItemUtil.addItem(user,finalMaterial,null);
//熟练度提升 TODO
//熟练度提升
int type = sWorkShopFoundationConfig.getType();
int addExp = sWorkShopFoundationConfig.getExp();
user.getPlayerInfoManager().addWorkShopExp(addExp);
if(type == GlobalsDef.WORK_SHOP_TYPE){
user.getWorkShopController().addWorkShopExp(addExp);
}else if( type == GlobalsDef.COOK_SHOP_TYPE){
user.getWorkShopController().addCookExp(addExp);
}
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_RESPONSE_VALUE,null,true);
}
//装备打造 TODO
public void createEquipByUser(ISession session, int equipTid, List<Integer> runneIdsList) throws Exception {
public void createEquipByUser(ISession session,int equipTid, List<Integer> runneIdsList) throws Exception {
int uid=session.getUid();
User user = UserManager.getUser(uid);
SWorkShopEquipmentConfig sWorkShopEquipmentConfig = SWorkShopEquipmentConfig.getsWorkShopEquipmentConfigMap().get(equipTid);
int runesNum = sWorkShopEquipmentConfig.getRunesNum();
int[] specialRunes = sWorkShopEquipmentConfig.getSpecialRunes();
int[][] specialRunes = sWorkShopEquipmentConfig.getSpecialRunes();
int needNums = runesNum - specialRunes.length;
if(runneIdsList.size()!=needNums){
MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_EQUIP_CREATE_RESPONSE_VALUE,"符文错误");
return;
}
int costLength = runesNum + 1;
int[] costMineral = sWorkShopEquipmentConfig.getMineral();
if(costMineral == null || costMineral.length == 0){
costLength = costLength-1;
}
int[][] costs = new int[costLength][];
if(costMineral!=null && costMineral.length>0){
costs[--costLength] =costMineral;
}
if(runneIdsList.size() ==0){
runneIdsList =new ArrayList<>(specialRunes.length);
}
for(Integer runneId : runneIdsList){
costs[--costLength] = new int[]{runneId, GlobalItemType.RUNNE};
costs[--costLength] = new int[]{runneId, 1};
}
for(Integer specialRunneId : specialRunes){
costs[--costLength] = new int[]{specialRunneId,GlobalItemType.RUNNE};
runneIdsList.add(specialRunneId);
for(int specialRunneId[] : specialRunes){
costs[--costLength] = new int[]{specialRunneId[0],specialRunneId[1]};
runneIdsList.add(specialRunneId[0]);
}
costs[--costLength] = sWorkShopEquipmentConfig.getMineral();
boolean enoughCost = ItemUtil.itemCost(user,costs);
if(!enoughCost){
MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_EQUIP_CREATE_RESPONSE_VALUE,"道具不足");
return;
}
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
//熟练度提升
int type = sWorkShopEquipmentConfig.getType();
int addExp = sWorkShopEquipmentConfig.getExp();
user.getPlayerInfoManager().addWorkShopExp(addExp);
Equip equip = new Equip(Integer.toString(uid), equipTid, user.getPlayerInfoManager().getWorkShopLevel(),runneIdsList);
user.getEquipManager().addEquip(equip);
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.WORKSHOP_EQUIP_CREATE_RESPONSE_VALUE,null,true);
if(type == GlobalsDef.WORK_SHOP_TYPE){
user.getWorkShopController().addWorkShopExp(addExp);
Equip equip = new Equip(Integer.toString(uid), equipTid, user.getWorkShopController().getWorkShopLevel(),runneIdsList);
user.getEquipManager().addEquip(equip);
dropBuilder.addEquipId(CBean2Proto.getEquipProto(equip));
}else if( type == GlobalsDef.COOK_SHOP_TYPE){
user.getWorkShopController().addCookExp(addExp);
Map<Integer,Integer> items = new HashMap<>();
items.put(equipTid,SMysteryFoodSetting.getsMysteryFoodSetting().getFoodNum());
ItemUtil.addItem(user,items,dropBuilder);
}
PlayerInfoProto.WorkShopEquipCreateResponse build = PlayerInfoProto.WorkShopEquipCreateResponse.newBuilder().setType(type).setDrop(dropBuilder).build();
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.WORKSHOP_EQUIP_CREATE_RESPONSE_VALUE,build,true);
}
//装备重铸
@ -122,7 +290,7 @@ public class WorkShopLogic {
return;
}
equip.rebuildEquip(user.getPlayerInfoManager().getWorkShopLevel());
equip.rebuildEquip(user.getWorkShopController().getWorkShopLevel());
equipManager.addEquip(equip);
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.WORKSHOP_REBUILD_RESPONSE_VALUE,null,true);

View File

@ -20,8 +20,6 @@ public class CBean2Proto {
.setVipLevel(playerManager.getVipLevel())
.setFamilyId(playerManager.getFamilyId())
.setHead(playerManager.getHead())
.setWorkLevel(playerManager.getWorkShopLevel())
.setWorkExp(playerManager.getWorkShopExp())
.build();
return player;
}

View File

@ -7,7 +7,7 @@ import java.util.*;
public class ExcelUtils {
private static boolean isWrite = true;
private static String excelPath ="D:/tmp/"; //excel 文件
private static String excelPath ="D:/jieling_client/data_execl/map/"; //excel 文件
private static String path = "conf/server/";
private static Set<String> oldFileNames = new HashSet<>();
private static String javaFilePath = "serverlogic/src/main/java/com/ljsd/jieling/config/";