back_recharge
jiahuiwen 2019-01-22 18:01:15 +08:00
commit 482f9c07b3
38 changed files with 1004 additions and 254 deletions

View File

@ -1,15 +1,5 @@
buildscript {
repositories {
maven { url "http://repo.spring.io/libs-release" }
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.4.RELEASE")
}
}

View File

@ -0,0 +1,58 @@
#server info
server.id = 10180
server.openTime = 20190101000101
# redis config
# Redis数据库索引默认为0
spring.redis.database=0
# Redis服务器地址
spring.redis.host=60.1.1.14
# Redis服务器连接端口
spring.redis.port=6379
# Redis服务器连接密码默认为空
spring.redis.password=
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.pool.max-active=8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.pool.max-wait=-1
# 连接池中的最大空闲连接
spring.redis.pool.max-idle=8
# 连接池中的最小空闲连接
spring.redis.pool.min-idle=0
# 连接超时时间(毫秒)
spring.redis.timeout=0
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_msy
mongodb.options.maxWaitTime = 120000
mongodb.options.connectTimeout = 1000
mongodb.options.socketTimeout = 0
mongodb.options.threadsAllowedToBlockForConnectionMultiplier = 20
mongodb.options.connectionsPerHost = 256
mongodb.options.minConnectionsPerHost = 5
mongodb.options.maxConnectionIdleTime = 1000
# netty config
netty.tcpPort = 16080
netty.chatTcpPort = 20001
netty.logintcpPort = 18091
netty.udpPort = 18092
netty.udpTargetIp=127.0.0.1
netty.udpTargetPort=10001
netty.reconnectDelay=3000
netty.bossThreadCount=1
netty.workerThreadCount=10
netty.readTimeout=32
netty.writeTimeout=32
netty.allTimeout=35
logging.config = conf/logback-boot.xml

View File

@ -1,2 +1,58 @@
Id BornItem
int mut,int#int,2
Id BornItem SpeedFormula
int mut,int#int,2 mut,int#int,1
1 2#1000#2|3#1#4 0#0#10#1
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null
0 null null

View File

