百味居
parent
e9dc4a0439
commit
3ef502dd5f
|
@ -1,2 +1,2 @@
|
|||
Id AddRate FailExp
|
||||
int mut,float#float,1 int
|
||||
Id AddRate FailExp FoodNum
|
||||
int mut,float#float,2 int int
|
||||
|
|
|
@ -1,77 +1,77 @@
|
|||
Id Type OpenRules Mineral RunesNum SpecialRunes Exp
|
||||
int int mut,int#int,1 mut,int#int,1 int mut,int#int,1 int
|
||||
3001 1 null 1007#1 1 null 0
|
||||
3002 1 null 1007#1 2 null 0
|
||||
3003 1 null 1007#1 1 null 0
|
||||
3004 1 null 1007#1 2 null 0
|
||||
3005 1 null 1007#1 1 null 0
|
||||
3006 1 null 1007#1 2 null 0
|
||||
3007 1 null 1007#1 1 null 0
|
||||
3008 1 null 1007#1 2 null 0
|
||||
3009 1 null 1007#1 1 null 0
|
||||
3010 1 null 1007#1 2 null 0
|
||||
3011 1 null 1007#1 1 null 0
|
||||
3012 1 null 1007#1 2 null 0
|
||||
3013 1 null 1007#1 1 null 0
|
||||
3014 1 null 1007#1 2 null 0
|
||||
3015 1 null 1007#1 1 null 0
|
||||
3016 1 null 1007#1 2 null 0
|
||||
3017 1 null 1007#1 1 null 0
|
||||
3018 1 null 1007#1 2 null 0
|
||||
3101 1 null 1007#1 1 null 0
|
||||
3102 1 null 1007#1 2 null 0
|
||||
3103 1 null 1007#1 1 null 0
|
||||
3104 1 null 1007#1 2 null 0
|
||||
3105 1 null 1007#1 1 null 0
|
||||
3106 1 null 1007#1 2 null 0
|
||||
3107 1 null 1007#1 1 null 0
|
||||
3108 1 null 1007#1 2 null 0
|
||||
3109 1 null 1007#1 1 null 0
|
||||
3110 1 null 1007#1 2 null 0
|
||||
3111 1 null 1007#1 1 null 0
|
||||
3112 1 null 1007#1 2 null 0
|
||||
3113 1 null 1007#1 1 null 0
|
||||
3114 1 null 1007#1 2 null 0
|
||||
3115 1 null 1007#1 1 null 0
|
||||
3116 1 null 1007#1 2 null 0
|
||||
3117 1 null 1007#1 1 null 0
|
||||
3118 1 null 1007#1 2 null 0
|
||||
3201 1 null 1008#1 1 null 0
|
||||
3202 1 null 1008#1 2 null 0
|
||||
3203 1 null 1008#1 1 null 0
|
||||
3204 1 null 1008#1 2 null 0
|
||||
3205 1 null 1008#1 1 null 0
|
||||
3206 1 null 1008#1 2 null 0
|
||||
3207 1 null 1008#1 1 null 0
|
||||
3208 1 null 1008#1 2 null 0
|
||||
3209 1 null 1008#1 1 null 0
|
||||
3210 1 null 1008#1 2 null 0
|
||||
3211 1 null 1008#1 1 null 0
|
||||
3212 1 null 1008#1 2 null 0
|
||||
3213 1 null 1008#1 1 null 0
|
||||
3214 1 null 1008#1 2 null 0
|
||||
3215 1 null 1008#1 1 null 0
|
||||
3216 1 null 1008#1 2 null 0
|
||||
3217 1 null 1008#1 1 null 0
|
||||
3218 1 null 1008#1 2 null 0
|
||||
3301 1 null 1009#1 1 null 0
|
||||
3302 1 null 1009#1 2 null 0
|
||||
3303 1 null 1009#1 1 null 0
|
||||
3304 1 null 1009#1 2 null 0
|
||||
3305 1 null 1009#1 1 null 0
|
||||
3306 1 null 1009#1 2 null 0
|
||||
3307 1 null 1009#1 1 null 0
|
||||
3308 1 null 1009#1 2 null 0
|
||||
3309 1 null 1009#1 1 null 0
|
||||
3310 1 null 1009#1 2 null 0
|
||||
3311 1 null 1009#1 1 null 0
|
||||
3312 1 null 1009#1 2 null 0
|
||||
3313 1 null 1009#1 1 null 0
|
||||
3314 1 null 1009#1 2 null 0
|
||||
3315 1 null 1009#1 1 null 0
|
||||
3316 1 null 1009#1 2 null 0
|
||||
3317 1 null 1009#1 1 null 0
|
||||
3318 1 null 1009#1 2 null 0
|
||||
int int mut,int#int,1 mut,int#int,1 int mut,int#int,2 int
|
||||
3001 1 1#1 1007#1 1 null 0
|
||||
3002 1 1#1 1007#1 2 null 0
|
||||
3003 1 1#1 1007#1 1 null 0
|
||||
3004 1 1#1 1007#1 2 null 0
|
||||
3005 1 1#1 1007#1 1 null 0
|
||||
3006 1 1#1 1007#1 2 null 0
|
||||
3007 1 1#1 1007#1 1 null 0
|
||||
3008 1 1#1 1007#1 2 null 0
|
||||
3009 1 1#1 1007#1 1 null 0
|
||||
3010 1 1#1 1007#1 2 null 0
|
||||
3011 1 1#1 1007#1 1 null 0
|
||||
3012 1 1#1 1007#1 2 null 0
|
||||
3013 1 1#1 1007#1 1 null 0
|
||||
3014 1 1#1 1007#1 2 null 0
|
||||
3015 1 1#1 1007#1 1 null 0
|
||||
3016 1 1#1 1007#1 2 null 0
|
||||
3017 1 1#1 1007#1 1 null 0
|
||||
3018 1 1#1 1007#1 2 null 0
|
||||
3101 1 1#1 1007#1 1 null 0
|
||||
3102 1 1#1 1007#1 2 null 0
|
||||
3103 1 1#1 1007#1 1 null 0
|
||||
3104 1 1#1 1007#1 2 null 0
|
||||
3105 1 1#1 1007#1 1 null 0
|
||||
3106 1 1#1 1007#1 2 null 0
|
||||
3107 1 1#1 1007#1 1 null 0
|
||||
3108 1 1#1 1007#1 2 null 0
|
||||
3109 1 1#1 1007#1 1 null 0
|
||||
3110 1 1#1 1007#1 2 null 0
|
||||
3111 1 1#1 1007#1 1 null 0
|
||||
3112 1 1#1 1007#1 2 null 0
|
||||
3113 1 1#1 1007#1 1 null 0
|
||||
3114 1 1#1 1007#1 2 null 0
|
||||
3115 1 1#2 1007#1 1 null 0
|
||||
3116 1 1#3 1007#1 2 null 0
|
||||
3117 1 1#4 1007#1 1 null 0
|
||||
3118 1 1#5 1007#1 2 null 0
|
||||
3201 1 1#6 1008#1 1 null 0
|
||||
3202 1 1#7 1008#1 2 null 0
|
||||
3203 1 1#8 1008#1 1 null 0
|
||||
3204 1 1#9 1008#1 2 null 0
|
||||
3205 1 1#10 1008#1 1 null 0
|
||||
3206 1 1#11 1008#1 2 null 0
|
||||
3207 1 1#12 1008#1 1 null 0
|
||||
3208 1 1#13 1008#1 2 null 0
|
||||
3209 1 1#14 1008#1 1 null 0
|
||||
3210 1 1#15 1008#1 2 null 0
|
||||
3211 1 1#16 1008#1 1 null 0
|
||||
3212 1 1#17 1008#1 2 null 0
|
||||
3213 1 1#18 1008#1 1 null 0
|
||||
3214 1 1#19 1008#1 2 null 0
|
||||
3215 1 1#20 1008#1 1 null 0
|
||||
3216 1 1#21 1008#1 2 null 0
|
||||
3217 1 1#22 1008#1 1 null 0
|
||||
3218 1 1#23 1008#1 2 null 0
|
||||
3301 1 1#24 1009#1 1 null 0
|
||||
3302 1 1#25 1009#1 2 null 0
|
||||
3303 1 1#26 1009#1 1 null 0
|
||||
3304 1 1#27 1009#1 2 null 0
|
||||
3305 1 1#28 1009#1 1 null 0
|
||||
3306 1 1#29 1009#1 2 null 0
|
||||
3307 1 1#30 1009#1 1 null 0
|
||||
3308 1 1#31 1009#1 2 null 0
|
||||
3309 1 1#32 1009#1 1 null 0
|
||||
3310 1 1#33 1009#1 2 null 0
|
||||
3311 1 1#34 1009#1 1 null 0
|
||||
3312 1 1#35 1009#1 2 null 0
|
||||
3313 1 1#36 1009#1 1 null 0
|
||||
3314 1 1#37 1009#1 2 null 0
|
||||
3315 1 1#38 1009#1 1 null 0
|
||||
3316 1 1#39 1009#1 2 null 0
|
||||
3317 1 1#40 1009#1 1 null 0
|
||||
3318 1 1#41 1009#1 2 null 0
|
||||
4001 1 2#7001 1008#1 2 null 0
|
||||
4002 1 2#7002 1008#1 2 null 0
|
||||
4003 1 2#7003 1008#1 2 null 0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Id Type OpenRules Cost Exp Num
|
||||
int int mut,int#int,1 mut,int#int,2 int int
|
||||
1007 0 null null 0 0
|
||||
1008 0 null null 0 0
|
||||
1009 0 null null 0 0
|
||||
1007 1 1#1 1005#100 1 5
|
||||
1008 1 1#2 1005#101 1 5
|
||||
1009 1 1#3 1005#102 1 5
|
||||
0 0 null null 0 0
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Id Exp Promote FoodExp AddNum PoolRate AddSuccessRate
|
||||
int int mut,int#int,1 int float mut,float#float,1 float
|
||||
int int mut,int#int,1 int float mut,int#int,2 float
|
||||
0 0 null 0 0.0 null 0.0
|
||||
1 1000 1#1 0 0.0 null 0.0
|
||||
2 1500 2#1 0 0.0 null 0.0
|
||||
|
@ -14,7 +14,7 @@ int int mut,int#int,1 int float mut,float#float,1 float
|
|||
11 6000 1#6 0 0.0 null 0.0
|
||||
12 6500 2#6 0 0.0 null 0.0
|
||||
13 7000 3#6 0 0.0 null 0.0
|
||||
14 7500 4#6 0 0.0 null 0.0
|
||||
14 7500 4#6 0 0 null 0.0
|
||||
15 8000 5#6 0 0.0 null 0.0
|
||||
16 8500 1#10 0 0.0 null 0.0
|
||||
17 9000 2#10 0 0.0 null 0.0
|
||||
|
|
|
@ -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,19 +11,32 @@ public class SMysteryFoodSetting implements BaseConfig {
|
|||
|
||||
private int id;
|
||||
|
||||
private float[] addRate;
|
||||
private float[][] addRate;
|
||||
|
||||
private int failExp;
|
||||
|
||||
private int num;
|
||||
|
||||
private static SMysteryFoodSetting sMysteryFoodSetting;
|
||||
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 = config.get(1);
|
||||
/* 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() {
|
||||
|
@ -33,7 +47,7 @@ public class SMysteryFoodSetting implements BaseConfig {
|
|||
return id;
|
||||
}
|
||||
|
||||
public float[] getAddRate() {
|
||||
public float[][] getAddRate() {
|
||||
return addRate;
|
||||
}
|
||||
|
||||
|
@ -44,4 +58,16 @@ public class SMysteryFoodSetting implements BaseConfig {
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,14 +19,18 @@ public class SWorkShopSetting implements BaseConfig {
|
|||
|
||||
private float addNum;
|
||||
|
||||
private float[] poolRate;
|
||||
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;
|
||||
|
||||
|
@ -36,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);
|
||||
}
|
||||
|
@ -92,11 +112,19 @@ public class SWorkShopSetting implements BaseConfig {
|
|||
return addNum;
|
||||
}
|
||||
|
||||
public float[] getPoolRate() {
|
||||
public int[][] getPoolRate() {
|
||||
return poolRate;
|
||||
}
|
||||
|
||||
public float getAddSuccessRate() {
|
||||
return addSuccessRate;
|
||||
}
|
||||
|
||||
public int getCookTotalWeight() {
|
||||
return cookTotalWeight;
|
||||
}
|
||||
|
||||
public void setCookTotalWeight(int cookTotalWeight) {
|
||||
this.cookTotalWeight = cookTotalWeight;
|
||||
}
|
||||
}
|
|
@ -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; //蓝图解锁
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ public class User extends MongoRoot {
|
|||
|
||||
private PokemonManager pokemonManager;
|
||||
|
||||
private WorkShopController workShopController;
|
||||
|
||||
|
||||
|
||||
public User(int uid, PlayerManager playerManager, ItemManager itemManager,
|
||||
|
@ -44,6 +46,7 @@ public class User extends MongoRoot {
|
|||
this.equipManager = new EquipManager();
|
||||
this.adventureManager = new AdventureManager();
|
||||
this.pokemonManager = new PokemonManager();
|
||||
this.workShopController = new WorkShopController();
|
||||
|
||||
//綁定关系
|
||||
this.playerManager.init(this, "playerManager", false);
|
||||
|
@ -56,6 +59,7 @@ public class User extends MongoRoot {
|
|||
this.equipManager.init(this,"equipManager",false);
|
||||
this.adventureManager.init(this,"adventureManager",false);
|
||||
this.pokemonManager.init(this,"pokemonManager",false);
|
||||
// this.workShopController.init(this,"workShopController",false);
|
||||
}
|
||||
|
||||
public User(){
|
||||
|
@ -77,6 +81,7 @@ public class User extends MongoRoot {
|
|||
missionManager.init(this, "missionManager", false);
|
||||
adventureManager.init(this,"adventureManager",false);
|
||||
pokemonManager.init(this,"pokemonManager",false);
|
||||
// workShopController.init(this,"workShopController",false);
|
||||
}
|
||||
|
||||
public static void init(LjsdMongoTemplate ljsdMongoTemplate) {
|
||||
|
@ -155,4 +160,8 @@ public class User extends MongoRoot {
|
|||
public MissionManager getMissionManager() {
|
||||
return missionManager;
|
||||
}
|
||||
|
||||
public WorkShopController getWorkShopController() {
|
||||
return workShopController;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,13 +1,15 @@
|
|||
package com.ljsd.jieling.logic.item;
|
||||
|
||||
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;
|
||||
|
@ -46,21 +48,60 @@ public class WorkShopLogic {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void makeFood(ISession session,List<Integer> materials,int nums){
|
||||
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;
|
||||
}
|
||||
float[] addRate = sMysteryFoodSetting.getAddRate();
|
||||
//算出概率
|
||||
float myRate = 0.2f;
|
||||
int totalWeight = 100;
|
||||
//成功
|
||||
if(MathUtils.randomInt(totalWeight) < totalWeight*myRate){
|
||||
|
||||
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());
|
||||
}
|
||||
//失败 熟练度加成
|
||||
int failExp = sMysteryFoodSetting.getFailExp();
|
||||
//算出概率
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -72,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)){
|
||||
|
@ -87,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);
|
||||
}
|
||||
|
||||
//装备重铸
|
||||
|
@ -152,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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue