From e9dc4a0439a483aadc0bbb24946e3838ea6fdcf2 Mon Sep 17 00:00:00 2001 From: wangyuan Date: Mon, 4 Mar 2019 09:20:45 +0800 Subject: [PATCH 1/2] table fix --- conf/server/WorkShopSetting.txt | 202 +++++++++--------- .../config/SMysteryFoodPoolConfig.java | 30 ++- .../jieling/config/SMysteryFoodSetting.java | 20 +- .../ljsd/jieling/config/SWorkShopSetting.java | 24 +++ .../jieling/logic/item/WorkShopLogic.java | 40 +++- .../src/main/resources/application.properties | 4 +- 6 files changed, 203 insertions(+), 117 deletions(-) diff --git a/conf/server/WorkShopSetting.txt b/conf/server/WorkShopSetting.txt index a52afea70..838d3fa43 100644 --- a/conf/server/WorkShopSetting.txt +++ b/conf/server/WorkShopSetting.txt @@ -1,103 +1,103 @@ Id Exp Promote FoodExp AddNum PoolRate AddSuccessRate int int mut,int#int,1 int float mut,float#float,1 float -0 0 null 0 int null 0.0 -1 1000 1#1 0 int null 0.0 -2 1500 2#1 0 int null 0.0 -3 2000 3#1 0 int null 0.0 -4 2500 4#1 0 int null 0.0 -5 2500 5#1 0 int null 0.0 -6 3500 1#3 0 int null 0.0 -7 4000 2#3 0 int null 0.0 -8 4500 3#3 0 int null 0.0 -9 5000 4#3 0 int null 0.0 -10 5500 5#3 0 int null 0.0 -11 6000 1#6 0 int null 0.0 -12 6500 2#6 0 int null 0.0 -13 7000 3#6 0 int null 0.0 -14 7500 4#6 0 int null 0.0 -15 8000 5#6 0 int null 0.0 -16 8500 1#10 0 int null 0.0 -17 9000 2#10 0 int null 0.0 -18 9500 3#10 0 int null 0.0 -19 10000 4#10 0 int null 0.0 -20 10500 5#10 0 int null 0.0 -21 11000 1#15 0 int null 0.0 -22 11500 2#15 0 int null 0.0 -23 12000 3#15 0 int null 0.0 -24 12500 4#15 0 int null 0.0 -25 13000 5#15 0 int null 0.0 -26 13500 1#21 0 int null 0.0 -27 14000 2#21 0 int null 0.0 -28 14500 3#21 0 int null 0.0 -29 15000 4#21 0 int null 0.0 -30 15500 5#21 0 int null 0.0 -31 16000 1#28 0 int null 0.0 -32 16500 2#28 0 int null 0.0 -33 17000 3#28 0 int null 0.0 -34 17500 4#28 0 int null 0.0 -35 18000 5#28 0 int null 0.0 -36 18500 1#36 0 int null 0.0 -37 19000 2#36 0 int null 0.0 -38 19500 3#36 0 int null 0.0 -39 20000 4#36 0 int null 0.0 -40 20500 5#36 0 int null 0.0 -41 21000 1#45 0 int null 0.0 -42 21500 2#45 0 int null 0.0 -43 22000 3#45 0 int null 0.0 -44 22500 4#45 0 int null 0.0 -45 23000 5#45 0 int null 0.0 -46 23500 1#55 0 int null 0.0 -47 24000 2#55 0 int null 0.0 -48 24500 3#55 0 int null 0.0 -49 25000 4#55 0 int null 0.0 -50 25500 5#55 0 int null 0.0 -51 26000 1#65 0 int null 0.0 -52 26500 2#65 0 int null 0.0 -53 27000 3#65 0 int null 0.0 -54 27500 4#65 0 int null 0.0 -55 28000 5#65 0 int null 0.0 -56 28500 1#76 0 int null 0.0 -57 29000 2#76 0 int null 0.0 -58 29500 3#76 0 int null 0.0 -59 30000 4#76 0 int null 0.0 -60 30500 5#76 0 int null 0.0 -61 31000 1#88 0 int null 0.0 -62 31500 2#88 0 int null 0.0 -63 32000 3#88 0 int null 0.0 -64 32500 4#88 0 int null 0.0 -65 33000 5#88 0 int null 0.0 -66 33500 1#101 0 int null 0.0 -67 34000 2#101 0 int null 0.0 -68 34500 3#101 0 int null 0.0 -69 35000 4#101 0 int null 0.0 -70 35500 5#101 0 int null 0.0 -71 36000 1#115 0 int null 0.0 -72 36500 2#115 0 int null 0.0 -73 37000 3#115 0 int null 0.0 -74 37500 4#115 0 int null 0.0 -75 38000 5#115 0 int null 0.0 -76 38500 1#130 0 int null 0.0 -77 39000 2#130 0 int null 0.0 -78 39500 3#130 0 int null 0.0 -79 40000 4#130 0 int null 0.0 -80 40500 5#130 0 int null 0.0 -81 41000 1#146 0 int null 0.0 -82 41500 2#146 0 int null 0.0 -83 42000 3#146 0 int null 0.0 -84 42500 4#146 0 int null 0.0 -85 43000 5#146 0 int null 0.0 -86 43500 1#163 0 int null 0.0 -87 44000 2#163 0 int null 0.0 -88 44500 3#163 0 int null 0.0 -89 45000 4#163 0 int null 0.0 -90 45500 5#163 0 int null 0.0 -91 46000 1#181 0 int null 0.0 -92 46500 2#181 0 int null 0.0 -93 47000 3#181 0 int null 0.0 -94 47500 4#181 0 int null 0.0 -95 48000 5#181 0 int null 0.0 -96 48500 1#200 0 int null 0.0 -97 49000 2#200 0 int null 0.0 -98 49500 3#200 0 int null 0.0 -99 50000 4#200 0 int null 0.0 -100 50500 5#200 0 int null 0.0 +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 +3 2000 3#1 0 0.0 null 0.0 +4 2500 4#1 0 0.0 null 0.0 +5 2500 5#1 0 0.0 null 0.0 +6 3500 1#3 0 0.0 null 0.0 +7 4000 2#3 0 0.0 null 0.0 +8 4500 3#3 0 0.0 null 0.0 +9 5000 4#3 0 0.0 null 0.0 +10 5500 5#3 0 0.0 null 0.0 +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 +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 +18 9500 3#10 0 0.0 null 0.0 +19 10000 4#10 0 0.0 null 0.0 +20 10500 5#10 0 0.0 null 0.0 +21 11000 1#15 0 0.0 null 0.0 +22 11500 2#15 0 0.0 null 0.0 +23 12000 3#15 0 0.0 null 0.0 +24 12500 4#15 0 0.0 null 0.0 +25 13000 5#15 0 0.0 null 0.0 +26 13500 1#21 0 0.0 null 0.0 +27 14000 2#21 0 0.0 null 0.0 +28 14500 3#21 0 0.0 null 0.0 +29 15000 4#21 0 0.0 null 0.0 +30 15500 5#21 0 0.0 null 0.0 +31 16000 1#28 0 0.0 null 0.0 +32 16500 2#28 0 0.0 null 0.0 +33 17000 3#28 0 0.0 null 0.0 +34 17500 4#28 0 0.0 null 0.0 +35 18000 5#28 0 0.0 null 0.0 +36 18500 1#36 0 0.0 null 0.0 +37 19000 2#36 0 0.0 null 0.0 +38 19500 3#36 0 0.0 null 0.0 +39 20000 4#36 0 0.0 null 0.0 +40 20500 5#36 0 0.0 null 0.0 +41 21000 1#45 0 0.0 null 0.0 +42 21500 2#45 0 0.0 null 0.0 +43 22000 3#45 0 0.0 null 0.0 +44 22500 4#45 0 0.0 null 0.0 +45 23000 5#45 0 0.0 null 0.0 +46 23500 1#55 0 0.0 null 0.0 +47 24000 2#55 0 0.0 null 0.0 +48 24500 3#55 0 0.0 null 0.0 +49 25000 4#55 0 0.0 null 0.0 +50 25500 5#55 0 0.0 null 0.0 +51 26000 1#65 0 0.0 null 0.0 +52 26500 2#65 0 0.0 null 0.0 +53 27000 3#65 0 0.0 null 0.0 +54 27500 4#65 0 0.0 null 0.0 +55 28000 5#65 0 0.0 null 0.0 +56 28500 1#76 0 0.0 null 0.0 +57 29000 2#76 0 0.0 null 0.0 +58 29500 3#76 0 0.0 null 0.0 +59 30000 4#76 0 0.0 null 0.0 +60 30500 5#76 0 0.0 null 0.0 +61 31000 1#88 0 0.0 null 0.0 +62 31500 2#88 0 0.0 null 0.0 +63 32000 3#88 0 0.0 null 0.0 +64 32500 4#88 0 0.0 null 0.0 +65 33000 5#88 0 0.0 null 0.0 +66 33500 1#101 0 0.0 null 0.0 +67 34000 2#101 0 0.0 null 0.0 +68 34500 3#101 0 0.0 null 0.0 +69 35000 4#101 0 0.0 null 0.0 +70 35500 5#101 0 0.0 null 0.0 +71 36000 1#115 0 0.0 null 0.0 +72 36500 2#115 0 0.0 null 0.0 +73 37000 3#115 0 0.0 null 0.0 +74 37500 4#115 0 0.0 null 0.0 +75 38000 5#115 0 0.0 null 0.0 +76 38500 1#130 0 0.0 null 0.0 +77 39000 2#130 0 0.0 null 0.0 +78 39500 3#130 0 0.0 null 0.0 +79 40000 4#130 0 0.0 null 0.0 +80 40500 5#130 0 0.0 null 0.0 +81 41000 1#146 0 0.0 null 0.0 +82 41500 2#146 0 0.0 null 0.0 +83 42000 3#146 0 0.0 null 0.0 +84 42500 4#146 0 0.0 null 0.0 +85 43000 5#146 0 0.0 null 0.0 +86 43500 1#163 0 0.0 null 0.0 +87 44000 2#163 0 0.0 null 0.0 +88 44500 3#163 0 0.0 null 0.0 +89 45000 4#163 0 0.0 null 0.0 +90 45500 5#163 0 0.0 null 0.0 +91 46000 1#181 0 0.0 null 0.0 +92 46500 2#181 0 0.0 null 0.0 +93 47000 3#181 0 0.0 null 0.0 +94 47500 4#181 0 0.0 null 0.0 +95 48000 5#181 0 0.0 null 0.0 +96 48500 1#200 0 0.0 null 0.0 +97 49000 2#200 0 0.0 null 0.0 +98 49500 3#200 0 0.0 null 0.0 +99 50000 4#200 0 0.0 null 0.0 +100 50500 5#200 0 0.0 null 0.0 diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SMysteryFoodPoolConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SMysteryFoodPoolConfig.java index 3378ced4a..2cd8c4827 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SMysteryFoodPoolConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SMysteryFoodPoolConfig.java @@ -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> sMysteryFoodPoolConfigByPoolMap; + private static Map totalWeightByPoolMap; + + + @Override public void init() throws Exception { - + Map> result = new HashMap<>(); + Map 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 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; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SMysteryFoodSetting.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SMysteryFoodSetting.java index 1475294c9..c16654d4f 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SMysteryFoodSetting.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SMysteryFoodSetting.java @@ -14,24 +14,34 @@ public class SMysteryFoodSetting implements BaseConfig { private int failExp; + private int num; + + private static SMysteryFoodSetting sMysteryFoodSetting; + @Override public void init() throws Exception { - + Map config = STableManager.getConfig(SMysteryFoodSetting.class); + sMysteryFoodSetting = config.get(1); } + 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; + } } \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SWorkShopSetting.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SWorkShopSetting.java index 104c02115..fed43450f 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SWorkShopSetting.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SWorkShopSetting.java @@ -15,6 +15,14 @@ public class SWorkShopSetting implements BaseConfig { private int[] promote; + private int foodExp; + + private float addNum; + + private float[] poolRate; + + private float addSuccessRate; + private Map promoteMap; private static int maxExp; @@ -75,4 +83,20 @@ public class SWorkShopSetting implements BaseConfig { public void setExp(int exp) { this.exp = exp; } + + public int getFoodExp() { + return foodExp; + } + + public float getAddNum() { + return addNum; + } + + public float[] getPoolRate() { + return poolRate; + } + + public float getAddSuccessRate() { + return addSuccessRate; + } } \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/item/WorkShopLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/item/WorkShopLogic.java index 7515df1dd..27900698b 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/item/WorkShopLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/item/WorkShopLogic.java @@ -1,9 +1,6 @@ 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.globals.GlobalItemType; import com.ljsd.jieling.logic.dao.Equip; import com.ljsd.jieling.logic.dao.EquipManager; @@ -12,6 +9,7 @@ import com.ljsd.jieling.logic.dao.UserManager; import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.protocols.MessageTypeProto; 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 +17,7 @@ import org.slf4j.LoggerFactory; import java.util.*; /** - * 工坊相关 + * 百味居、工坊相关 */ public class WorkShopLogic { private static final Logger LOGGER = LoggerFactory.getLogger(WorkShopLogic.class); @@ -34,7 +32,39 @@ public class WorkShopLogic { return WorkShopLogic.Instance.instance; } + private SMysteryFoodPoolConfig randomFromFoodPool(int poolId){ + List 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 materials,int nums){ + 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){ + + } + //失败 熟练度加成 + int failExp = sMysteryFoodSetting.getFailExp(); + + + + } private void times2Array(int [][] array,int times){ for(int[] a :array){ diff --git a/serverlogic/src/main/resources/application.properties b/serverlogic/src/main/resources/application.properties index 7344d189f..d4e884493 100644 --- a/serverlogic/src/main/resources/application.properties +++ b/serverlogic/src/main/resources/application.properties @@ -1,5 +1,5 @@ #server info -server.id = 10212 +server.id = 10215 server.openTime = 20190101000101 server.num = 1 @@ -30,7 +30,7 @@ spring.redis.expireTime = -1 #spring.data.mongodb.uri = mongodb://mongouser:ysj#2017#ljsd@111.231.54.96:27017/ysj_wx_1 #spring.data.mongodb2.uri = mongodb://mongouser:ysj#2017#ljsd@111.231.54.96:27017/develop_ysj_wx_1 #mongodb2 develop -spring.data.mongodb.uri = mongodb://60.1.1.14:27017/jieling_10212 +spring.data.mongodb.uri = mongodb://60.1.1.14:27017/jieling_10215 mongodb.options.maxWaitTime = 120000 mongodb.options.connectTimeout = 1000 mongodb.options.socketTimeout = 0 From 3ef502dd5f9f0a4db459e79c6f25db39c8075180 Mon Sep 17 00:00:00 2001 From: wangyuan Date: Mon, 25 Feb 2019 11:54:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=99=BE=E5=91=B3=E5=B1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/server/MysteryFoodSetting.txt | 4 +- conf/server/WorkShopEquipmentConfig.txt | 146 ++++++------- conf/server/WorkShopFoundationConfig.txt | 6 +- conf/server/WorkShopSetting.txt | 4 +- .../jieling/config/SMysteryFoodSetting.java | 36 +++- .../config/SWorkShopEquipmentConfig.java | 4 +- .../ljsd/jieling/config/SWorkShopSetting.java | 42 +++- .../com/ljsd/jieling/core/GlobalsDef.java | 4 + .../workshop/ActiviteWorkShopHandler.java | 26 +++ .../workshop/GetWorkShopInfoHandler.java | 21 ++ .../ljsd/jieling/logic/dao/PlayerManager.java | 46 +--- .../java/com/ljsd/jieling/logic/dao/User.java | 9 + .../jieling/logic/dao/WorkShopController.java | 125 +++++++++++ .../jieling/logic/item/WorkShopLogic.java | 198 +++++++++++++++--- .../com/ljsd/jieling/util/CBean2Proto.java | 2 - 15 files changed, 502 insertions(+), 171 deletions(-) create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/handler/workshop/ActiviteWorkShopHandler.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/handler/workshop/GetWorkShopInfoHandler.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/logic/dao/WorkShopController.java diff --git a/conf/server/MysteryFoodSetting.txt b/conf/server/MysteryFoodSetting.txt index 917472451..1d5d1bd64 100644 --- a/conf/server/MysteryFoodSetting.txt +++ b/conf/server/MysteryFoodSetting.txt @@ -1,2 +1,2 @@ -Id AddRate FailExp -int mut,float#float,1 int +Id AddRate FailExp FoodNum +int mut,float#float,2 int int diff --git a/conf/server/WorkShopEquipmentConfig.txt b/conf/server/WorkShopEquipmentConfig.txt index 578823836..8d2689731 100644 --- a/conf/server/WorkShopEquipmentConfig.txt +++ b/conf/server/WorkShopEquipmentConfig.txt @@ -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 diff --git a/conf/server/WorkShopFoundationConfig.txt b/conf/server/WorkShopFoundationConfig.txt index 8ad3831fa..0283141b7 100644 --- a/conf/server/WorkShopFoundationConfig.txt +++ b/conf/server/WorkShopFoundationConfig.txt @@ -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 diff --git a/conf/server/WorkShopSetting.txt b/conf/server/WorkShopSetting.txt index 838d3fa43..4037fea3d 100644 --- a/conf/server/WorkShopSetting.txt +++ b/conf/server/WorkShopSetting.txt @@ -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 diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SMysteryFoodSetting.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SMysteryFoodSetting.java index c16654d4f..1073cd608 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SMysteryFoodSetting.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SMysteryFoodSetting.java @@ -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 addRateByQuality; + + private static SMysteryFoodSetting sMysteryFoodSetting; @Override public void init() throws Exception { - Map config = STableManager.getConfig(SMysteryFoodSetting.class); - sMysteryFoodSetting = config.get(1); + /* Map config = STableManager.getConfig(SMysteryFoodSetting.class); + SMysteryFoodSetting sMysteryFoodSettingTmp = config.get(1); + Map 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 getAddRateByQuality() { + return addRateByQuality; + } + + public void setAddRateByQuality(Map addRateByQuality) { + this.addRateByQuality = addRateByQuality; + } + + public int getFoodNum() { + return foodNum; + } } \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SWorkShopEquipmentConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SWorkShopEquipmentConfig.java index 8db5475b1..238a118e1 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SWorkShopEquipmentConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SWorkShopEquipmentConfig.java @@ -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; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SWorkShopSetting.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SWorkShopSetting.java index fed43450f..1481f2de3 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SWorkShopSetting.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SWorkShopSetting.java @@ -19,14 +19,18 @@ public class SWorkShopSetting implements BaseConfig { private float addNum; - private float[] poolRate; + private int[][] poolRate; private float addSuccessRate; private Map promoteMap; + private int cookTotalWeight; + private static int maxExp; + private static int maxCookExp; + private static Map sWorkShopSettingMap; @@ -36,26 +40,42 @@ public class SWorkShopSetting implements BaseConfig { Map sWorkShopSettingMapTmp = sWorkShopSettingMap = STableManager.getConfig(SWorkShopSetting.class); Map 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; + } } \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/core/GlobalsDef.java b/serverlogic/src/main/java/com/ljsd/jieling/core/GlobalsDef.java index a9fafa466..a2417af6a 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/core/GlobalsDef.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/core/GlobalsDef.java @@ -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; //蓝图解锁 + } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/workshop/ActiviteWorkShopHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/workshop/ActiviteWorkShopHandler.java new file mode 100644 index 000000000..cf23df0df --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/workshop/ActiviteWorkShopHandler.java @@ -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); + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/workshop/GetWorkShopInfoHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/workshop/GetWorkShopInfoHandler.java new file mode 100644 index 000000000..62a804ae9 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/workshop/GetWorkShopInfoHandler.java @@ -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); + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PlayerManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PlayerManager.java index 2b7741bb1..916bcf5a3 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PlayerManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PlayerManager.java @@ -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; - } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/User.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/User.java index 8c43ed34e..1c9983cbb 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/User.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/User.java @@ -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; + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/WorkShopController.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/WorkShopController.java new file mode 100644 index 000000000..cc2bf69b1 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/WorkShopController.java @@ -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> 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> getOpenBlueStateMap() { + return openBlueStateMap; + } + + public int getCookLevel() { + return cookLevel; + } + + public int getCookExp() { + return cookExp; + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/item/WorkShopLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/item/WorkShopLogic.java index 27900698b..2b7f1b1e5 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/item/WorkShopLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/item/WorkShopLogic.java @@ -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 materials,int nums){ + public void makeFood(ISession session,List 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 addRateByQuality = sMysteryFoodSetting.getAddRateByQuality(); + for(Integer id : materials){ + Map 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> openBlueStateMap = workShopController.getOpenBlueStateMap(); + int workShopLevel = workShopController.getWorkShopLevel(); + int workShopExp = workShopController.getWorkShopExp(); + + int cookLevel = workShopController.getCookLevel(); + int cookExp = workShopController.getCookExp(); + List workShopList = openBlueStateMap.get(GlobalsDef.WORK_SHOP_TYPE); + List cookShopList = openBlueStateMap.get(GlobalsDef.COOK_SHOP_TYPE); + + List 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 runneIdsList) throws Exception { + public void createEquipByUser(ISession session,int equipTid, List 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 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); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java b/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java index db50c1196..8e3dfff91 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java @@ -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; }