@ -0,0 +1,252 @@
Id Level CharacterLevelPara Consume
int int float mut,int#int,2
1 1 1 2#0|1100#0
2 2 1 2#500|1100#60
3 3 1 2#600|1100#70
4 4 1 2#700|1100#80
5 5 1 2#800|1100#90
6 6 1 2#900|1100#100
7 7 1 2#1000|1100#110
8 8 1 2#1100|1100#120
9 9 1 2#1200|1100#130
10 10 1 2#1300|1100#140
11 11 1 2#1400|1100#150
12 12 1 2#1500|1100#160
13 13 1 2#1600|1100#170
14 14 1 2#1700|1100#180
15 15 1 2#1800|1100#190
16 16 1 2#1900|1100#200
17 17 1 2#2000|1100#210
18 18 1 2#2100|1100#220
19 19 1 2#2200|1100#230
20 20 1 2#2300|1100#240
21 21 1 2#2400|1100#250
22 22 1 2#2500|1100#260
23 23 1 2#2600|1100#270
24 24 1 2#2700|1100#280
25 25 1 2#2800|1100#290
26 26 1 2#2900|1100#300
27 27 2 2#3000|1100#310
28 28 2 2#3100|1100#320
29 29 2 2#3200|1100#330
30 30 2 2#3300|1100#340
31 31 2 2#3500|1100#350
32 32 2 2#3700|1100#360
33 33 2 2#3900|1100#370
34 34 2 2#4100|1100#380
35 35 2 2#4300|1100#390
36 36 2 2#4500|1100#400
37 37 2 2#4700|1100#410
38 38 2 2#4900|1100#420
39 39 2 2#5100|1100#430
40 40 2 2#5300|1100#440
41 41 2 2#5500|1100#450
42 42 2 2#5700|1100#460
43 43 2 2#5900|1100#470
44 44 2 2#6100|1100#480
45 45 2 2#6300|1100#490
46 46 2 2#6500|1100#500
47 47 2 2#6700|1100#510
48 48 2 2#6900|1100#520
49 49 2 2#7100|1100#530
50 50 2 2#7300|1100#540
51 51 2 2#7500|1100#550
52 52 3 2#7700|1100#560
53 53 3 2#7900|1100#570
54 54 3 2#8100|1100#580
55 55 3 2#8300|1100#590
56 56 3 2#8500|1100#600
57 57 3 2#8700|1100#610
58 58 3 2#8900|1100#620
59 59 3 2#9100|1100#630
60 60 3 2#9300|1100#640
61 61 3 2#10000|1100#650
62 62 3 2#10700|1100#660
63 63 3 2#11400|1100#670
64 64 3 2#12100|1100#680
65 65 3 2#12800|1100#690
66 66 3 2#13500|1100#700
67 67 3 2#14200|1100#710
68 68 3 2#14900|1100#720
69 69 3 2#15600|1100#730
70 70 3 2#16300|1100#740
71 71 3 2#17000|1100#750
72 72 3 2#17700|1100#760
73 73 3 2#18400|1100#770
74 74 3 2#19100|1100#780
75 75 3 2#19800|1100#790
76 76 3 2#20500|1100#800
77 77 3 2#21200|1100#810
78 78 4 2#21900|1100#820
79 79 4 2#22600|1100#830
80 80 4 2#23300|1100#840
81 81 4 2#24000|1100#850
82 82 4 2#24700|1100#860
83 83 4 2#25400|1100#870
84 84 4 2#26100|1100#880
85 85 4 2#26800|1100#890
86 86 4 2#27500|1100#900
87 87 4 2#28200|1100#910
88 88 4 2#28900|1100#920
89 89 4 2#29600|1100#930
90 90 4 2#30300|1100#940
91 91 4 2#31000|1100#950
92 92 4 2#31700|1100#960
93 93 4 2#32400|1100#970
94 94 4 2#33100|1100#980
95 95 4 2#33800|1100#990
96 96 4 2#34500|1100#1000
97 97 4 2#35200|1100#1010
98 98 4 2#35900|1100#1020
99 99 4 2#36600|1100#1030
100 100 5 2#37300|1100#1040
101 101 5 2#38000|1100#1140
102 102 5 2#39000|1100#1240
103 103 5 2#40000|1100#1340
104 104 5 2#41000|1100#1440
105 105 6 2#42000|1100#1540
106 106 6 2#43000|1100#1640
107 107 6 2#44000|1100#1740
108 108 6 2#45000|1100#1840
109 109 6 2#46000|1100#1940
110 110 7 2#47000|1100#2040
111 111 7 2#48000|1100#2140
112 112 7 2#49000|1100#2240
113 113 7 2#50000|1100#2340
114 114 7 2#51000|1100#2440
115 115 8 2#52000|1100#2540
116 116 8 2#53000|1100#2640
117 117 8 2#54000|1100#2740
118 118 8 2#55000|1100#2840
119 119 8 2#56000|1100#2940
120 120 9 2#57000|1100#3040
121 121 9 2#58000|1100#3140
122 122 9 2#59000|1100#3240
123 123 9 2#60000|1100#3340
124 124 9 2#61000|1100#3440
125 125 10 2#62000|1100#3540
126 126 10 2#63000|1100#3640
127 127 10 2#64000|1100#3740
128 128 10 2#65000|1100#3840
129 129 10 2#66000|1100#3940
130 130 11 2#67000|1100#4040
131 131 11 2#68000|1100#4140
132 132 11 2#69000|1100#4240
133 133 11 2#70000|1100#4340
134 134 11 2#71000|1100#4440
135 135 12 2#72000|1100#4540
136 136 12 2#73000|1100#4640
137 137 12 2#74000|1100#4740
138 138 12 2#75000|1100#4840
139 139 12 2#76000|1100#4940
140 140 13 2#77000|1100#5040
141 141 13 2#80000|1100#5340
142 142 13 2#83000|1100#5640
143 143 13 2#86000|1100#5940
144 144 13 2#89000|1100#6240
145 145 13 2#92000|1100#6540
146 146 13 2#95000|1100#6840
147 147 14 2#98000|1100#7140
148 148 14 2#101000|1100#7440
149 149 14 2#104000|1100#7740
150 150 14 2#107000|1100#8040
151 151 14 2#110000|1100#8340
152 152 14 2#113000|1100#8640
153 153 15 2#116000|1100#8940
154 154 15 2#119000|1100#9240
155 155 15 2#122000|1100#9540
156 156 15 2#125000|1100#9840
157 157 15 2#128000|1100#10140
158 158 15 2#131000|1100#10440
159 159 16 2#134000|1100#10740
160 160 16 2#137000|1100#11040
161 161 16 2#140000|1100#11340
162 162 16 2#145000|1100#11640
163 163 16 2#150000|1100#11940
164 164 16 2#155000|1100#12240
165 165 17 2#160000|1100#12540
166 166 17 2#165000|1100#12840
167 167 17 2#170000|1100#13140
168 168 17 2#175000|1100#13440
169 169 17 2#180000|1100#13740
170 170 17 2#185000|1100#14040
171 171 18 2#190000|1100#14340
172 172 18 2#195000|1100#14640
173 173 18 2#200000|1100#14940
174 174 18 2#205000|1100#15240
175 175 18 2#210000|1100#15540
176 176 18 2#215000|1100#15840
177 177 19 2#220000|1100#16140
178 178 19 2#225000|1100#16440
179 179 19 2#230000|1100#16740
180 180 19 2#235000|1100#17040
181 181 19 2#240000|1100#17340
182 182 19 2#245000|1100#17640
183 183 20 2#250000|1100#17940
184 184 20 2#255000|1100#18240
185 185 20 2#260000|1100#18540
186 186 20 2#265000|1100#18840
187 187 20 2#270000|1100#19140
188 188 20 2#275000|1100#19440
189 189 21 2#280000|1100#19740
190 190 21 2#285000|1100#20040
191 191 21 2#290000|1100#20340
192 192 21 2#295000|1100#20640
193 193 21 2#300000|1100#20940
194 194 21 2#305000|1100#21240
195 195 22 2#310000|1100#21540
196 196 22 2#315000|1100#21840
197 197 22 2#320000|1100#22140
198 198 22 2#325000|1100#22440
199 199 22 2#330000|1100#22740
200 200 22 2#335000|1100#22980
201 201 22 2#340000|1100#23580
202 202 23 2#345000|1100#24180
203 203 23 2#350000|1100#24780
204 204 23 2#355000|1100#25380
205 205 23 2#360000|1100#25980
206 206 23 2#365000|1100#26580
207 207 23 2#370000|1100#27180
208 208 24 2#375000|1100#27780
209 209 24 2#380000|1100#28380
210 210 24 2#385000|1100#28980
211 211 24 2#390000|1100#29580
212 212 24 2#395000|1100#30180
213 213 24 2#400000|1100#30780
214 214 25 2#405000|1100#31380
215 215 25 2#410000|1100#31980
216 216 25 2#415000|1100#32580
217 217 25 2#420000|1100#33180
218 218 25 2#425000|1100#33780
219 219 25 2#430000|1100#34380
220 220 26 2#435000|1100#34980
221 221 26 2#440000|1100#35580
222 222 26 2#445000|1100#36180
223 223 26 2#450000|1100#36780
224 224 26 2#455000|1100#37380
225 225 26 2#460000|1100#37980
226 226 27 2#465000|1100#38580
227 227 27 2#470000|1100#39180
228 228 27 2#475000|1100#39780
229 229 27 2#480000|1100#40380
230 230 27 2#485000|1100#40980
231 231 27 2#490000|1100#41580
232 232 28 2#495000|1100#42180
233 233 28 2#500000|1100#42780
234 234 28 2#505000|1100#43380
235 235 28 2#510000|1100#43980
236 236 28 2#515000|1100#44580
237 237 28 2#520000|1100#45180
238 238 29 2#525000|1100#45780
239 239 29 2#530000|1100#46380
240 240 29 2#535000|1100#46980
241 241 29 2#540000|1100#47580
242 242 29 2#545000|1100#48180
243 243 29 2#550000|1100#48780
244 244 30 2#555000|1100#49380
245 245 30 2#560000|1100#49980
246 246 30 2#565000|1100#50580
247 247 30 2#570000|1100#51180
248 248 30 2#575000|1100#51780
249 249 30 2#580000|1100#52380
250 250 31 2#585000|1100#52980

View File

@ -0,0 +1,3 @@
Id IsUpset RewardItem RewardMaxNum Loop
int int mut,int#int,1 int int
1 2 1#2#3#4#5#6#7#8#9#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#27#28#29#30#31#32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47#48#49#50#51#52#53#54#55#56 1 0

View File

