Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
58e335b60e
|
@ -12,10 +12,14 @@ public class SWorkShopSetting implements BaseConfig {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
private int exp;
|
private int[][] exp;
|
||||||
|
|
||||||
private int[] promote;
|
private int[] promote;
|
||||||
|
|
||||||
|
private int technologyLevel;
|
||||||
|
|
||||||
|
private int[] unravelItem;
|
||||||
|
|
||||||
private int foodExp;
|
private int foodExp;
|
||||||
|
|
||||||
private float addNum;
|
private float addNum;
|
||||||
|
@ -28,10 +32,7 @@ public class SWorkShopSetting implements BaseConfig {
|
||||||
|
|
||||||
private int cookTotalWeight;
|
private int cookTotalWeight;
|
||||||
|
|
||||||
private static int maxExp;
|
private static int maxLevel;
|
||||||
|
|
||||||
private static int maxCookExp;
|
|
||||||
|
|
||||||
|
|
||||||
private static Map<Integer,SWorkShopSetting> sWorkShopSettingMap;
|
private static Map<Integer,SWorkShopSetting> sWorkShopSettingMap;
|
||||||
|
|
||||||
|
@ -40,8 +41,7 @@ public class SWorkShopSetting implements BaseConfig {
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
Map<Integer, SWorkShopSetting> sWorkShopSettingMapTmp = sWorkShopSettingMap = STableManager.getConfig(SWorkShopSetting.class);
|
Map<Integer, SWorkShopSetting> sWorkShopSettingMapTmp = sWorkShopSettingMap = STableManager.getConfig(SWorkShopSetting.class);
|
||||||
Map<Integer,Integer> promoteMapTmp = new HashMap<>();
|
Map<Integer,Integer> promoteMapTmp = new HashMap<>();
|
||||||
int maxExpTmp = 0;
|
int maxLevel = 0;
|
||||||
int maxCookExpTmp = 0;
|
|
||||||
for(SWorkShopSetting sWorkShopSetting : sWorkShopSettingMapTmp.values()){
|
for(SWorkShopSetting sWorkShopSetting : sWorkShopSettingMapTmp.values()){
|
||||||
Map<Integer,Integer> promoteMapTmptm = new HashMap<>(promoteMapTmp);
|
Map<Integer,Integer> promoteMapTmptm = new HashMap<>(promoteMapTmp);
|
||||||
int[] promote = sWorkShopSetting.getPromote();
|
int[] promote = sWorkShopSetting.getPromote();
|
||||||
|
@ -51,8 +51,7 @@ public class SWorkShopSetting implements BaseConfig {
|
||||||
promoteMapTmptm.put(promote[0],promote[1]);
|
promoteMapTmptm.put(promote[0],promote[1]);
|
||||||
sWorkShopSetting.setPromoteMap(promoteMapTmptm);
|
sWorkShopSetting.setPromoteMap(promoteMapTmptm);
|
||||||
}
|
}
|
||||||
maxExpTmp = MathUtils.getMaxNum(maxExpTmp,sWorkShopSetting.getExp());
|
maxLevel = MathUtils.getMaxNum(maxLevel,sWorkShopSetting.getId());
|
||||||
maxCookExpTmp=MathUtils.getMaxNum(maxExpTmp,sWorkShopSetting.getFoodExp());
|
|
||||||
int[][] poolWeight = sWorkShopSetting.getPoolRate();
|
int[][] poolWeight = sWorkShopSetting.getPoolRate();
|
||||||
if(poolWeight!=null && poolWeight.length>0){
|
if(poolWeight!=null && poolWeight.length>0){
|
||||||
int totalWeight = 0;
|
int totalWeight = 0;
|
||||||
|
@ -64,27 +63,22 @@ public class SWorkShopSetting implements BaseConfig {
|
||||||
|
|
||||||
}
|
}
|
||||||
sWorkShopSettingMap = sWorkShopSettingMapTmp;
|
sWorkShopSettingMap = sWorkShopSettingMapTmp;
|
||||||
maxExp = maxExpTmp;
|
this.maxLevel = maxLevel;
|
||||||
maxCookExp = maxCookExpTmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMaxExp() {
|
public static int getMaxLevel() {
|
||||||
return maxExp;
|
return maxLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMaxCookExp() {
|
public static SWorkShopSetting getsWorkShopSettingByLevel(int level) {
|
||||||
return maxCookExp;
|
return sWorkShopSettingMap.get(level);
|
||||||
}
|
|
||||||
|
|
||||||
public static SWorkShopSetting getsWorkShopSettingByLevel(int levle) {
|
|
||||||
return sWorkShopSettingMap.get(levle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExp() {
|
public int[][] getExp() {
|
||||||
return exp;
|
return exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,18 +94,10 @@ public class SWorkShopSetting implements BaseConfig {
|
||||||
this.promoteMap = promoteMap;
|
this.promoteMap = promoteMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExp(int exp) {
|
public void setExp(int[][] exp) {
|
||||||
this.exp = exp;
|
this.exp = exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFoodExp() {
|
|
||||||
return foodExp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getAddNum() {
|
|
||||||
return addNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[][] getPoolRate() {
|
public int[][] getPoolRate() {
|
||||||
return poolRate;
|
return poolRate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 WorkShopLevelUpHandler extends BaseHandler {
|
||||||
|
@Override
|
||||||
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
|
return MessageTypeProto.MessageType.WORKSHOP_LEVELUP_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||||
|
WorkShopLogic.getInstance().workShopLevelUp(iSession);
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,62 +38,6 @@ public class WorkShopController extends MongoBase {
|
||||||
updateString("openBlueStateMap." + type, openBlueStateMap.get(type));
|
updateString("openBlueStateMap." + type, openBlueStateMap.get(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addWorkShopExp(User user,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);
|
|
||||||
int oldLevel = this.workShopLevel;
|
|
||||||
while(curExp>=needLevelExp && curExp <= maxExp){
|
|
||||||
setWorkShopLevel(this.workShopLevel+1);
|
|
||||||
sWorkShopSetting = SWorkShopSetting.getsWorkShopSettingByLevel(this.workShopLevel + 1);
|
|
||||||
if(null == sWorkShopSetting){
|
|
||||||
needLevelExp = Integer.MAX_VALUE;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
needLevelExp = sWorkShopSetting.getExp();
|
|
||||||
}
|
|
||||||
if(this.workShopLevel>oldLevel){
|
|
||||||
user.getUserMissionManager().onGameEvent(user,GameEvent.WORKSHOP_LEVELUP,oldLevel,this.workShopLevel);
|
|
||||||
}
|
|
||||||
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+1);
|
|
||||||
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() {
|
public int getWorkShopLevel() {
|
||||||
return workShopLevel;
|
return workShopLevel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,9 +105,7 @@ public class WorkShopLogic {
|
||||||
totalFailExp+=failExp;
|
totalFailExp+=failExp;
|
||||||
}
|
}
|
||||||
CommonProto.Drop.Builder dropThing = ItemUtil.drop(user, drop,BIReason.WORKSHOP_MAKEFOOD);
|
CommonProto.Drop.Builder dropThing = ItemUtil.drop(user, drop,BIReason.WORKSHOP_MAKEFOOD);
|
||||||
if(totalFailExp>0){
|
|
||||||
user.getWorkShopController().addCookExp(totalFailExp);
|
|
||||||
}
|
|
||||||
|
|
||||||
CommonProto.WorkShopBaseInfo workShopBaseInfo = CommonProto.WorkShopBaseInfo.newBuilder().setType(GlobalsDef.COOK_SHOP_TYPE).setLevle(workShopController.getCookLevel()).setExp(workShopController.getCookExp()).build();
|
CommonProto.WorkShopBaseInfo workShopBaseInfo = CommonProto.WorkShopBaseInfo.newBuilder().setType(GlobalsDef.COOK_SHOP_TYPE).setLevle(workShopController.getCookLevel()).setExp(workShopController.getCookExp()).build();
|
||||||
PlayerInfoProto.CookFoodResponse build = PlayerInfoProto.CookFoodResponse.newBuilder().setWorkShopBaseInfo(workShopBaseInfo).setDrop(dropThing).build();
|
PlayerInfoProto.CookFoodResponse build = PlayerInfoProto.CookFoodResponse.newBuilder().setWorkShopBaseInfo(workShopBaseInfo).setDrop(dropThing).build();
|
||||||
|
@ -245,11 +243,7 @@ public class WorkShopLogic {
|
||||||
//熟练度提升
|
//熟练度提升
|
||||||
int type = sWorkShopFoundationConfig.getType();
|
int type = sWorkShopFoundationConfig.getType();
|
||||||
int addExp = sWorkShopFoundationConfig.getExp()*nums;
|
int addExp = sWorkShopFoundationConfig.getExp()*nums;
|
||||||
if(type == GlobalsDef.WORK_SHOP_TYPE){
|
|
||||||
user.getWorkShopController().addWorkShopExp(user,addExp);
|
|
||||||
}else if( type == GlobalsDef.COOK_SHOP_TYPE){
|
|
||||||
user.getWorkShopController().addCookExp(addExp);
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_RESPONSE_VALUE,null,true);
|
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_RESPONSE_VALUE,null,true);
|
||||||
}
|
}
|
||||||
|
@ -309,10 +303,8 @@ public class WorkShopLogic {
|
||||||
user.getEquipManager().addEquip(user,equip);
|
user.getEquipManager().addEquip(user,equip);
|
||||||
dropBuilder.addEquipId(CBean2Proto.getEquipProto(equip));
|
dropBuilder.addEquipId(CBean2Proto.getEquipProto(equip));
|
||||||
}
|
}
|
||||||
user.getWorkShopController().addWorkShopExp(user,addExp);
|
|
||||||
user.getUserMissionManager().onGameEvent(user, GameEvent.WORKSHOP_CREATE_EQUIP,nums);
|
user.getUserMissionManager().onGameEvent(user, GameEvent.WORKSHOP_CREATE_EQUIP,nums);
|
||||||
}else if( type == GlobalsDef.COOK_SHOP_TYPE){
|
}else if( type == GlobalsDef.COOK_SHOP_TYPE){
|
||||||
user.getWorkShopController().addCookExp(addExp);
|
|
||||||
Map<Integer,Integer> items = new HashMap<>();
|
Map<Integer,Integer> items = new HashMap<>();
|
||||||
items.put(equipTid,SMysteryFoodSetting.getsMysteryFoodSetting().getFoodNum()*nums);
|
items.put(equipTid,SMysteryFoodSetting.getsMysteryFoodSetting().getFoodNum()*nums);
|
||||||
ItemUtil.addItem(user,items,dropBuilder,BIReason.WORKSHOP_CREATEQUIP);
|
ItemUtil.addItem(user,items,dropBuilder,BIReason.WORKSHOP_CREATEQUIP);
|
||||||
|
@ -343,7 +335,6 @@ public class WorkShopLogic {
|
||||||
clone.rebuildEquip(user.getWorkShopController().getWorkShopLevel());
|
clone.rebuildEquip(user.getWorkShopController().getWorkShopLevel());
|
||||||
equipManager.setUnDetermined(clone);
|
equipManager.setUnDetermined(clone);
|
||||||
int addExp = sWorkShopRebuildConfig.getExp();
|
int addExp = sWorkShopRebuildConfig.getExp();
|
||||||
user.getWorkShopController().addWorkShopExp(user,addExp);
|
|
||||||
PlayerInfoProto.WorkShopRebuildRespoonse build = PlayerInfoProto.WorkShopRebuildRespoonse.newBuilder().setEquip(CBean2Proto.getEquipProto(clone)).build();
|
PlayerInfoProto.WorkShopRebuildRespoonse build = PlayerInfoProto.WorkShopRebuildRespoonse.newBuilder().setEquip(CBean2Proto.getEquipProto(clone)).build();
|
||||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.WORKSHOP_REBUILD_RESPONSE_VALUE,build,true);
|
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.WORKSHOP_REBUILD_RESPONSE_VALUE,build,true);
|
||||||
}
|
}
|
||||||
|
@ -409,4 +400,23 @@ public class WorkShopLogic {
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
public void workShopLevelUp(ISession session)throws Exception{
|
||||||
|
int uid = session.getUid();
|
||||||
|
User user = UserManager.getUser(uid);
|
||||||
|
WorkShopController controller = user.getWorkShopController();
|
||||||
|
int currLevel = controller.getWorkShopLevel();
|
||||||
|
SWorkShopSetting shopSetting = SWorkShopSetting.getsWorkShopSettingByLevel(currLevel);
|
||||||
|
int[][] itemInfo = shopSetting.getExp();
|
||||||
|
if(currLevel>=SWorkShopSetting.getMaxLevel()){
|
||||||
|
MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_LEVELUP_RESPONSE_VALUE,"已满级");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boolean costResult = ItemUtil.itemCost(user,itemInfo,1,1);
|
||||||
|
if(costResult){
|
||||||
|
controller.setWorkShopLevel(currLevel+1);
|
||||||
|
MessageUtil.sendMessage(uid,1,MessageTypeProto.MessageType.WORKSHOP_LEVELUP_RESPONSE_VALUE,null,true);
|
||||||
|
}else{
|
||||||
|
MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_LEVELUP_RESPONSE_VALUE,"道具不足");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue