Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
245ed58ec8
|
@ -28,6 +28,10 @@ public class LjsdMongoTemplate {
|
|||
root.setBsave(true);
|
||||
}
|
||||
|
||||
public <T> void saveWithoutMongoRoot(T obj) throws Exception {
|
||||
mongoTemplate.save(obj);
|
||||
}
|
||||
|
||||
public <T> List<T> findAll(String collectionName, Class<T> clazz) throws Exception {
|
||||
DBCollection coll = mongoTemplate.getCollection(collectionName);
|
||||
DBCursor dbCursor = coll.find();
|
||||
|
@ -44,6 +48,10 @@ public class LjsdMongoTemplate {
|
|||
return BeanUtil.dbObject2Bean(doc, clazz);
|
||||
}
|
||||
|
||||
public <T> T findById(int id, Class<T> clazz) throws Exception {
|
||||
return mongoTemplate.findById(id,clazz);
|
||||
}
|
||||
|
||||
public void chnage(Object obj){
|
||||
Class<?> clazz = obj.getClass();
|
||||
}
|
||||
|
|
|
@ -1,57 +1,58 @@
|
|||
Id PiecesId PiecesCount Profession PropertyName MaxRank Hp Attack PhysicalDefence MagicDefence Speed SkillId RankupConsumeMaterial
|
||||
int int int int int int float float float float float mut,int#int,2 mut,int#int,2
|
||||
1 2001 0 1 1 10 2389 164 278 0 176 10100#10|10101#20 null
|
||||
2 2002 0 5 2 10 2277 155 260 0 158 10100#10|10101#20 null
|
||||
3 2003 0 2 3 10 2275 159 263 0 172 10100#10|10101#20 null
|
||||
4 2004 0 3 4 10 2269 183 0 277 132 10100#10|10101#20 null
|
||||
5 2005 0 4 5 10 2163 173 0 258 176 10100#10|10101#20 null
|
||||
6 2006 0 3 6 10 2165 174 0 261 176 10100#10|10101#20 null
|
||||
7 2007 0 0 2 10 2159 169 0 262 176 10100#10|10101#20 null
|
||||
8 2008 0 0 2 10 2020 206 0 222 132 10100#10|10101#20 null
|
||||
9 2009 0 0 2 10 1923 198 0 212 163 10100#10|10101#20 null
|
||||
10 2010 0 0 2 10 1925 200 0 208 132 10100#10|10101#20 null
|
||||
11 2011 0 0 2 10 1925 199 0 203 150 10100#10|10101#20 null
|
||||
12 2012 0 0 2 10 1763 251 201 0 150 10100#10|10101#20 null
|
||||
13 2013 0 0 3 10 1675 239 194 0 163 10100#10|10101#20 null
|
||||
14 2014 0 0 3 10 1684 235 197 0 185 10100#10|10101#20 null
|
||||
15 2015 0 0 3 10 1680 237 193 0 176 10100#10|10101#20 null
|
||||
16 2016 0 0 3 10 1513 293 167 0 154 10100#10|10101#20 null
|
||||
17 2017 0 0 3 10 1439 278 159 0 154 10100#10|10101#20 null
|
||||
18 2018 0 0 3 10 1439 278 159 0 154 10100#10|10101#20 null
|
||||
19 2019 0 0 4 10 1444 281 153 0 154 10100#10|10101#20 null
|
||||
20 2020 0 0 4 10 2277 159 261 0 154 10100#10|10101#20 null
|
||||
21 2021 0 0 4 10 1936 131 225 0 176 10100#10|10101#20 null
|
||||
22 2022 0 0 4 10 1637 168 0 178 163 10100#10|10101#20 null
|
||||
23 2023 0 0 4 10 1431 200 162 0 194 10100#10|10101#20 null
|
||||
24 2024 0 0 4 10 1220 239 133 0 154 10100#10|10101#20 null
|
||||
25 2025 0 0 4 10 1832 143 0 222 176 10100#10|10101#20 null
|
||||
26 2026 0 0 4 10 1934 136 226 0 176 10100#10|10101#20 null
|
||||
27 2027 0 0 4 10 1628 173 0 175 163 10100#10|10101#20 null
|
||||
28 2028 0 0 4 10 1428 209 165 0 194 10100#10|10101#20 null
|
||||
29 2029 0 0 4 10 1222 235 132 0 154 10100#10|10101#20 null
|
||||
30 2030 0 0 4 10 1834 149 0 224 176 10100#10|10101#20 null
|
||||
31 2031 0 0 4 10 1940 131 220 0 176 10100#10|10101#20 null
|
||||
32 2032 0 0 4 10 1632 165 0 177 163 10100#10|10101#20 null
|
||||
33 2033 0 0 4 10 1429 205 164 0 194 10100#10|10101#20 null
|
||||
34 2034 0 0 4 10 1221 242 135 0 154 10100#10|10101#20 null
|
||||
35 2035 0 0 4 10 1834 147 0 225 176 10100#10|10101#20 null
|
||||
36 2036 0 0 4 10 1934 136 217 0 176 10100#10|10101#20 null
|
||||
37 2037 0 0 4 10 1637 170 0 179 163 10100#10|10101#20 null
|
||||
38 2038 0 0 4 10 1427 201 170 0 194 10100#10|10101#20 null
|
||||
39 2039 0 0 4 10 1300 235 129 0 154 10100#10|10101#20 null
|
||||
40 2040 0 0 4 10 1948 147 0 219 176 10100#10|10101#20 null
|
||||
41 2041 0 0 4 10 1938 135 224 0 176 10100#10|10101#20 null
|
||||
42 2042 0 0 4 10 1636 174 0 179 163 10100#10|10101#20 null
|
||||
43 2043 0 0 4 10 1943 132 217 0 176 10100#10|10101#20 null
|
||||
44 2044 0 0 4 10 1627 166 0 181 163 10100#10|10101#20 null
|
||||
45 2045 0 0 4 10 1433 209 166 0 194 10100#10|10101#20 null
|
||||
46 2046 0 0 4 10 1228 241 131 0 154 10100#10|10101#20 null
|
||||
47 2047 0 0 4 10 1836 146 0 226 176 10100#10|10101#20 null
|
||||
48 2048 0 0 4 10 1939 141 223 0 176 10100#10|10101#20 null
|
||||
49 2049 0 0 4 10 1635 175 0 173 163 10100#10|10101#20 null
|
||||
50 2050 0 0 4 10 1424 208 166 0 194 10100#10|10101#20 null
|
||||
51 2051 0 0 4 10 1222 234 132 0 154 10100#10|10101#20 null
|
||||
52 2052 0 0 4 10 1834 140 0 220 176 10100#10|10101#20 null
|
||||
53 2053 0 0 4 10 1943 135 219 0 176 10100#10|10101#20 null
|
||||
54 2054 0 0 4 10 1630 169 0 176 163 10100#10|10101#20 null
|
||||
55 2055 0 0 4 10 1508 205 163 0 194 10100#10|10101#20 null
|
||||
Id PiecesId PiecesCount Star Profession PropertyName MaxRank Hp Attack PhysicalDefence MagicDefence Speed SkillId RankupConsumeMaterial
|
||||
int int int int int int int float float float float float mut,int#int,2 mut,int#int,2
|
||||
10001 11001 50 5 1 1 10 2390 167 275 96 176 10100#10|10101#20 null
|
||||
10002 11002 50 5 5 2 10 2278 165 265 93 158 10100#10|10101#20 null
|
||||
10003 11003 50 5 2 3 10 2277 155 259 91 172 10100#10|10101#20 null
|
||||
10004 11004 50 5 3 4 10 2263 183 97 278 132 10100#10|10101#20 null
|
||||
10005 11005 50 5 4 5 10 2163 170 92 263 176 10100#10|10101#20 null
|
||||
10006 11006 50 5 3 6 10 2159 174 93 265 176 10100#10|10101#20 null
|
||||
10007 11007 50 5 0 2 10 2161 168 91 261 176 10100#10|10101#20 null
|
||||
10008 11008 50 5 0 2 10 2016 208 77 220 132 10100#10|10101#20 null
|
||||
10009 11009 50 5 0 2 10 1922 196 74 212 163 10100#10|10101#20 null
|
||||
10010 11010 50 5 0 2 10 1919 202 71 203 132 10100#10|10101#20 null
|
||||
10011 11011 50 5 0 2 10 1921 198 71 203 150 10100#10|10101#20 null
|
||||
10012 11012 50 5 0 2 10 1768 253 201 70 150 10100#10|10101#20 null
|
||||
10013 11013 50 5 0 3 10 1682 244 199 70 163 10100#10|10101#20 null
|
||||
10014 11014 50 5 0 3 10 1676 245 200 70 185 10100#10|10101#20 null
|
||||
10015 11015 50 5 0 3 10 1680 245 198 69 176 10100#10|10101#20 null
|
||||
10016 11016 50 5 0 3 10 1507 293 160 56 154 10100#10|10101#20 null
|
||||
10017 11017 50 5 0 3 10 1437 278 157 55 154 10100#10|10101#20 null
|
||||
10018 11018 50 5 0 3 10 1440 285 154 54 154 10100#10|10101#20 null
|
||||
10019 11019 50 5 0 4 10 1440 284 159 56 154 10100#10|10101#20 null
|
||||
10020 11020 50 5 0 4 10 2280 164 256 90 154 10100#10|10101#20 null
|
||||
10021 11021 40 4 0 4 10 1941 133 218 76 176 10100#10|10101#20 null
|
||||
10022 11022 40 4 0 4 10 1630 175 62 178 163 10100#10|10101#20 null
|
||||
10023 11023 40 4 0 4 10 1428 208 161 56 194 10100#10|10101#20 null
|
||||
10024 11024 40 4 0 4 10 1225 237 135 47 154 10100#10|10101#20 null
|
||||
10025 11025 40 4 0 4 10 1831 148 78 223 176 10100#10|10101#20 null
|
||||
10026 11026 40 4 0 4 10 1943 132 223 78 176 10100#10|10101#20 null
|
||||
10027 11027 40 4 0 4 10 1629 169 61 173 163 10100#10|10101#20 null
|
||||
10028 11028 40 4 0 4 10 1431 203 166 58 194 10100#10|10101#20 null
|
||||
10029 11029 40 4 0 4 10 1223 241 136 48 154 10100#10|10101#20 null
|
||||
10030 11030 40 4 0 4 10 1835 140 76 218 176 10100#10|10101#20 null
|
||||
10031 11031 40 4 0 4 10 1940 133 221 77 176 10100#10|10101#20 null
|
||||
10032 11032 40 4 0 4 10 1636 172 61 175 163 10100#10|10101#20 null
|
||||
10033 11033 40 4 0 4 10 1433 209 169 59 194 10100#10|10101#20 null
|
||||
10034 11034 40 4 0 4 10 1222 237 137 48 154 10100#10|10101#20 null
|
||||
10035 11035 40 4 0 4 10 1832 147 76 217 176 10100#10|10101#20 null
|
||||
10036 11036 40 4 0 4 10 1933 137 217 76 176 10100#10|10101#20 null
|
||||
10037 11037 40 4 0 4 10 1630 170 63 180 163 10100#10|10101#20 null
|
||||
10038 11038 40 4 0 4 10 1428 204 169 59 194 10100#10|10101#20 null
|
||||
10039 11039 40 4 0 4 10 1292 235 136 48 154 10100#10|10101#20 null
|
||||
10040 11040 40 4 0 4 10 1945 142 78 224 176 10100#10|10101#20 null
|
||||
10041 11041 40 4 0 4 10 1935 134 225 79 176 10100#10|10101#20 null
|
||||
10042 11042 40 4 0 4 10 1634 172 63 179 163 10100#10|10101#20 null
|
||||
10043 11043 40 4 0 4 10 1943 134 220 77 176 10100#10|10101#20 null
|
||||
10044 11044 40 4 0 4 10 1629 169 61 173 163 10100#10|10101#20 null
|
||||
10045 11045 40 4 0 4 10 1423 200 167 58 194 10100#10|10101#20 null
|
||||
10046 11046 30 3 0 4 10 1222 240 135 47 154 10100#10|10101#20 null
|
||||
10047 11047 30 3 0 4 10 1838 140 79 225 176 10100#10|10101#20 null
|
||||
10048 11048 30 3 0 4 10 1940 138 220 77 176 10100#10|10101#20 null
|
||||
10049 11049 30 3 0 4 10 1627 165 62 176 163 10100#10|10101#20 null
|
||||
10050 11050 30 3 0 4 10 1433 204 169 59 194 10100#10|10101#20 null
|
||||
10051 11051 30 3 0 4 10 1222 233 131 46 154 10100#10|10101#20 null
|
||||
10052 11052 30 3 0 4 10 1834 142 79 225 176 10100#10|10101#20 null
|
||||
10053 11053 30 3 0 4 10 1937 141 224 78 176 10100#10|10101#20 null
|
||||
10054 11054 30 3 0 4 10 1633 167 61 174 163 10100#10|10101#20 null
|
||||
10055 11055 30 3 0 4 10 1516 202 166 58 194 10100#10|10101#20 null
|
||||
10056 11056 30 3 0 4 10 1299 235 129 45 154 10100#10|10101#20 null
|
||||
|
|
|
@ -1,6 +1,130 @@
|
|||
Id BackpackOrNot ItemType ItemBaseType Quantity IsStacking
|
||||
int bool int int int bool
|
||||
1 false 1 1 5 false
|
||||
2 true 1 1 5 false
|
||||
3 true 1 1 5 false
|
||||
4 false 1 1 5 false
|
||||
Id ItemType Quantity IsStacking
|
||||
int int int bool
|
||||
1 0 5 true
|
||||
2 0 5 true
|
||||
3 0 5 true
|
||||
4 0 5 true
|
||||
5 0 5 true
|
||||
1001 0 1 true
|
||||
1002 0 2 true
|
||||
1003 0 3 true
|
||||
1004 0 4 true
|
||||
1005 0 5 true
|
||||
1006 0 5 true
|
||||
1007 0 5 true
|
||||
1008 0 5 true
|
||||
1009 0 5 true
|
||||
1100 0 3 true
|
||||
1101 0 3 true
|
||||
10001 1 5 false
|
||||
10002 1 5 false
|
||||
10003 1 5 false
|
||||
10004 1 5 false
|
||||
10005 1 5 false
|
||||
10006 1 5 false
|
||||
10007 1 5 false
|
||||
10008 1 5 false
|
||||
10009 1 5 false
|
||||
10010 1 5 false
|
||||
10011 1 5 false
|
||||
10012 1 5 false
|
||||
10013 1 5 false
|
||||
10014 1 5 false
|
||||
10015 1 5 false
|
||||
10016 1 5 false
|
||||
10017 1 5 false
|
||||
10018 1 5 false
|
||||
10019 1 5 false
|
||||
10020 1 5 false
|
||||
10021 1 5 false
|
||||
10022 1 5 false
|
||||
10023 1 5 false
|
||||
10024 1 5 false
|
||||
10025 1 5 false
|
||||
10026 1 5 false
|
||||
10027 1 5 false
|
||||
10028 1 5 false
|
||||
10029 1 5 false
|
||||
10030 1 5 false
|
||||
10031 1 5 false
|
||||
10032 1 5 false
|
||||
10033 1 5 false
|
||||
10034 1 5 false
|
||||
10035 1 5 false
|
||||
10036 1 5 false
|
||||
10037 1 5 false
|
||||
10038 1 5 false
|
||||
10039 1 5 false
|
||||
10040 1 5 false
|
||||
10041 1 5 false
|
||||
10042 1 5 false
|
||||
10043 1 5 false
|
||||
10044 1 5 false
|
||||
10045 1 5 false
|
||||
10046 1 5 false
|
||||
10047 1 5 false
|
||||
10048 1 5 false
|
||||
10049 1 5 false
|
||||
10050 1 5 false
|
||||
10051 1 5 false
|
||||
10052 1 5 false
|
||||
10053 1 5 false
|
||||
10054 1 5 false
|
||||
10055 1 5 false
|
||||
10056 1 5 false
|
||||
11001 2 5 true
|
||||
11002 2 5 true
|
||||
11003 2 5 true
|
||||
11004 2 5 true
|
||||
11005 2 5 true
|
||||
11006 2 5 true
|
||||
11007 2 5 true
|
||||
11008 2 5 true
|
||||
11009 2 5 true
|
||||
11010 2 5 true
|
||||
11011 2 5 true
|
||||
11012 2 5 true
|
||||
11013 2 5 true
|
||||
11014 2 5 true
|
||||
11015 2 5 true
|
||||
11016 2 5 true
|
||||
11017 2 5 true
|
||||
11018 2 5 true
|
||||
11019 2 5 true
|
||||
11020 2 5 true
|
||||
11021 2 5 true
|
||||
11022 2 5 true
|
||||
11023 2 5 true
|
||||
11024 2 5 true
|
||||
11025 2 5 true
|
||||
11026 2 5 true
|
||||
11027 2 5 true
|
||||
11028 2 5 true
|
||||
11029 2 5 true
|
||||
11030 2 5 true
|
||||
11031 2 5 true
|
||||
11032 2 5 true
|
||||
11033 2 5 true
|
||||
11034 2 5 true
|
||||
11035 2 5 true
|
||||
11036 2 5 true
|
||||
11037 2 5 true
|
||||
11038 2 5 true
|
||||
11039 2 5 true
|
||||
11040 2 5 true
|
||||
11041 2 5 true
|
||||
11042 2 5 true
|
||||
11043 2 5 true
|
||||
11044 2 5 true
|
||||
11045 2 5 true
|
||||
11046 2 5 true
|
||||
11047 2 5 true
|
||||
11048 2 5 true
|
||||
11049 2 5 true
|
||||
11050 2 5 true
|
||||
11051 2 5 true
|
||||
11052 2 5 true
|
||||
11053 2 5 true
|
||||
11054 2 5 true
|
||||
11055 2 5 true
|
||||
11056 2 5 true
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
Id Reward ItemName Pool Weight
|
||||
int mut,int#int,1 string int int
|
||||
2 10002#1 角色2 1 11
|
||||
3 10003#1 角色3 1 11
|
||||
4 10004#1 角色4 1 8
|
||||
5 10005#1 角色5 1 11
|
||||
6 10006#1 角色6 1 11
|
||||
7 10007#1 角色7 1 11
|
||||
8 10008#1 角色8 1 8
|
||||
9 10009#1 角色9 1 11
|
||||
10 10010#1 角色10 1 5
|
||||
11 10011#1 角色11 1 11
|
||||
12 10012#1 角色12 1 8
|
||||
13 10013#1 角色13 1 11
|
||||
14 10014#1 角色14 1 5
|
||||
15 10015#1 角色15 1 11
|
||||
16 10016#1 角色16 1 8
|
||||
17 10017#1 角色17 1 11
|
||||
18 10018#1 角色18 1 5
|
||||
19 10019#1 角色19 1 5
|
||||
20 10020#1 角色20 1 11
|
||||
21 10021#1 角色21 1 95
|
||||
22 10022#1 角色22 1 95
|
||||
23 10023#1 角色23 1 95
|
||||
24 10024#1 角色24 1 95
|
||||
25 10025#1 角色25 1 95
|
||||
26 10026#1 角色26 1 95
|
||||
27 10027#1 角色27 1 95
|
||||
28 10028#1 角色28 1 95
|
||||
29 10029#1 角色29 1 95
|
||||
30 10030#1 角色30 1 95
|
||||
31 10031#1 角色31 1 95
|
||||
32 10032#1 角色32 1 95
|
||||
33 10033#1 角色33 1 95
|
||||
34 10034#1 角色34 1 95
|
||||
35 10035#1 角色35 1 95
|
||||
36 10036#1 角色36 1 95
|
||||
37 10037#1 角色37 1 95
|
||||
38 10038#1 角色38 1 95
|
||||
39 10039#1 角色39 1 47
|
||||
40 10040#1 角色40 1 47
|
||||
41 10041#1 角色41 1 95
|
||||
42 10042#1 角色42 1 95
|
||||
43 10043#1 角色43 1 600
|
||||
44 10044#1 角色44 1 600
|
||||
45 10045#1 角色45 1 600
|
||||
46 10046#1 角色46 1 600
|
||||
47 10047#1 角色47 1 600
|
||||
48 10048#1 角色48 1 600
|
||||
49 10049#1 角色49 1 600
|
||||
50 10050#1 角色50 1 600
|
||||
51 10051#1 角色51 1 600
|
||||
52 10052#1 角色52 1 600
|
||||
53 10053#1 角色53 1 600
|
||||
54 10054#1 角色54 1 600
|
||||
55 10055#1 角色55 1 300
|
||||
56 10056#1 角色56 1 300
|
||||
57 10035#1 角色35 11 100
|
||||
58 10036#1 角色36 11 100
|
||||
59 10037#1 角色37 11 100
|
||||
60 10038#1 角色38 11 100
|
||||
61 10031#1 角色31 12 100
|
||||
62 10032#1 角色32 12 100
|
||||
63 10033#1 角色33 12 100
|
||||
64 10034#1 角色34 12 100
|
||||
65 10026#1 角色26 13 100
|
||||
66 10027#1 角色27 13 100
|
||||
67 10028#1 角色28 13 100
|
||||
68 10029#1 角色29 13 100
|
||||
69 10021#1 角色21 14 100
|
||||
70 10022#1 角色22 14 100
|
||||
71 10023#1 角色23 14 100
|
||||
72 10024#1 角色24 14 100
|
|
@ -0,0 +1,6 @@
|
|||
Id OrderBoxOpenTime OrderBoxContinue OrderBoxInterval OrderBoxPool DiamondBoxInterval Cost GetHerosInterval DiamondBoxContain TenTimesMustGetItem PerCount
|
||||
int int int int mut,int#int,1 int mut,int#int,1 int mut,int#int,2 mut,int#int,1 int
|
||||
1 56 48 120 11#12#13#14 0 3#10 0 null null 10
|
||||
2 56 48 120 11#12#13#14 0 3#1 0 null null 1
|
||||
11 0 0 0 null 0 220 150 1#100 3#1 10
|
||||
12 0 0 0 null 2160.0 2200 0 1#100 null 1
|
|
@ -1,5 +1,7 @@
|
|||
package com.ljsd;
|
||||
|
||||
import com.ljsd.common.mogodb.LjsdMongoTemplate;
|
||||
import com.ljsd.jieling.config.ServerConfig;
|
||||
import com.ljsd.jieling.config.json.ServerConfiguration;
|
||||
import com.ljsd.jieling.config.json.ServerProperties;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
|
@ -12,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.TimeUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
|
@ -21,6 +24,8 @@ import org.springframework.context.annotation.ComponentScan;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
|
@ -39,6 +44,8 @@ public class GameApplication {
|
|||
// public static ServerProperties serverProperties;
|
||||
public static boolean start = false;
|
||||
|
||||
public static ServerConfig serverConfig;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
start = true;
|
||||
app = new SpringApplication(GameApplication.class);
|
||||
|
@ -62,7 +69,7 @@ public class GameApplication {
|
|||
|
||||
RedisUtil.getInstence().init(configurableApplicationContext);
|
||||
|
||||
// STableManager.initialize("com.ljsd.jieling.config");
|
||||
STableManager.initialize("com.ljsd.jieling.config");
|
||||
|
||||
UserManager.init(configurableApplicationContext);
|
||||
|
||||
|
@ -71,6 +78,24 @@ public class GameApplication {
|
|||
|
||||
final NettyServerAutoConfiguration netServerConfig = configurableApplicationContext.getBean(NettyServerAutoConfiguration.class);
|
||||
NettyProperties properties = netServerConfig.getNettyProperties();
|
||||
//todo 设置开服时间
|
||||
ServerConfig serverConfigTmp = UserManager.ljsdMongoTemplate.findById(1, ServerConfig.class);
|
||||
if( null == serverConfigTmp ){
|
||||
serverConfigTmp = new ServerConfig();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
long serverOenTime = TimeUtils.getAppointTime(5);
|
||||
String format = simpleDateFormat.format(serverOenTime);
|
||||
serverConfigTmp.setOpenTime(format);
|
||||
serverConfigTmp.setCacheOpenTime(serverOenTime);
|
||||
serverConfigTmp.setId(1);
|
||||
UserManager.ljsdMongoTemplate.saveWithoutMongoRoot(serverConfigTmp);
|
||||
}else{
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String openTime = serverConfigTmp.getOpenTime();
|
||||
Date date = simpleDateFormat.parse(openTime);
|
||||
serverConfigTmp.setCacheOpenTime(date.getTime());
|
||||
serverConfig = serverConfigTmp;
|
||||
}
|
||||
try {
|
||||
LOGGER.info("main->CoreApplication start...");
|
||||
ISessionFactory sessionFactory = new ISessionFactory();
|
||||
|
|
|
@ -22,6 +22,8 @@ public class SCHero implements BaseConfig{
|
|||
|
||||
private int maxRank; //角色最高星级
|
||||
|
||||
private int star;
|
||||
|
||||
private float hp;
|
||||
|
||||
private float attack; //攻击力
|
||||
|
@ -39,7 +41,7 @@ public class SCHero implements BaseConfig{
|
|||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
// sCHero = STableManager.getConfig(SCHero.class);
|
||||
sCHero = STableManager.getConfig(SCHero.class);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
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 ="LotteryRewardConfig")
|
||||
public class SLotteryRewardConfig implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int[] reward;
|
||||
|
||||
private String itemName;
|
||||
|
||||
private int pool;
|
||||
|
||||
private int weight;
|
||||
|
||||
private static Map<Integer, List<SLotteryRewardConfig>> sLotteryRewardConfigsByPoolId;
|
||||
private static Map<Integer, Integer> sLotteryRewardWeightByPoolId;
|
||||
|
||||
public static List<SLotteryRewardConfig> getSLotteryRewardConfigListByPoolId(int poolId) {
|
||||
return sLotteryRewardConfigsByPoolId.get(poolId);
|
||||
}
|
||||
|
||||
public static int getTotalCountByPoolId(int poolId) {
|
||||
return sLotteryRewardWeightByPoolId.get(poolId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
Map<Integer, SLotteryRewardConfig> config = STableManager.getConfig(SLotteryRewardConfig.class);
|
||||
Map<Integer, Integer> sLotteryRewardWeightByPoolIdTmp = new HashMap<>();
|
||||
Map<Integer, List<SLotteryRewardConfig>> sLotteryRewardConfigsByPoolIdTmp = new HashMap<>();
|
||||
for(SLotteryRewardConfig sLotteryRewardConfig : config.values()){
|
||||
int pool = sLotteryRewardConfig.getPool();
|
||||
int weight = sLotteryRewardConfig.getWeight();
|
||||
|
||||
if(!sLotteryRewardConfigsByPoolIdTmp.containsKey(pool)){
|
||||
sLotteryRewardConfigsByPoolIdTmp.put(pool,new ArrayList<>());
|
||||
}
|
||||
|
||||
sLotteryRewardConfigsByPoolIdTmp.get(pool).add(sLotteryRewardConfig);
|
||||
|
||||
if(!sLotteryRewardWeightByPoolIdTmp.containsKey(pool)){
|
||||
sLotteryRewardWeightByPoolIdTmp.put(pool,0);
|
||||
}
|
||||
sLotteryRewardWeightByPoolIdTmp.put(pool,sLotteryRewardWeightByPoolIdTmp.get(pool) + weight);
|
||||
}
|
||||
sLotteryRewardWeightByPoolId = sLotteryRewardWeightByPoolIdTmp;
|
||||
sLotteryRewardConfigsByPoolId = sLotteryRewardConfigsByPoolIdTmp;
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int[] getReward() {
|
||||
return reward;
|
||||
}
|
||||
|
||||
public String getItemName() {
|
||||
return itemName;
|
||||
}
|
||||
|
||||
public int getPool() {
|
||||
return pool;
|
||||
}
|
||||
|
||||
public int getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package com.ljsd.jieling.config;
|
||||
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="LotterySetting")
|
||||
public class SLotterySetting implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int orderBoxOpenTime;
|
||||
|
||||
private int orderBoxContinue;
|
||||
|
||||
private int orderBoxInterval;
|
||||
|
||||
private int[] orderBoxPool;
|
||||
|
||||
private int diamondBoxInterval;
|
||||
|
||||
private int[] cost;
|
||||
|
||||
private int getHerosInterval;
|
||||
|
||||
private int[][] diamondBoxContain;
|
||||
|
||||
private int[] tenTimesMustGetItem;
|
||||
|
||||
private int perCount;
|
||||
|
||||
private static Map<Integer,SLotterySetting> sLotterySettingByType;
|
||||
|
||||
public static Map<Integer, SLotterySetting> getsLotterySettingMap() {
|
||||
return sLotterySettingByType;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
sLotterySettingByType = STableManager.getConfig(SLotterySetting.class);
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getOrderBoxOpenTime() {
|
||||
return orderBoxOpenTime;
|
||||
}
|
||||
|
||||
public int getOrderBoxContinue() {
|
||||
return orderBoxContinue;
|
||||
}
|
||||
|
||||
public int getOrderBoxInterval() {
|
||||
return orderBoxInterval;
|
||||
}
|
||||
|
||||
public int[] getOrderBoxPool() {
|
||||
return orderBoxPool;
|
||||
}
|
||||
|
||||
public int getDiamondBoxInterval() {
|
||||
return diamondBoxInterval;
|
||||
}
|
||||
|
||||
public int[] getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
public int getGetHerosInterval() {
|
||||
return getHerosInterval;
|
||||
}
|
||||
|
||||
public int[][] getDiamondBoxContain() {
|
||||
return diamondBoxContain;
|
||||
}
|
||||
|
||||
public int[] getTenTimesMustGetItem() {
|
||||
return tenTimesMustGetItem;
|
||||
}
|
||||
|
||||
public int getPerCount() {
|
||||
return perCount;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.ljsd.jieling.config;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
import org.springframework.data.mongodb.core.mapping.Field;
|
||||
|
||||
@Document( collection = "server_config")
|
||||
public class ServerConfig {
|
||||
|
||||
@Id
|
||||
private int id;
|
||||
|
||||
@Field(value = "open_time")
|
||||
private String openTime;
|
||||
|
||||
@Transient
|
||||
private long cacheOpenTime;
|
||||
|
||||
public void setOpenTime(String openTime) {
|
||||
this.openTime = openTime;
|
||||
}
|
||||
|
||||
public String getOpenTime() {
|
||||
return openTime;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getCacheOpenTime() {
|
||||
return cacheOpenTime;
|
||||
}
|
||||
|
||||
public void setCacheOpenTime(long cacheOpenTime) {
|
||||
this.cacheOpenTime = cacheOpenTime;
|
||||
}
|
||||
}
|
|
@ -1,17 +1,23 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.config.SCHero;
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.dao.Hero;
|
||||
import com.ljsd.jieling.logic.dao.HeroManager;
|
||||
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.HeroInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.CBean2Proto;
|
||||
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;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class GetAllHerosHandler extends BaseHandler{
|
||||
|
@ -38,45 +44,13 @@ public class GetAllHerosHandler extends BaseHandler{
|
|||
// // SCHero scHero = SCHero.getsCHero().get(1);
|
||||
|
||||
List<CommonProto.Hero> heroList = new ArrayList<>();
|
||||
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();
|
||||
User user = UserManager.getUser(userId);
|
||||
HeroManager heroManager = user.getHeroManager();
|
||||
Map<String, Hero> heroMap = heroManager.getHeroMap();
|
||||
for(Hero hero : heroMap.values()){
|
||||
heroList.add(CBean2Proto.getHero(hero));
|
||||
}
|
||||
|
||||
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);
|
||||
heroList.add(hero2);
|
||||
heroList.add(hero3);
|
||||
|
||||
HeroInfoProto.GetHeroListInfoResponse build
|
||||
= HeroInfoProto.GetHeroListInfoResponse.newBuilder()
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.HeroInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component
|
||||
public class GetRandomHeroHandler extends BaseHandler{
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.HERO_RAND_REQQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
byte[] bytes = netData.parseClientProtoNetData();
|
||||
HeroInfoProto.HeroRandRequest heroRandRequest = HeroInfoProto.HeroRandRequest.parseFrom(bytes);
|
||||
int type = heroRandRequest.getType();
|
||||
HeroLogic.getInstance().random(iSession,type);
|
||||
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ public class MapEnterRequestHandler extends BaseHandler{
|
|||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
byte[] message = netData.parseClientProtoNetData();
|
||||
MapInfoProto.MapInfo.MapEnterRequest mapEnterRequest = MapInfoProto.MapInfo.MapEnterRequest.parseFrom(message);
|
||||
MapInfoProto.MapEnterRequest mapEnterRequest = MapInfoProto.MapEnterRequest.parseFrom(message);
|
||||
MapLogic.getInstance().enterMap(iSession, mapEnterRequest.getMapId(), MessageTypeProto.MessageType.MAP_ENTER_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,6 @@ public class MapLogic {
|
|||
user.setMapManager(mapManager);
|
||||
}
|
||||
}
|
||||
|
||||
List<CommonProto.Cell> cells = new ArrayList<>(mapManager.getMapInfo().size());
|
||||
for (Map.Entry<Integer, Cell> entry : mapManager.getMapInfo().entrySet()) {
|
||||
List<CommonProto.CellEvent> cellEvents = new ArrayList<>();
|
||||
|
@ -85,7 +84,7 @@ public class MapLogic {
|
|||
.build();
|
||||
cells.add(cellProto);
|
||||
}
|
||||
MapInfoProto.MapInfo.MapEnterResponse mapEnterResponse = MapInfoProto.MapInfo.MapEnterResponse
|
||||
MapInfoProto.MapEnterResponse mapEnterResponse = MapInfoProto.MapEnterResponse
|
||||
.newBuilder()
|
||||
.addAllMapList(cells)
|
||||
.setCurXY(mapManager.getCurXY())
|
||||
|
@ -121,14 +120,50 @@ public class MapLogic {
|
|||
mapManager.setTypeEight(spicelMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 战斗开始
|
||||
*/
|
||||
public void fightStart(ISession session, int bigEventId){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 战斗结束
|
||||
*/
|
||||
public void fightEnd(ISession session, int bigEventId){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用物品(包括侦察和吃buff)
|
||||
*/
|
||||
public void useItem(ISession session, int bigEventId){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 离开
|
||||
*/
|
||||
public void leave(ISession session, int bigEventId){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 更新事件点
|
||||
*
|
||||
* @param uid
|
||||
* @param session
|
||||
* @param xy
|
||||
*/
|
||||
public void updateEvent(int uid, int xy, int bigEventId, int smallEventId, int choice) throws Exception {
|
||||
public void updateEvent(ISession session, int xy, int bigEventId, int choice, List<Integer> cells) throws Exception {
|
||||
Set<Integer> cellSet = new HashSet<>(cells);
|
||||
if (cells.size() != cellSet.size()) {
|
||||
LOGGER.info("cells has repeated");
|
||||
return;
|
||||
}
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
Cell cell = mapManager.getMapInfo().get(xy);
|
||||
|
@ -147,14 +182,14 @@ public class MapLogic {
|
|||
return;
|
||||
}
|
||||
int schedule = eventIds.get(bigEventId);
|
||||
if (schedule == -1 || schedule >= smallEventId) {
|
||||
LOGGER.info("event is finished,bigEventId=>{} smallEventId=>{}", bigEventId, smallEventId);
|
||||
if (schedule == -1) {
|
||||
LOGGER.info("event is finished,bigEventId=>{} smallEventId=>{}", bigEventId, -1);
|
||||
return;
|
||||
}
|
||||
SCMapEventsConfig scMapEvent = SCMapEventsConfig.scMapEventMap.get(bigEventId);
|
||||
SCMapEventsItemConfig scMapEventsItemConfig = SCMapEventsItemConfig.scMapEventsItemConfigs.get(bigEventId).get(smallEventId);
|
||||
SCMapEventsItemConfig scMapEventsItemConfig = SCMapEventsItemConfig.scMapEventsItemConfigs.get(bigEventId).get(schedule);
|
||||
if (scMapEventsItemConfig == null) {
|
||||
LOGGER.info("no scMapEventsItemConfig bigEventId=>{} smallEventId=>{}", bigEventId, smallEventId);
|
||||
LOGGER.info("no scMapEventsItemConfig bigEventId=>{} smallEventId=>{}", bigEventId, schedule);
|
||||
return;
|
||||
}
|
||||
String[] contents = scMapEventsItemConfig.getContents().split("\\|");
|
||||
|
@ -163,49 +198,41 @@ public class MapLogic {
|
|||
return;
|
||||
}
|
||||
String[] eventArr = contents[choice].split("#");
|
||||
switch (scMapEvent.getStyle()) {
|
||||
case EventType.monster: {
|
||||
switch (Integer.parseInt(eventArr[0])) {
|
||||
case EventType.fight: {
|
||||
fightStart(session, bigEventId);
|
||||
break;
|
||||
}
|
||||
case EventType.continuity: {
|
||||
switch (Integer.parseInt(eventArr[0])) {
|
||||
case EventType.fight: {
|
||||
case EventType.attribute: {
|
||||
|
||||
break;
|
||||
}
|
||||
case EventType.attribute: {
|
||||
|
||||
break;
|
||||
}
|
||||
case EventType.useItem:
|
||||
case EventType.scout: {
|
||||
|
||||
break;
|
||||
}
|
||||
case EventType.leave: {
|
||||
|
||||
break;
|
||||
}
|
||||
case EventType.dialogue: {
|
||||
|
||||
break;
|
||||
}
|
||||
case EventType.jump: {
|
||||
|
||||
break;
|
||||
}
|
||||
case EventType.eatBuff: {
|
||||
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EventType.useItem:
|
||||
case EventType.scout: {
|
||||
|
||||
break;
|
||||
}
|
||||
case EventType.leave: {
|
||||
|
||||
break;
|
||||
}
|
||||
case EventType.dialogue: {
|
||||
|
||||
break;
|
||||
}
|
||||
case EventType.jump: {
|
||||
|
||||
break;
|
||||
}
|
||||
case EventType.eatBuff: {
|
||||
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (smallEventId + 1 >= contents.length - 1) {
|
||||
if (schedule + 1 >= contents.length - 1) {
|
||||
cell.getEventIds().put(bigEventId, -1);
|
||||
} else {
|
||||
cell.getEventIds().put(bigEventId, schedule + 1);
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class CardRandomManager {
|
||||
|
||||
private Set<Integer> heroIids;
|
||||
|
||||
private Map<Integer,Integer> totalConuntByType;
|
||||
|
||||
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
import com.ljsd.jieling.config.SCHero;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Hero extends MongoBase {
|
||||
|
@ -10,28 +12,44 @@ public class Hero extends MongoBase {
|
|||
|
||||
private int templateId; //模板ID
|
||||
|
||||
private int heroType;
|
||||
|
||||
private int level;//等级
|
||||
|
||||
private int star;
|
||||
|
||||
private int quality;
|
||||
|
||||
private int hp;
|
||||
private float hp;
|
||||
|
||||
private int attack;
|
||||
private float attack;
|
||||
|
||||
private int pDefence;
|
||||
private float pDefence;
|
||||
|
||||
private int mDefence;
|
||||
private float mDefence;
|
||||
|
||||
private int speed;
|
||||
private float speed;
|
||||
|
||||
private List<Skill> skillList;
|
||||
|
||||
private List<Equip> equipList;
|
||||
|
||||
public Hero(){}
|
||||
|
||||
public Hero(String uid,int heroTid){
|
||||
this.id = uid + "" + heroTid;
|
||||
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<>();
|
||||
}
|
||||
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
@ -41,10 +59,6 @@ public class Hero extends MongoBase {
|
|||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public void setHeroType(int heroType) throws Exception {
|
||||
updateString("heroType",heroType);
|
||||
this.heroType = heroType;
|
||||
}
|
||||
|
||||
public void setLevel(int level) throws Exception {
|
||||
updateString("level",level);
|
||||
|
@ -56,32 +70,27 @@ public class Hero extends MongoBase {
|
|||
this.star = star;
|
||||
}
|
||||
|
||||
public void setQuality(int quality) throws Exception {
|
||||
updateString("quality",quality);
|
||||
this.quality = quality;
|
||||
}
|
||||
|
||||
public void setHp(int hp) throws Exception {
|
||||
public void setHp(float hp) throws Exception {
|
||||
updateString("hp",hp);
|
||||
this.hp = hp;
|
||||
}
|
||||
|
||||
public void setAttack(int attack) throws Exception {
|
||||
public void setAttack(float attack) throws Exception {
|
||||
updateString("attack",attack);
|
||||
this.attack = attack;
|
||||
}
|
||||
|
||||
public void setpDefence(int pDefence) throws Exception {
|
||||
public void setpDefence(float pDefence) throws Exception {
|
||||
updateString("pDefence",pDefence);
|
||||
this.pDefence = pDefence;
|
||||
}
|
||||
|
||||
public void setmDefence(int mDefence) throws Exception {
|
||||
public void setmDefence(float mDefence) throws Exception {
|
||||
updateString("mDefence",mDefence);
|
||||
this.mDefence = mDefence;
|
||||
}
|
||||
|
||||
public void setSpeed(int speed) throws Exception {
|
||||
public void setSpeed(float speed) throws Exception {
|
||||
updateString("speed",speed);
|
||||
this.speed = speed;
|
||||
}
|
||||
|
@ -94,10 +103,6 @@ public class Hero extends MongoBase {
|
|||
return templateId;
|
||||
}
|
||||
|
||||
public int getHeroType() {
|
||||
return heroType;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
@ -106,43 +111,40 @@ public class Hero extends MongoBase {
|
|||
return star;
|
||||
}
|
||||
|
||||
public int getQuality() {
|
||||
return quality;
|
||||
}
|
||||
|
||||
public int getHp() {
|
||||
public float getHp() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
public int getAttack() {
|
||||
public float getAttack() {
|
||||
return attack;
|
||||
}
|
||||
|
||||
public int getpDefence() {
|
||||
public float getpDefence() {
|
||||
return pDefence;
|
||||
}
|
||||
|
||||
public int getmDefence() {
|
||||
public float getmDefence() {
|
||||
return mDefence;
|
||||
}
|
||||
|
||||
public int getSpeed() {
|
||||
public float getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public List<Skill> getSkillList() {
|
||||
return skillList;
|
||||
}
|
||||
|
||||
public void setSkillList(List<Skill> skillList) {
|
||||
this.skillList = skillList;
|
||||
}
|
||||
|
||||
public List<Equip> getEquipList() {
|
||||
return equipList;
|
||||
}
|
||||
|
||||
public void setEquipList(List<Equip> equipList) {
|
||||
this.equipList = equipList;
|
||||
}
|
||||
|
||||
public List<Skill> getSkillList() {
|
||||
return skillList;
|
||||
}
|
||||
|
||||
|
||||
public List<Equip> getEquipList() {
|
||||
return equipList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,4 +35,7 @@ public class HeroManager extends MongoBase {
|
|||
heroMap.remove(heroId);
|
||||
}
|
||||
|
||||
public Map<String, Hero> getHeroMap() {
|
||||
return heroMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TeamPosManager extends MongoBase {
|
||||
|
||||
private Map<Integer, List<String>> teamPosForHero;
|
||||
private Map<Integer,String> teamNames;
|
||||
private Map<Integer,List<Integer>> teamPosForPoken;
|
||||
|
||||
public TeamPosManager(){
|
||||
teamNames = new HashMap<>(3);
|
||||
teamPosForHero = new HashMap<>(3);
|
||||
teamPosForPoken = new HashMap<>(3);
|
||||
}
|
||||
|
||||
public void changeName(int teamId,String teamName) throws Exception {
|
||||
teamNames.put(teamId,teamName);
|
||||
updateString("teamNames",teamNames);
|
||||
}
|
||||
|
||||
public void changeTeamInfo(int teamId,List<String> heroIds,List<Integer> pokenIds) throws Exception {
|
||||
teamPosForHero.put(teamId,heroIds);
|
||||
teamPosForPoken.put(teamId,pokenIds);
|
||||
updateString("teamPosForHero",teamPosForHero);
|
||||
updateString("teamPosForPoken",teamPosForPoken);
|
||||
|
||||
}
|
||||
|
||||
public Map<Integer, List<String>> getTeamPosForHero() {
|
||||
return teamPosForHero;
|
||||
}
|
||||
|
||||
public Map<Integer, String> getTeamNames() {
|
||||
return teamNames;
|
||||
}
|
||||
|
||||
public Map<Integer, List<Integer>> getTeamPosForPoken() {
|
||||
return teamPosForPoken;
|
||||
}
|
||||
}
|
|
@ -15,6 +15,10 @@ public class User extends MongoRoot {
|
|||
|
||||
private MapManager mapManager;
|
||||
|
||||
private TeamPosManager teamPosManager;
|
||||
|
||||
|
||||
|
||||
public User(int uid, PlayerManager playerManager, ItemManager itemManager,
|
||||
HeroManager heroManager, MapManager mapManager){
|
||||
setMyMongoDBPool(_myMongoDBPool);
|
||||
|
@ -23,11 +27,14 @@ public class User extends MongoRoot {
|
|||
this.itemManager = itemManager;
|
||||
this.heroManager = heroManager;
|
||||
this.mapManager = mapManager;
|
||||
this.teamPosManager = new TeamPosManager();
|
||||
|
||||
//綁定关系
|
||||
playerManager.init(this, "playerManager", false);
|
||||
itemManager.init(this, "itemManager", false);
|
||||
heroManager.init(this, "heroManager", false);
|
||||
mapManager.init(this, "mapManager", false);
|
||||
teamPosManager.init(this,"teamPosManager",false);
|
||||
}
|
||||
|
||||
public User(){
|
||||
|
@ -87,4 +94,12 @@ public class User extends MongoRoot {
|
|||
public void setMapManager(MapManager mapManager) {
|
||||
this.mapManager = mapManager;
|
||||
}
|
||||
|
||||
public TeamPosManager getTeamPosManager() {
|
||||
return teamPosManager;
|
||||
}
|
||||
|
||||
public void setTeamPosManager(TeamPosManager teamPosManager) {
|
||||
this.teamPosManager = teamPosManager;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,198 @@
|
|||
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.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.util.CBean2Proto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.apache.commons.lang.math.RandomUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class HeroLogic {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(HeroLogic.class);
|
||||
|
||||
private HeroLogic(){}
|
||||
|
||||
public static class Instance {
|
||||
public final static HeroLogic instance = new HeroLogic();
|
||||
}
|
||||
|
||||
public static HeroLogic getInstance() {
|
||||
return HeroLogic.Instance.instance;
|
||||
}
|
||||
|
||||
|
||||
public void random(ISession session,int type) throws Exception {
|
||||
int uid = session.getUid();
|
||||
SLotterySetting sLotterySetting = SLotterySetting.getsLotterySettingMap().get(type);
|
||||
//检验消耗
|
||||
|
||||
//筛选卡池
|
||||
StringBuilder reward = new StringBuilder();
|
||||
int pooId =0;
|
||||
int perCount = sLotterySetting.getPerCount();
|
||||
boolean isSpecial = false;
|
||||
if(sLotterySetting.getOrderBoxPool()!=null && sLotterySetting.getOrderBoxPool().length>0){
|
||||
pooId = getOrderBoxPoolId(sLotterySetting);
|
||||
isSpecial = true;
|
||||
}
|
||||
for(int i=0;i<perCount;i++){
|
||||
if(!isSpecial){
|
||||
pooId = getPooId(sLotterySetting, pooId);
|
||||
}
|
||||
LOGGER.info("the uid={},the type={},the poolId={}",uid,type,pooId);
|
||||
reward.append(randomHeroByPoolId(pooId)).append("|");
|
||||
}
|
||||
|
||||
//额外获取
|
||||
reward.append( extraReward(sLotterySetting));
|
||||
User user = UserManager.getUser(uid);
|
||||
|
||||
HeroInfoProto.HeroRandResponse heroRandResponse = addItem(user, reward.toString());
|
||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.HERO_RAND_RESPONSE_VALUE, heroRandResponse, true);
|
||||
}
|
||||
|
||||
private int getPooId(SLotterySetting sLotterySetting, int pooId) throws Exception {
|
||||
int[][] diamondBoxContain = sLotterySetting.getDiamondBoxContain();
|
||||
int totalWeight = 0;
|
||||
for(int i=0;i<diamondBoxContain.length;i++){
|
||||
int[] poolWeightInfo = diamondBoxContain[i];
|
||||
totalWeight += poolWeightInfo[1];
|
||||
}
|
||||
int randWeight = RandomUtils.nextInt(totalWeight) + 1;
|
||||
int weight = 0;
|
||||
for(int i=0;i<diamondBoxContain.length;i++){
|
||||
int[] poolWeightInfo = diamondBoxContain[i];
|
||||
weight += poolWeightInfo[1];
|
||||
if(randWeight<weight){
|
||||
pooId = poolWeightInfo[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pooId;
|
||||
}
|
||||
|
||||
public HeroInfoProto.HeroRandResponse addItem(User user, String rewards) throws Exception {
|
||||
HeroInfoProto.HeroRandResponse.Builder builder = HeroInfoProto.HeroRandResponse.newBuilder();
|
||||
List<CommonProto.Hero> heros = new ArrayList<>();
|
||||
List<CommonProto.Item> items = new ArrayList<>();
|
||||
ItemManager itemManager = user.getItemManager();
|
||||
HeroManager heroManager = user.getHeroManager();
|
||||
String[] rewardItems = rewards.split("\\|");
|
||||
for(String heroOrItem : rewardItems){
|
||||
String[] splitReward = heroOrItem.split("#");
|
||||
int itemId = Integer.parseInt(splitReward[0]);
|
||||
int itemNum = Integer.parseInt(splitReward[1]);
|
||||
SItem sItem = SItem.getsItemMap().get(itemId);
|
||||
int itemType = sItem.getItemType();
|
||||
if(itemType == 1){ //hero
|
||||
Hero hero = new Hero(user.getId(), itemId);
|
||||
heroManager.addHero(hero);
|
||||
CommonProto.Hero hero1 = CBean2Proto.getHero(hero);
|
||||
heros.add(hero1);
|
||||
}
|
||||
if( itemType == 2) {
|
||||
Item item = itemManager.getItem(itemId);
|
||||
if (item == null){
|
||||
item = itemManager.newItem(itemId, itemNum);
|
||||
}else{
|
||||
if(sItem.isStacking()){
|
||||
item.setItemNum(item.getItemNum() + itemNum);
|
||||
}
|
||||
}
|
||||
items.add(CBean2Proto.getItem(item));
|
||||
}
|
||||
}
|
||||
builder.addAllHeroList(heros);
|
||||
builder.addAllItemList(items);
|
||||
//todo 为了测试 日后要删掉
|
||||
UserManager.ljsdMongoTemplate.lastUpdate();
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public int getOrderBoxPoolId(SLotterySetting sLotterySetting) throws Exception {
|
||||
int[] orderBoxPool = sLotterySetting.getOrderBoxPool();
|
||||
int orderBoxOpenTime = sLotterySetting.getOrderBoxOpenTime();
|
||||
int orderBoxContinue = sLotterySetting.getOrderBoxContinue();
|
||||
long now = System.currentTimeMillis();
|
||||
ServerConfig serverConfig = GameApplication.serverConfig;
|
||||
int diffHours = (int)((now - serverConfig.getCacheOpenTime())%( (orderBoxContinue + orderBoxContinue) * 1000*60*60));
|
||||
int diffSeaseon = (int)((now - serverConfig.getCacheOpenTime())/( (orderBoxContinue + orderBoxContinue) * 1000*60*60));
|
||||
if(diffHours<=orderBoxOpenTime){
|
||||
return orderBoxPool[diffSeaseon%orderBoxPool.length];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String randomHeroByPoolId(int poolId){
|
||||
|
||||
List<SLotteryRewardConfig> sLotteryRewardConfigListByPoolId = SLotteryRewardConfig.getSLotteryRewardConfigListByPoolId(poolId);
|
||||
int totalCountByPoolId = SLotteryRewardConfig.getTotalCountByPoolId(poolId);
|
||||
int randCount = RandomUtils.nextInt(totalCountByPoolId) + 1;
|
||||
int weight =0;
|
||||
for(SLotteryRewardConfig sLotteryRewardConfig :sLotteryRewardConfigListByPoolId){
|
||||
weight += sLotteryRewardConfig.getWeight();
|
||||
if(weight>randCount){
|
||||
int[] reward = sLotteryRewardConfig.getReward();
|
||||
return reward[0] + "#" + reward[1];
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String extraReward(SLotterySetting sLotterySetting){
|
||||
if(sLotterySetting.getTenTimesMustGetItem()!=null){
|
||||
int[] tenTimesMustGetItem = sLotterySetting.getTenTimesMustGetItem();
|
||||
return tenTimesMustGetItem[0] + "#" + tenTimesMustGetItem[1];
|
||||
// tenTimesMustGetItem
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public void saveTeamPos(int uid,int teamId,List<String> heroIds ,List<Integer> pokenIds) throws Exception {
|
||||
User user = UserManager.getUser(uid);
|
||||
|
||||
user.getTeamPosManager().changeTeamInfo(teamId,heroIds,pokenIds);
|
||||
}
|
||||
|
||||
public boolean checkTeamPos(User user,int teamId,List<String> heroIds){
|
||||
if(heroIds ==null || heroIds.isEmpty()){
|
||||
return false;
|
||||
}
|
||||
Set<String> cacheHeroIds = new HashSet<>();
|
||||
Collection<List<String>> values = user.getTeamPosManager().getTeamPosForHero().values();
|
||||
for(String heroId : heroIds){
|
||||
if(user.getHeroManager().getHero(heroId) == null) {
|
||||
// 卡牌不存在
|
||||
return false;
|
||||
}
|
||||
// 卡牌重复
|
||||
if(cacheHeroIds.contains(heroId)){
|
||||
return false;
|
||||
}
|
||||
// 卡牌已上阵
|
||||
if(values.contains(heroId)){
|
||||
return false;
|
||||
}
|
||||
cacheHeroIds.add(heroId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -217,6 +217,7 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
return;
|
||||
} else {
|
||||
try {
|
||||
LOGGER.info("request uid=>{} commond=>{} msgId=>{}: ", packetNetData.getUserId(), baseHandler.getMessageCode(), packetNetData.getMsgId());
|
||||
baseHandler.execute(session, packetNetData);
|
||||
} catch (Exception e) {
|
||||
//TODO
|
||||
|
|
|
@ -43,11 +43,11 @@ public class CBean2Proto {
|
|||
.setHeroId(hero.getTemplateId())
|
||||
.setLevel(hero.getLevel())
|
||||
.setStar(hero.getStar())
|
||||
.setHp(hero.getHp())
|
||||
.setAttack(hero.getAttack())
|
||||
.setPDefence(hero.getpDefence())
|
||||
.setMDefence(hero.getmDefence())
|
||||
.setSpeed(hero.getSpeed())
|
||||
.setHp((int)hero.getHp())
|
||||
.setAttack((int)hero.getAttack())
|
||||
.setPDefence((int)hero.getpDefence())
|
||||
.setMDefence((int)hero.getmDefence())
|
||||
.setSpeed((int)hero.getSpeed())
|
||||
.addAllSkillList(getHeroSkill(hero.getSkillList()))
|
||||
.addAllEquipIdList(getHeroEquip(hero.getEquipList()))
|
||||
.build();
|
||||
|
|
|
@ -18,7 +18,7 @@ public class NettyClient {
|
|||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(NettyClient.class);
|
||||
|
||||
private static int uid = 10000001;
|
||||
private static int uid = 10000009;
|
||||
private static int msgIndex = 1;
|
||||
private static int token=543242;
|
||||
|
||||
|
@ -43,12 +43,17 @@ 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));
|
||||
|
||||
}
|
||||
|
||||
public static HeroInfoProto.GetHeroListInfoRequest getHero(){
|
||||
return HeroInfoProto.GetHeroListInfoRequest.newBuilder().setNum(1).setStr("111").build();
|
||||
}
|
||||
public static HeroInfoProto.HeroRandRequest getRandomHero(){
|
||||
return HeroInfoProto.HeroRandRequest.newBuilder().setType(11).build();
|
||||
|
||||
}
|
||||
|
||||
private static byte[] makeFinalMessage(MessageLite request, int msgNum) {
|
||||
byte[] messageData = request.toByteArray();
|
||||
|
|
Loading…
Reference in New Issue