@ -0,0 +1,58 @@
id itemId Chance GrowChance RandomMin RandomMax
int int int int int int
1 10001 100 0 1 1
2 10002 100 0 1 1
3 10003 100 0 1 1
4 10004 100 0 1 1
5 10005 100 0 1 1
6 10006 100 0 1 1
7 10007 100 0 1 1
8 10008 100 0 1 1
9 10009 100 0 1 1
10 10010 100 0 1 1
11 10011 100 0 1 1
12 10012 100 0 1 1
13 10013 100 0 1 1
14 10014 100 0 1 1
15 10015 100 0 1 1
16 10016 100 0 1 1
17 10017 100 0 1 1
18 10018 100 0 1 1
19 10019 100 0 1 1
20 10020 100 0 1 1
21 10021 100 0 1 1
22 10022 100 0 1 1
23 10023 100 0 1 1
24 10024 100 0 1 1
25 10025 100 0 1 1
26 10026 100 0 1 1
27 10027 100 0 1 1
28 10028 100 0 1 1
29 10029 100 0 1 1
30 10030 100 0 1 1
31 10031 100 0 1 1
32 10032 100 0 1 1
33 10033 100 0 1 1
34 10034 100 0 1 1
35 10035 100 0 1 1
36 10036 100 0 1 1
37 10037 100 0 1 1
38 10038 100 0 1 1
39 10039 100 0 1 1
40 10040 100 0 1 1
41 10041 100 0 1 1
42 10042 100 0 1 1
43 10043 100 0 1 1
44 10044 100 0 1 1
45 10045 100 0 1 1
46 10046 100 0 1 1
47 10047 100 0 1 1
48 10048 100 0 1 1
49 10049 100 0 1 1
50 10050 100 0 1 1
51 10051 100 0 1 1
52 10052 100 0 1 1
53 10053 100 0 1 1
54 10054 100 0 1 1
55 10055 100 0 1 1
56 10056 100 0 1 1

View File

@ -8,7 +8,6 @@ version '1.0.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
maven { url "http://repo.spring.io/libs-release" }
mavenLocal()
mavenCentral()
}

View File

@ -14,6 +14,7 @@ import com.ljsd.jieling.network.NettyServerAutoConfiguration;
import com.ljsd.jieling.network.server.ProtocolsManager;
import com.ljsd.jieling.network.session.ISessionFactory;
import com.ljsd.jieling.thread.ThreadManager;
import com.ljsd.jieling.util.KeyGenUtils;
import com.ljsd.jieling.util.TimeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -96,6 +97,7 @@ public class GameApplication {
serverConfigTmp.setCacheOpenTime(date.getTime());
serverConfig = serverConfigTmp;
}
KeyGenUtils.setMachineNum(serverConfiguration.getServerProperties().getNum());
try {
LOGGER.info("main->CoreApplication start...");
ISessionFactory sessionFactory = new ISessionFactory();

View File

@ -29,7 +29,7 @@ public class SCHeroRankUpConfig implements BaseConfig{
@Override
public void init() throws Exception {
scHeroRankUpConfigMap = STableManager.getConfig(SCHeroRankUpConfig.class);
// scHeroRankUpConfigMap = STableManager.getConfig(SCHeroRankUpConfig.class);
}
public static Map<Integer, SCHeroRankUpConfig> getScHeroRankUpConfigMap() {

View File

@ -1,41 +0,0 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.Map;
@Table(name = "drop")
public class SDrop implements BaseConfig {
public static Map<Integer, SDrop> sDropMap;
private int id;
private int dropType; // 掉落type
private int[][] item;
private int[] weight;
@Override
public void init() throws Exception {
sDropMap = STableManager.getConfig(SDrop.class);
}
public int getId() {
return id;
}
public int[][] getItem() {
return item;
}
public static Map<Integer, SDrop> getsDropMap() {
return sDropMap;
}
public int getDropType() {
return dropType;
}
public int[] getWeight() {
return weight;
}
}

View File

@ -12,13 +12,14 @@ public class SGameSetting implements BaseConfig {
private int[][] bornItem;
private int[] speedFormula;
@Override
public void init() throws Exception {
}
public int getId() {
return id;
}
@ -27,5 +28,18 @@ public class SGameSetting implements BaseConfig {
return bornItem;
}
public int[] getSpeedFormula() {
return speedFormula;
}
public float calSpeed(float speed){
float result = 0.0f;
int length = speedFormula.length;
for(int i=0;i< speedFormula.length;i++){
double pow = Math.pow(speed, --length);
result += speedFormula[i]*pow;
}
return result;
}
}

View File

@ -16,10 +16,13 @@ public class SHeroLevlConfig implements BaseConfig{
private float characterLevelPara;
private int[][] consume;
@Override
public void init() throws Exception {
sHeroLevlConfigMap = STableManager.getConfig(SHeroLevlConfig.class);
}
@ -42,4 +45,8 @@ public class SHeroLevlConfig implements BaseConfig{
public float getCharacterLevelPara() {
return characterLevelPara;
}
public int[][] getConsume() {
return consume;
}
}

View File

@ -0,0 +1,55 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.Map;
@Table(name = "RewardGroup")
public class SRewardGroup implements BaseConfig {
public static Map<Integer, SRewardGroup> sRewardItemMap;
private int id;
/**
*
* 1
* 2
* 3
*/
private int isUpset; // 掉落type
private int[] rewardItem;
private int rewardMaxNum; // 道具数
/**
* 3
*/
private int loop ;
@Override
public void init() throws Exception {
sRewardItemMap = STableManager.getConfig(SRewardGroup.class);
}
public int getId() {
return id;
}
public static Map<Integer, SRewardGroup> getsRewardItemMap() {
return sRewardItemMap;
}
public int getIsUpset() {
return isUpset;
}
public int[] getRewardItem() {
return rewardItem;
}
public int getRewardMaxNum() {
return rewardMaxNum;
}
public int getLoop() {
return loop;
}
}

View File

@ -0,0 +1,51 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.Map;
@Table(name = "RewardItemConfig")
public class SRewardItem implements BaseConfig {
public static Map<Integer, SRewardItem> sDropMap;
private int id;
private int itemId;
private int chance; //获取概率
private int growChance; //成长概率 针对特殊处理,如果不获取,则获取概率增加
private int randomMin; //获取数量最小值
private int randomMax; //获取数量最大值
@Override
public void init() throws Exception {
sDropMap = STableManager.getConfig(SRewardItem.class);
}
public int getId() {
return id;
}
public static Map<Integer, SRewardItem> getsDropMap() {
return sDropMap;
}
public int getItemId() {
return itemId;
}
public int getChance() {
return chance;
}
public int getGrowChance() {
return growChance;
}
public int getRandomMin() {
return randomMin;
}
public int getRandomMax() {
return randomMax;
}
}

View File

@ -18,6 +18,8 @@ public class ServerProperties {
private String openTime;
private int num;
public int getId() {
return id;
}
@ -58,6 +60,14 @@ public class ServerProperties {
this.openTime = openTime;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
@Override
public String toString() {
return "ServerProperties{" +
@ -66,6 +76,7 @@ public class ServerProperties {
", channel='" + channel + '\'' +
", isLAN=" + isLAN +
", openTime=" + openTime +
", num=" + num +
'}';
}
}

View File

@ -2,4 +2,14 @@ package com.ljsd.jieling.exception;
public class ErrorCode {
//系统错误
public static final int sysErrorCode = -100;
//重复登陆
public static final int reloginCode = -101;
//踢用户下线
public static final int kickUserCode = -102;
}

View File

@ -2,4 +2,5 @@ package com.ljsd.jieling.globals;
public interface GlobalGm {
int ADD_ITEM = 0;//添加道具
int ADD_CARD = 1; //添加卡牌
}

View File

@ -4,8 +4,11 @@ public interface GlobalItemType {
//掉落物品类型
int ALL_DROP = 0; //全部掉落
int WEIGHT_DROP = 1; //随机掉落
int SUCCESSIVELY_RANDOM = 2; // 依次随机
// 物品类型
int ITEM = 10; //道具类型
int GEM = 1; // 钻石Id(充值获得)
int ITEM = 10; //道具
int CARD = 11; // 卡牌
}

View File

@ -39,37 +39,22 @@ public class DrawHeroHandler extends BaseHandler {
CommonProto.Hero hero1 = CommonProto.Hero.newBuilder()
.setId("aaa")
.setHeroId(1)
.setAttack(2)
.setStar(2)
.setLevel(1)
.setHp(1000)
.setMDefence(2000)
.setPDefence(3000)
.setSpeed(4000)
.build();
CommonProto.Hero hero2 = CommonProto.Hero.newBuilder()
.setId("bbb")
.setHeroId(2)
.setAttack(2)
.setStar(2)
.setLevel(1)
.setHp(1000)
.setMDefence(2000)
.setPDefence(3000)
.setSpeed(4000)
.build();
CommonProto.Hero hero3 = CommonProto.Hero.newBuilder()
.setId("ccc")
.setHeroId(3)
.setAttack(2)
.setStar(2)
.setLevel(1)
.setHp(1000)
.setMDefence(2000)
.setPDefence(3000)
.setSpeed(4000)
.build();
heroList.add(hero1);

View File

@ -2,20 +2,17 @@ package com.ljsd.jieling.handler.GameGM;
import com.ljsd.jieling.globals.GlobalGm;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.Item;
import com.ljsd.jieling.logic.dao.ItemManager;
import com.ljsd.jieling.logic.dao.User;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.GMCommandProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -30,7 +27,7 @@ public class GMRequestHandler extends BaseHandler{
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
byte[] message = netData.parseClientProtoNetData();
GMCommandProto.GMCommand gmCommand = GMCommandProto.GMCommand.parseFrom(message);
CommonProto.GMCommand gmCommand = CommonProto.GMCommand.parseFrom(message);
String command = gmCommand.getCommand();
if (!command.contains("#") || command.split("#").length < 3) {
LOGGER.error("wrong command :" + command);
@ -38,15 +35,30 @@ public class GMRequestHandler extends BaseHandler{
}
String[] commandArray = command.split("#");
int uid = Integer.parseInt(commandArray[0]);
int gmCommandType = Integer.parseInt(commandArray[1]);// type 0添加道具
int gmCommandType = Integer.parseInt(commandArray[1]);// type 0添加道具 1:卡牌
int prarm1 = 0, prarm2 = 0;
User cUser = UserManager.getUser(uid);
switch (gmCommandType){
case GlobalGm.ADD_ITEM:
giveItem(cUser,prarm1,prarm2);
break;
case GlobalGm.ADD_CARD:
giveHero(cUser,prarm1,prarm2);
break;
}
try {
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GM_RESPONSE_VALUE, null, true);
LOGGER.info("back to client!");
} catch (Exception e) {
e.printStackTrace();
}
}
private void giveHero(User cUser, int cardId, int cardNum) throws Exception {
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
Map<Integer,Integer> cardMap = new ConcurrentHashMap<>();
cardMap.put(cardId,cardNum);
ItemUtil.addCard(cUser,cardMap,dropBuilder);
}
private void giveItem(User cUser,int itemId,int itemNum) throws Exception {

View File

@ -1,16 +1,18 @@
package com.ljsd.jieling.handler;
import com.ljsd.jieling.logic.dao.User;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.protocols.PlayerInfoProto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component
@ -34,27 +36,8 @@ public class GetAllItemHandler extends BaseHandler {
LOGGER.info("processMessage->uid={},token={},msgId={},msgIndex={},messageNum={},messageStr={}",
userId, token,msgId,msgIndex,getItemInfoRequest.getNum(),getItemInfoRequest.getStr());
List<CommonProto.Item> itemList = new ArrayList<>();
CommonProto.Item item1 = CommonProto.Item.newBuilder()
.setItemId(1)
.setItemNum(111)
.build();
CommonProto.Item item2 = CommonProto.Item.newBuilder()
.setItemId(2)
.setItemNum(222)
.build();
CommonProto.Item item3 = CommonProto.Item.newBuilder()
.setItemId(3)
.setItemNum(333)
.build();
itemList.add(item1);
itemList.add(item2);
itemList.add(item3);
// User user = UserManager.getUserForLogin(userId);
// List<CommonProto.Item> itemList = ItemUtil.getAllItem(user);
User user = UserManager.getUserForLogin(userId);
List<CommonProto.Item> itemList = ItemUtil.getAllItem(user);
PlayerInfoProto.GetItemInfoResponse getItemInfoResponse = PlayerInfoProto.GetItemInfoResponse.newBuilder()
.addAllItemlist(itemList)
.build();

View File

@ -12,4 +12,7 @@ public class CalHeroFinalAttri {
}

View File

@ -8,19 +8,16 @@ import java.util.concurrent.ConcurrentHashMap;
public class OnlineUserManager {
public static Map<Integer, Integer> onlineUidMap = new ConcurrentHashMap<>();
public static Map<Integer, ISession> sessionMap = new ConcurrentHashMap<>();
public static Map<Integer, PlayerManager> onlineUserMap = new ConcurrentHashMap<>(10000);
public static void registUser(int uid, int serverId, ISession session) {
onlineUidMap.put(uid, serverId);
public static void userOnline(int uid, ISession session) {
sessionMap.put(uid, session);
}
public static void unRegistUser(int uid) {
onlineUidMap.remove(uid);
public static void userOffline(int uid) {
sessionMap.remove(uid);
}

View File

@ -2,7 +2,10 @@ package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.config.SCHero;
import com.ljsd.jieling.config.SHeroLevlConfig;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.util.KeyGenUtils;
import com.ljsd.jieling.util.UUIDEnum;
import java.util.ArrayList;
import java.util.List;
@ -17,17 +20,6 @@ public class Hero extends MongoBase {
private int star;
private float hp;
private float attack;
private float pDefence;
private float mDefence;
private float speed;
private List<Integer> skillList;
private List<Equip> equipList;
@ -35,20 +27,34 @@ public class Hero extends MongoBase {
public Hero(){}
public Hero(String uid,int heroTid){
this.id = uid + "" + heroTid;
this.id = KeyGenUtils.produceIdByModule(UUIDEnum.HERO,uid);
SCHero scHero = SCHero.getsCHero().get(heroTid);
this.templateId = scHero.getId();
this.level = 1;
this.star = 1;
this.hp = scHero.getHp();
this.attack = scHero.getAttack();
this.pDefence = scHero.getPhysicalDefence();
this.mDefence = scHero.getMagicDefence();
this.speed = scHero.getSpeed();
this.skillList = new ArrayList<>();
this.equipList = new ArrayList<>();
List<Integer> skillIds = scHero.getSkillListByStar().get(star);
this.skillList.addAll(skillIds);
if(skillIds!=null && skillIds.isEmpty()){
this.skillList.addAll(skillIds);
}
}
public void upStar(int upStar) throws Exception {
SCHero scHero = SCHero.getsCHero().get(templateId);
List<Integer> skillIds = scHero.getSkillListByStar().get(star);
if(skillIds!=null && skillIds.isEmpty()){
if(this.skillList!=null){
skillList.clear();
}else{
this.skillList = new ArrayList<>();
}
this.skillList.addAll(skillIds);
}
this.star += upStar;
updateString("star",star);
updateString("skillList",skillList);
}
@ -72,30 +78,6 @@ public class Hero extends MongoBase {
this.star = star;
}
public void setHp(float hp) throws Exception {
updateString("hp",hp);
this.hp = hp;
}
public void setAttack(float attack) throws Exception {
updateString("attack",attack);
this.attack = attack;
}
public void setpDefence(float pDefence) throws Exception {
updateString("pDefence",pDefence);
this.pDefence = pDefence;
}
public void setmDefence(float mDefence) throws Exception {
updateString("mDefence",mDefence);
this.mDefence = mDefence;
}
public void setSpeed(float speed) throws Exception {
updateString("speed",speed);
this.speed = speed;
}
public String getId() {
return id;
@ -113,27 +95,6 @@ public class Hero extends MongoBase {
return star;
}
public float getHp() {
return hp;
}
public float getAttack() {
return attack;
}
public float getpDefence() {
return pDefence;
}
public float getmDefence() {
return mDefence;
}
public float getSpeed() {
return speed;
}
public List<Integer> getSkillList() {
return skillList;
}

View File

@ -1,10 +1,7 @@
package com.ljsd.jieling.logic.hero;
import com.ljsd.GameApplication;
import com.ljsd.jieling.config.SItem;
import com.ljsd.jieling.config.SLotteryRewardConfig;
import com.ljsd.jieling.config.SLotterySetting;
import com.ljsd.jieling.config.ServerConfig;
import com.ljsd.jieling.config.*;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
@ -196,6 +193,28 @@ public class HeroLogic {
}
public void upHeroLevel(ISession session,String heroId) throws Exception {
User user = UserManager.getUser(session.getUid());
Hero hero = user.getHeroManager().getHero(heroId);
if( null == hero){
return;
}
//校验消耗
int oldLevel = hero.getLevel();
SHeroLevlConfig sHeroLevlConfig = SHeroLevlConfig.getsCHero().get(oldLevel);
int[][] consume = sHeroLevlConfig.getConsume();
hero.setLevel( oldLevel + 1);
}
}

View File

@ -3,7 +3,11 @@ package com.ljsd.jieling.network.server;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.MessageLite;
import com.ljsd.GameApplication;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.dao.User;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.netty.handler.GameMessageHandler;
import com.ljsd.jieling.network.session.ISession;
@ -207,7 +211,7 @@ public class ProtocolsManager implements ProtocolsAbstract {
int resultCode = checkAndRefresh(session,packetNetData);
if (resultCode != 0 ){
MessageUtil.sendErrorCode(session);
MessageUtil.sendErrorCode(session,0);
return;
}
@ -251,8 +255,9 @@ public class ProtocolsManager implements ProtocolsAbstract {
private int checkAndRefresh(ISession session, PacketNetData packetNetData) {
int myToken = 0;
if (packetNetData.getMsgId()== MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE){
OnlineUserManager.userOnline(session.getUid(),session);
//TODO 更新token
}else if (packetNetData.getMsgId()== MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE){
//TODO 更新token
@ -260,6 +265,13 @@ public class ProtocolsManager implements ProtocolsAbstract {
}else {
}
if (OnlineUserManager.checkUidOnline(session.getUid())){
ISession iSession = OnlineUserManager.getSessionByUid(session.getUid());
MessageUtil.sendErrorCode(session, ErrorCode.reloginCode);
iSession.close();
}
// if (myToken != packetNetData.getToken()){
// return 1;
// }
@ -295,14 +307,10 @@ public class ProtocolsManager implements ProtocolsAbstract {
return;
}
if (nowSession != null) {
LOGGER.error("offLine->uid={},session={},nowUid={},nowSession={}",
session.getUid(), session, nowSession.getUid(), nowSession);
}
GameMessageHandler.currentSessions.remove(session.getUid());
try {
OnlineUserManager.userOffline(session.getUid());
// 下线处理的逻辑需要添加在这里
} finally {
//保证数据的保存

View File

@ -43,11 +43,6 @@ public class CBean2Proto {
.setHeroId(hero.getTemplateId())
.setLevel(hero.getLevel())
.setStar(hero.getStar())
.setHp((int)hero.getHp())
.setAttack((int)hero.getAttack())
.setPDefence((int)hero.getpDefence())
.setMDefence((int)hero.getmDefence())
.setSpeed((int)hero.getSpeed())
.addAllSkillIdList(hero.getSkillList())
.addAllEquipIdList(getHeroEquip(hero.getEquipList()))
.build();

View File

@ -40,6 +40,13 @@ public class CellUtil {
}
/**
* width x height pos
* @param width
* @param height
* @param pos
* @return
*/
public static Set<Integer> getOneOpenCell(int width, int height, int pos){
int[] xy = pos2XY(pos);
int x = xy[0];
@ -89,4 +96,21 @@ public class CellUtil {
}
return s1 ;
}
/**
*
* @param pos1
* @param pos2
* @return
*/
public static boolean checkIsNextCell(int pos1 , int pos2){
int[] xy1 = pos2XY(pos1);
int[] xy2 = pos2XY(pos2);
if ((xy1[0]==xy2[0] && Math.abs(xy1[1]-xy2[1])==1) || (xy1[1]==xy2[1] && Math.abs(xy1[0]-xy2[0])==1)){
return true;
}
return false ;
}
}

View File

@ -1,12 +1,10 @@
package com.ljsd.jieling.util;
import com.ljsd.jieling.config.SDrop;
import com.ljsd.jieling.config.SRewardItem;
import com.ljsd.jieling.config.SItem;
import com.ljsd.jieling.config.SRewardGroup;
import com.ljsd.jieling.globals.GlobalItemType;
import com.ljsd.jieling.logic.dao.Item;
import com.ljsd.jieling.logic.dao.ItemManager;
import com.ljsd.jieling.logic.dao.User;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.protocols.CommonProto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -20,47 +18,108 @@ import java.util.concurrent.CopyOnWriteArrayList;
public class ItemUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(ItemUtil.class);
//掉落
public static CommonProto.Drop.Builder drop(User user, int dropId, CommonProto.Drop.Builder drop) throws Exception {
SDrop sDrop = SDrop.getsDropMap().get(dropId);
if (sDrop == null){
public static CommonProto.Drop.Builder drop(User user, int dropGroupId, CommonProto.Drop.Builder drop) throws Exception {
SRewardGroup sRewardGroup = SRewardGroup.getsRewardItemMap().get(dropGroupId);
if (sRewardGroup == null){
return drop;
}
int dropType = sDrop.getDropType();
Map<Integer, Integer> itemMap = new HashMap<>();
selectDrop(sDrop, dropType, itemMap);
Map<Integer, Integer> cardMap = new HashMap<>();
selectDrop(sRewardGroup,itemMap,cardMap);
addItem(user,itemMap,drop);
addCard(user,cardMap,drop);
return drop;
}
private static void selectDrop(SDrop sDrop, int dropType, Map<Integer, Integer> itemMap) {
int[][] itemIds = sDrop.getItem();
if (dropType == GlobalItemType.ALL_DROP){
for (int[] itemId : itemIds) {
getMap(itemId, itemMap);
private static void selectDrop(SRewardGroup sRewardGroup,Map<Integer, Integer> itemMap, Map<Integer, Integer> cardMap) {
int[] rewardItem = sRewardGroup.getRewardItem();
StringBuilder rewardStr = new StringBuilder();
StringBuilder weight = new StringBuilder();
for (int dropId :rewardItem){
SRewardItem sRewardItem = SRewardItem.getsDropMap().get(dropId);
if (sRewardItem == null){
continue;
}
if (rewardStr.length() == 0){
rewardStr = new StringBuilder(String.valueOf(sRewardItem.getItemId()));
}else{
rewardStr.append("#").append(sRewardItem.getItemId());
}
if (weight.length() == 0){
weight = new StringBuilder(String.valueOf(sRewardItem.getChance()));
}else{
weight.append("#").append(sRewardItem.getItemId());
}
}else{
int[] weights = sDrop.getWeight();
int index = MathUtils.randomForStrArray(weights);
getMap(itemIds[index], itemMap);
}
}
private static void getMap(int[] itemInfo, Map<Integer, Integer> itemMap) {
SItem sItem = SItem.getsItemMap().get(itemInfo[1]);
int itemType = sItem.getItemType();
switch (itemType) {
case GlobalItemType.ITEM:
putcountMap(itemInfo, itemMap);
switch (sRewardGroup.getIsUpset()) {
case GlobalItemType.ALL_DROP:
getMap(rewardStr.toString().split("#"),itemMap,cardMap);
break;
case GlobalItemType.WEIGHT_DROP:
getRandomMap(sRewardGroup.getRewardMaxNum(),rewardStr.toString().split("#"),weight.toString().split("#"),itemMap,cardMap);
break;
case GlobalItemType.SUCCESSIVELY_RANDOM:
getSuccessivelyRandmoMap(sRewardGroup,rewardStr.toString().split("#"),weight.toString().split("#"),itemMap,cardMap);
break;
default:
break;
}
}
private static void putcountMap(int[] itemInfo, Map<Integer, Integer> map) {
map.merge(itemInfo[0], itemInfo[1], (a, b) -> b + a);
private static void getSuccessivelyRandmoMap(SRewardGroup sRewardGroup,String[] rewardArr,String[] weightArr, Map<Integer, Integer> itemMap, Map<Integer, Integer> cardMap) {
for (int i = 0 ; i < sRewardGroup.getRewardMaxNum();i++){
int itemId = 0;
for (int j = 0 ; j < sRewardGroup.getLoop();i++){
int index = MathUtils.randomForStrArray(weightArr);
itemId = Integer.parseInt(rewardArr[index]);
if (itemId ==Integer.parseInt(rewardArr[j])){
break;
}
}
if (0 == itemId){
int index = MathUtils.randomForStrArray(weightArr);
itemId = Integer.parseInt(rewardArr[index]);
}
SRewardItem sRewardItem = SRewardItem.getsDropMap().get(itemId);
getMap(itemId,itemMap, cardMap, sRewardItem);
}
}
private static void getRandomMap(int randomItemNum ,String[] rewardArr,String[] weightArr, Map<Integer, Integer> itemMap, Map<Integer, Integer> cardMap) {
for (int i = 0 ; i < randomItemNum;i++){
int index = MathUtils.randomForStrArray(weightArr);
int itemId = Integer.parseInt(rewardArr[index]);
SRewardItem sRewardItem = SRewardItem.getsDropMap().get(itemId);
getMap(itemId,itemMap, cardMap, sRewardItem);
}
}
private static void getMap(String[] itemInfo, Map<Integer, Integer> itemMap,Map<Integer, Integer> cardMap) {
for (String itemId :itemInfo){
SRewardItem sRewardItem = SRewardItem.getsDropMap().get(Integer.parseInt(itemId));
getMap(Integer.parseInt(itemId),itemMap, cardMap, sRewardItem);
}
}
private static void getMap(int itemId ,Map<Integer, Integer> itemMap, Map<Integer, Integer> cardMap, SRewardItem sRewardItem) {
int itemNum = MathUtils.random(sRewardItem.getRandomMin(), sRewardItem.getRandomMax());
SItem sItem = SItem.getsItemMap().get(itemId);
switch (sItem.getItemType()) {
case GlobalItemType.ITEM:
putcountMap(itemId,itemNum,itemMap);
break;
case GlobalItemType.CARD:
putcountMap(itemId,itemNum,cardMap);
break;
default:
break;
}
}
private static void putcountMap(int itemId,int itemNum, Map<Integer, Integer> map) {
map.merge(itemId, itemNum, (a, b) -> b + a);
}
/**
@ -74,6 +133,9 @@ public class ItemUtil {
ItemManager itemManager = user.getItemManager();
for (Map.Entry<Integer, Integer> entry : itemMap.entrySet()) {
SItem sItem = SItem.getsItemMap().get(entry.getKey());
if (sItem == null){
continue;
}
Item item = itemManager.getItem(entry.getKey());
if (item == null){
item = itemManager.newItem(entry.getKey(), entry.getValue());
@ -83,8 +145,7 @@ public class ItemUtil {
}
}
if (dropBuilder != null) {
CommonProto.Item itemProto = CommonProto.Item.newBuilder().setItemId(item.getItemId()).setItemNum(item.getItemNum()).build();
itemProtoList.add(itemProto);
itemProtoList.add(CBean2Proto.getItem(item));
}
}
dropBuilder.addAllItemlist(itemProtoList);
@ -124,4 +185,98 @@ public class ItemUtil {
return itemList;
}
public static void addCard(User user,Map<Integer,Integer> cardMap,CommonProto.Drop.Builder dropBuilder) throws Exception {
List<CommonProto.Hero> heroList = new CopyOnWriteArrayList<>();
for (Map.Entry<Integer, Integer> entry : cardMap.entrySet()) {
int count = entry.getValue();
for (int i = 0; i < count; i++) {
addCard(user, entry.getKey(),heroList);
}
}
dropBuilder.addAllHero(heroList);
}
public static void addCard(User user,int cardId,List<CommonProto.Hero> heroList) throws Exception {
HeroManager heroManager = user.getHeroManager();
Hero hero = new Hero(user.getId(),cardId);
heroManager.addHero(hero);
heroList.add(CBean2Proto.getHero(hero));
}
/**
*
* @param user
* @param costItems
* @return
* @throws Exception
*/
public static boolean itemCost(User user,int[][] costItems) throws Exception {
Map<Integer, Integer> itemMap = new HashMap<>();
Map<Integer, Integer> moneyMap = new HashMap<>();
selectCost(costItems,itemMap,moneyMap);
boolean result = checkCost(user, itemMap, moneyMap);
if (!result) {
return false;
}
useItem(user, itemMap);
useMoney(user, moneyMap);
return true;
}
private static void useMoney(User user, Map<Integer, Integer> moneyMap) throws Exception {
for (Map.Entry<Integer, Integer> entry : moneyMap.entrySet()) {
int itemId = entry.getKey();
int itemNum = entry.getValue();
if (itemId==GlobalItemType.GEM){
user.getPlayerInfoManager().setGem(user.getPlayerInfoManager().getGem() - itemNum);
}
}
}
private static boolean checkCost(User user, Map<Integer, Integer> itemMap, Map<Integer, Integer> moneyMap) {
if (itemMap != null) {
for (Map.Entry<Integer, Integer> entry : itemMap.entrySet()) {
Item item = user.getItemManager().getItem(entry.getKey());
if (item == null || item.getItemNum() < entry.getValue()) {
return false;
}
}
}
if (moneyMap != null) {
for (Map.Entry<Integer, Integer> entry : moneyMap.entrySet()) {
int count = 0;
if (entry.getKey() == GlobalItemType.GEM) {
count = user.getPlayerInfoManager().getGem();
}
if (count < entry.getValue()) {
return false;
}
}
}
return true;
}
private static void selectCost(int[][] costItems, Map<Integer, Integer> itemMap, Map<Integer, Integer> moneyMap) {
for (int[] costItem : costItems){
int itemId = costItem[0];
int itemNum = costItem[1];
SItem sItem = SItem.getsItemMap().get(itemId);
switch (sItem.getItemType()) {
case GlobalItemType.GEM:
putcountMap(itemId,itemNum,moneyMap);
break;
case GlobalItemType.ITEM:
putcountMap(itemId,itemNum,itemMap);
break;
default:
break;
}
}
}
}

View File

@ -0,0 +1,55 @@
package com.ljsd.jieling.util;
public class KeyGenUtils {
//机器码
private static String machineNum;
private static Object uuidLock = new Object();
private static Integer uuidIndex = 0;
private static long uuidPreTimeStamp = 0;
public static String produceIdByModule(UUIDEnum uuidEnum, String userId){
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(userId);
stringBuffer.append(machineNum);
if (uuidEnum.getValue()<=9){
stringBuffer.append(0).append(uuidEnum.getValue());
}else {
stringBuffer.append(uuidEnum.getValue());
}
long timestamp = 0;
int index = 0;
//必须加锁,否则多线程会有问题
//因是基于用户的,理论上可以不加锁,用户的处理在一个线程中
synchronized(uuidLock) {
timestamp = System.currentTimeMillis() / 1000;
if (timestamp > uuidPreTimeStamp) {
uuidIndex = 0;
uuidPreTimeStamp = timestamp;
}
index = uuidIndex++;
}
stringBuffer.append(timestamp);
//不是用format仅仅是为了提高效率
if(index < 10){
stringBuffer.append("000");
} else if(index < 100){
stringBuffer.append("00");
} else if(index < 1000){
stringBuffer.append("0");
}
stringBuffer.append(index);
return stringBuffer.toString();
}
public static void setMachineNum(int machineNum) {
if(machineNum/10 == 0){
KeyGenUtils.machineNum = "0" + machineNum;
}else{
KeyGenUtils.machineNum = machineNum +"";
}
}
}

View File

@ -22,10 +22,10 @@ public class MathUtils {
* @param rateArray
* @return
*/
public static int randomForStrArray(int[] rateArray) {
public static int randomForStrArray(String [] rateArray) {
return randomStrArray(rateArray, -1);
}
public static int randomStrArray(int[] rateArray, int minSum) {
public static int randomStrArray(String [] rateArray, int minSum) {
if (null == rateArray) {
throw new IllegalArgumentException(
"The random array must not be null!");
@ -42,11 +42,11 @@ public class MathUtils {
for (int i = 0; i < arrayLength; i++) {
if (rateArray[i] < 0) {
if (Integer.parseInt(rateArray[i]) < 0) {
throw new IllegalArgumentException(
"The array's element must not be equal or greater than zero!");
}
rateSum += rateArray[i];
rateSum += Integer.parseInt(rateArray[i]);
rateSumArray[i] = rateSum;
}
if (rateSum <= 0) {

View File

@ -5,6 +5,7 @@ import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.netty.PackageConstant;
import com.ljsd.jieling.netty.cocdex.Tea;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -43,10 +44,14 @@ public class MessageUtil {
}
public static void sendMessage(ISession session, int result, int msgId, GeneratedMessage generatedMessage, boolean flush) throws Exception {
public static void sendMessage(ISession session, int result, int msgId, GeneratedMessage generatedMessage, boolean flush) {
byte[] byteBuf = wrappedBuffer(session.getUid(), session.getToken(), session.getIndex(), result, msgId, generatedMessage);
UserManager.ljsdMongoTemplate.lastUpdate();
System.out.println("-----> msgId : "+ msgId+"; length : "+byteBuf.length+"; content : "+byteBuf);
try {
UserManager.ljsdMongoTemplate.lastUpdate();
} catch (Exception e) {
e.printStackTrace();
}
// System.out.println("-----> msgId : "+ msgId+"; length : "+byteBuf.length+"; content : "+byteBuf);
if (flush) {
session.writeAndFlush(byteBuf);
} else {
@ -59,23 +64,19 @@ public class MessageUtil {
+ PackageConstant.MSG_ID_FIELD_LEN ;
byte[] bytes = new byte[length];
int pos = 0;
Tea.intToByte(bytes, pos, 100001);
Tea.intToByte(bytes, pos, session.getUid());
pos += PackageConstant.UID_FIELD_LEN;
Tea.intToByte(bytes, pos, 123456);
Tea.intToByte(bytes, pos, session.getToken());
pos += PackageConstant.TOKEN_LEN;
Tea.intToByte(bytes, pos, 1001);
Tea.intToByte(bytes, pos, MessageTypeProto.MessageType.HEART_BEAT_RESPONSE_VALUE);
byte[] byteBuf = Tea.encrypt2(bytes, Tea.KEY);
session.writeAndFlush(byteBuf);
}
public static void sendErrorCode(ISession session,int result,int msgId,String errMsg) throws Exception {
/* if(StringUtils.isEmpty(errMsg)){
sendMessage(session, result, msgId, null, true);
}else{
PlayerInfoProto.ErrorMsgResponse build = PlayerInfoProto.ErrorMsgResponse.newBuilder().setMsg(errMsg).build();
sendMessage(session, result, msgId, build, true);
}*/
public static void sendErrorCode(ISession session,int errorCode) {
byte[] byteBuf = wrappedBuffer(session.getUid(), session.getToken(), session.getIndex(),
errorCode, MessageTypeProto.MessageType.ERROR_CODE_INDICATION_VALUE, null);
session.writeAndFlush(byteBuf);
}
// public static void sendErrorResponse(Msg msg, GeneratedMessage error_message, int msgId) throws Exception {

View File

@ -147,4 +147,11 @@ public class StringUtil {
return str;
}
public static boolean isEmpty(String source){
if( source == null || source.isEmpty()){
return true;
}
return false;
}
}

View File

@ -0,0 +1,15 @@
package com.ljsd.jieling.util;
public enum UUIDEnum {
HERO(0),
EQUIP(1);
private int value;
UUIDEnum( int value ){
this.value = value;
}
public int getValue() {
return value;
}
}

View File

@ -1,6 +1,7 @@
#server info
server.id = 10180
server.id = 10212
server.openTime = 20190101000101
server.num = 1
# redis config
@ -29,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_msy
spring.data.mongodb.uri = mongodb://60.1.1.14:27017/jieling_10212
mongodb.options.maxWaitTime = 120000
mongodb.options.connectTimeout = 1000
mongodb.options.socketTimeout = 0
@ -40,7 +41,7 @@ mongodb.options.maxConnectionIdleTime = 1000
# netty config
netty.tcpPort = 18090
netty.tcpPort = 16080
netty.chatTcpPort = 20001
netty.logintcpPort = 18091
netty.udpPort = 18092
@ -54,14 +55,5 @@ netty.writeTimeout=32
netty.allTimeout=35
#core
services.core.ip=60.1.1.180
services.core.port=7900
services.core.area=1000
services.core.id=1
services.core.weight=5
#arena service
services.fight.key=key_dir_checkserver_Hash
logging.config = conf/logback-boot.xml

View File

@ -154,7 +154,7 @@ public class ExcelUtils {
int rownum = sheet.getLastRowNum();
FileWriter fw = new FileWriter(path + sheetName + ".txt");
PrintWriter out = new PrintWriter(fw);
for (int i = 0; i < rownum; i++) {
for (int i = 0; i <= rownum; i++) {
if (i == 2 || i == 3 || i == 4 ||i == 5||i == 6){
continue;
}

View File

@ -2,7 +2,7 @@ package network.client;
import com.google.protobuf.*;
import com.ljsd.jieling.netty.cocdex.Tea;
import com.ljsd.jieling.protocols.GMCommandProto;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.HeroInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.protocols.PlayerInfoProto;
@ -44,6 +44,7 @@ public class NettyClient {
handler.sendRequest_jieling(makeFinalMessage(gameMessage, MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE));
handler.sendRequest_jieling(makeFinalMessage(getHero(), MessageTypeProto.MessageType.GET_HEROINFO_REQUEST_VALUE));
handler.sendRequest_jieling(makeFinalMessage(getRandomHero(), MessageTypeProto.MessageType.HERO_RAND_REQQUEST_VALUE));
handler.sendRequest_jieling(makeFinalMessage(gmRequest(), MessageTypeProto.MessageType.GM_REQUEST_VALUE));
}
@ -69,8 +70,8 @@ public class NettyClient {
return finalData;
}
public static GMCommandProto.GMCommand gmRequest(){
return GMCommandProto.GMCommand.newBuilder().setCommand("10000001#0#1#100").build();
public static CommonProto.GMCommand gmRequest(){
return CommonProto.GMCommand.newBuilder().setCommand("10000001#0#1#100").build();
}

View File

@ -3,9 +3,7 @@ package network.client;
import com.google.protobuf.MessageLite;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.netty.cocdex.Tea;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.HeroInfoProto;
import com.ljsd.jieling.protocols.PlayerInfoProto;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
@ -20,6 +18,7 @@ import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.atomic.AtomicInteger;
import static com.ljsd.jieling.protocols.MessageTypeProto.MessageType.GET_HEROINFO_RESPONSE_VALUE;
import static com.ljsd.jieling.protocols.MessageTypeProto.MessageType.HERO_RAND_RESPONSE_VALUE;
/**
* Created by justin on 14-8-12.
@ -120,6 +119,15 @@ public class NettyTCPClientHandler extends SimpleChannelInboundHandler<Object> {
// System.out.println("--->>>>" + heroListCount);
}
if(msgId == HERO_RAND_RESPONSE_VALUE){
HeroInfoProto.HeroRandResponse heroRandResponse = HeroInfoProto.HeroRandResponse.parseFrom(packetData);
int heroListCount = heroRandResponse.getHeroListCount();
// int heroListCount = getHeroInfoResponse.getHeroListCount();
//int heroListCount = getHeroInfoResponse.getHeroListCount();
// System.out.println("--->>>>" + heroListCount);
}
System.out.println("back hartbeat id : "+msgId);
//System.out.println(JsonFormat.printToString());