From 6c58432270ac5c193ab3f53dd289b72e3e0440bf Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 28 Jun 2022 12:04:02 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=AD=A6=E5=99=A8?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=BA=A0=E6=AD=A3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_equipattrlibrary.json | 1584 ++++++----------- bin/json/game_equipintensify.json | 42 +- comm/imodule.go | 6 +- modules/equipment/api_equip.go | 8 +- modules/equipment/api_getlist.go | 2 +- modules/equipment/api_upgrade.go | 20 +- modules/equipment/configure_comp.go | 39 +- modules/equipment/model_equipment_comp.go | 109 +- modules/equipment/module.go | 32 + modules/equipment/module_test.go | 11 +- modules/items/module.go | 2 +- modules/model_comp.go | 3 + modules/modulebase.go | 56 +- .../structs/game.equipAttrlibraryData.go | 111 +- 14 files changed, 845 insertions(+), 1180 deletions(-) diff --git a/bin/json/game_equipattrlibrary.json b/bin/json/game_equipattrlibrary.json index 25d67c15d..a19a95cdf 100644 --- a/bin/json/game_equipattrlibrary.json +++ b/bin/json/game_equipattrlibrary.json @@ -2,10 +2,8 @@ { "key": 1, "libraryid": 10001, - "attr": [ - "atk", - "20" - ], + "attrkey": "atk", + "attrvar": 20, "probability": 1000, "Addition": [ 800, @@ -18,10 +16,8 @@ { "key": 2, "libraryid": 10002, - "attr": [ - "atk", - "20" - ], + "attrkey": "atk", + "attrvar": 20, "probability": 150, "Addition": [ 800, @@ -34,10 +30,8 @@ { "key": 3, "libraryid": 10002, - "attr": [ - "def", - "20" - ], + "attrkey": "def", + "attrvar": 20, "probability": 150, "Addition": [ 800, @@ -50,10 +44,8 @@ { "key": 4, "libraryid": 10002, - "attr": [ - "hp", - "100" - ], + "attrkey": "hp", + "attrvar": 100, "probability": 400, "Addition": [ 800, @@ -66,10 +58,8 @@ { "key": 5, "libraryid": 10002, - "attr": [ - "atkpro", - "20" - ], + "attrkey": "atkpro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -82,10 +72,8 @@ { "key": 6, "libraryid": 10002, - "attr": [ - "defpro", - "20" - ], + "attrkey": "defpro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -98,10 +86,8 @@ { "key": 7, "libraryid": 10002, - "attr": [ - "hppro", - "20" - ], + "attrkey": "hppro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -114,10 +100,8 @@ { "key": 8, "libraryid": 10003, - "attr": [ - "def", - "20" - ], + "attrkey": "def", + "attrvar": 20, "probability": 1000, "Addition": [ 800, @@ -130,10 +114,8 @@ { "key": 9, "libraryid": 10004, - "attr": [ - "atk", - "20" - ], + "attrkey": "atk", + "attrvar": 20, "probability": 150, "Addition": [ 800, @@ -146,10 +128,8 @@ { "key": 10, "libraryid": 10004, - "attr": [ - "def", - "20" - ], + "attrkey": "def", + "attrvar": 20, "probability": 150, "Addition": [ 800, @@ -162,10 +142,8 @@ { "key": 11, "libraryid": 10004, - "attr": [ - "hp", - "100" - ], + "attrkey": "hp", + "attrvar": 100, "probability": 400, "Addition": [ 800, @@ -178,10 +156,8 @@ { "key": 12, "libraryid": 10004, - "attr": [ - "atkpro", - "20" - ], + "attrkey": "atkpro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -194,10 +170,8 @@ { "key": 13, "libraryid": 10004, - "attr": [ - "defpro", - "20" - ], + "attrkey": "defpro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -210,10 +184,8 @@ { "key": 14, "libraryid": 10004, - "attr": [ - "hppro", - "20" - ], + "attrkey": "hppro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -226,10 +198,8 @@ { "key": 15, "libraryid": 10005, - "attr": [ - "hp", - "100" - ], + "attrkey": "hp", + "attrvar": 100, "probability": 1000, "Addition": [ 800, @@ -242,10 +212,8 @@ { "key": 16, "libraryid": 10006, - "attr": [ - "atk", - "20" - ], + "attrkey": "atk", + "attrvar": 20, "probability": 150, "Addition": [ 800, @@ -258,10 +226,8 @@ { "key": 17, "libraryid": 10006, - "attr": [ - "def", - "20" - ], + "attrkey": "def", + "attrvar": 20, "probability": 150, "Addition": [ 800, @@ -274,10 +240,8 @@ { "key": 18, "libraryid": 10006, - "attr": [ - "hp", - "100" - ], + "attrkey": "hp", + "attrvar": 100, "probability": 400, "Addition": [ 800, @@ -290,10 +254,8 @@ { "key": 19, "libraryid": 10006, - "attr": [ - "atkpro", - "20" - ], + "attrkey": "atkpro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -306,10 +268,8 @@ { "key": 20, "libraryid": 10006, - "attr": [ - "defpro", - "20" - ], + "attrkey": "defpro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -322,10 +282,8 @@ { "key": 21, "libraryid": 10006, - "attr": [ - "hppro", - "20" - ], + "attrkey": "hppro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -338,10 +296,8 @@ { "key": 22, "libraryid": 10011, - "attr": [ - "atk", - "26" - ], + "attrkey": "atk", + "attrvar": 26, "probability": 1000, "Addition": [ 800, @@ -354,10 +310,8 @@ { "key": 23, "libraryid": 10012, - "attr": [ - "atk", - "26" - ], + "attrkey": "atk", + "attrvar": 26, "probability": 150, "Addition": [ 800, @@ -370,10 +324,8 @@ { "key": 24, "libraryid": 10012, - "attr": [ - "def", - "26" - ], + "attrkey": "def", + "attrvar": 26, "probability": 150, "Addition": [ 800, @@ -386,10 +338,8 @@ { "key": 25, "libraryid": 10012, - "attr": [ - "hp", - "130" - ], + "attrkey": "hp", + "attrvar": 130, "probability": 400, "Addition": [ 800, @@ -402,10 +352,8 @@ { "key": 26, "libraryid": 10012, - "attr": [ - "atkpro", - "26" - ], + "attrkey": "atkpro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -418,10 +366,8 @@ { "key": 27, "libraryid": 10012, - "attr": [ - "defpro", - "26" - ], + "attrkey": "defpro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -434,10 +380,8 @@ { "key": 28, "libraryid": 10012, - "attr": [ - "hppro", - "26" - ], + "attrkey": "hppro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -450,10 +394,8 @@ { "key": 29, "libraryid": 10013, - "attr": [ - "def", - "26" - ], + "attrkey": "def", + "attrvar": 26, "probability": 1000, "Addition": [ 800, @@ -466,10 +408,8 @@ { "key": 30, "libraryid": 10014, - "attr": [ - "atk", - "26" - ], + "attrkey": "atk", + "attrvar": 26, "probability": 150, "Addition": [ 800, @@ -482,10 +422,8 @@ { "key": 31, "libraryid": 10014, - "attr": [ - "def", - "26" - ], + "attrkey": "def", + "attrvar": 26, "probability": 150, "Addition": [ 800, @@ -498,10 +436,8 @@ { "key": 32, "libraryid": 10014, - "attr": [ - "hp", - "130" - ], + "attrkey": "hp", + "attrvar": 130, "probability": 400, "Addition": [ 800, @@ -514,10 +450,8 @@ { "key": 33, "libraryid": 10014, - "attr": [ - "atkpro", - "26" - ], + "attrkey": "atkpro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -530,10 +464,8 @@ { "key": 34, "libraryid": 10014, - "attr": [ - "defpro", - "26" - ], + "attrkey": "defpro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -546,10 +478,8 @@ { "key": 35, "libraryid": 10014, - "attr": [ - "hppro", - "26" - ], + "attrkey": "hppro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -562,10 +492,8 @@ { "key": 36, "libraryid": 10015, - "attr": [ - "hp", - "130" - ], + "attrkey": "hp", + "attrvar": 130, "probability": 1000, "Addition": [ 800, @@ -578,10 +506,8 @@ { "key": 37, "libraryid": 10016, - "attr": [ - "atk", - "26" - ], + "attrkey": "atk", + "attrvar": 26, "probability": 150, "Addition": [ 800, @@ -594,10 +520,8 @@ { "key": 38, "libraryid": 10016, - "attr": [ - "def", - "26" - ], + "attrkey": "def", + "attrvar": 26, "probability": 150, "Addition": [ 800, @@ -610,10 +534,8 @@ { "key": 39, "libraryid": 10016, - "attr": [ - "hp", - "130" - ], + "attrkey": "hp", + "attrvar": 130, "probability": 400, "Addition": [ 800, @@ -626,10 +548,8 @@ { "key": 40, "libraryid": 10016, - "attr": [ - "atkpro", - "26" - ], + "attrkey": "atkpro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -642,10 +562,8 @@ { "key": 41, "libraryid": 10016, - "attr": [ - "defpro", - "26" - ], + "attrkey": "defpro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -658,10 +576,8 @@ { "key": 42, "libraryid": 10016, - "attr": [ - "hppro", - "26" - ], + "attrkey": "hppro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -674,10 +590,8 @@ { "key": 43, "libraryid": 10021, - "attr": [ - "atk", - "33" - ], + "attrkey": "atk", + "attrvar": 33, "probability": 1000, "Addition": [ 800, @@ -690,10 +604,8 @@ { "key": 44, "libraryid": 10022, - "attr": [ - "atk", - "33" - ], + "attrkey": "atk", + "attrvar": 33, "probability": 150, "Addition": [ 800, @@ -706,10 +618,8 @@ { "key": 45, "libraryid": 10022, - "attr": [ - "def", - "33" - ], + "attrkey": "def", + "attrvar": 33, "probability": 150, "Addition": [ 800, @@ -722,10 +632,8 @@ { "key": 46, "libraryid": 10022, - "attr": [ - "hp", - "169" - ], + "attrkey": "hp", + "attrvar": 169, "probability": 400, "Addition": [ 800, @@ -738,10 +646,8 @@ { "key": 47, "libraryid": 10022, - "attr": [ - "atkpro", - "33" - ], + "attrkey": "atkpro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -754,10 +660,8 @@ { "key": 48, "libraryid": 10022, - "attr": [ - "defpro", - "33" - ], + "attrkey": "defpro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -770,10 +674,8 @@ { "key": 49, "libraryid": 10022, - "attr": [ - "hppro", - "33" - ], + "attrkey": "hppro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -786,10 +688,8 @@ { "key": 50, "libraryid": 10023, - "attr": [ - "def", - "33" - ], + "attrkey": "def", + "attrvar": 33, "probability": 1000, "Addition": [ 800, @@ -802,10 +702,8 @@ { "key": 51, "libraryid": 10024, - "attr": [ - "atk", - "33" - ], + "attrkey": "atk", + "attrvar": 33, "probability": 150, "Addition": [ 800, @@ -818,10 +716,8 @@ { "key": 52, "libraryid": 10024, - "attr": [ - "def", - "33" - ], + "attrkey": "def", + "attrvar": 33, "probability": 150, "Addition": [ 800, @@ -834,10 +730,8 @@ { "key": 53, "libraryid": 10024, - "attr": [ - "hp", - "169" - ], + "attrkey": "hp", + "attrvar": 169, "probability": 400, "Addition": [ 800, @@ -850,10 +744,8 @@ { "key": 54, "libraryid": 10024, - "attr": [ - "atkpro", - "33" - ], + "attrkey": "atkpro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -866,10 +758,8 @@ { "key": 55, "libraryid": 10024, - "attr": [ - "defpro", - "33" - ], + "attrkey": "defpro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -882,10 +772,8 @@ { "key": 56, "libraryid": 10024, - "attr": [ - "hppro", - "33" - ], + "attrkey": "hppro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -898,10 +786,8 @@ { "key": 57, "libraryid": 10025, - "attr": [ - "hp", - "169" - ], + "attrkey": "hp", + "attrvar": 169, "probability": 1000, "Addition": [ 800, @@ -914,10 +800,8 @@ { "key": 58, "libraryid": 10026, - "attr": [ - "atk", - "33" - ], + "attrkey": "atk", + "attrvar": 33, "probability": 150, "Addition": [ 800, @@ -930,10 +814,8 @@ { "key": 59, "libraryid": 10026, - "attr": [ - "def", - "33" - ], + "attrkey": "def", + "attrvar": 33, "probability": 150, "Addition": [ 800, @@ -946,10 +828,8 @@ { "key": 60, "libraryid": 10026, - "attr": [ - "hp", - "169" - ], + "attrkey": "hp", + "attrvar": 169, "probability": 400, "Addition": [ 800, @@ -962,10 +842,8 @@ { "key": 61, "libraryid": 10026, - "attr": [ - "atkpro", - "33" - ], + "attrkey": "atkpro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -978,10 +856,8 @@ { "key": 62, "libraryid": 10026, - "attr": [ - "defpro", - "33" - ], + "attrkey": "defpro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -994,10 +870,8 @@ { "key": 63, "libraryid": 10026, - "attr": [ - "hppro", - "33" - ], + "attrkey": "hppro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -1010,10 +884,8 @@ { "key": 64, "libraryid": 10031, - "attr": [ - "atk", - "42" - ], + "attrkey": "atk", + "attrvar": 42, "probability": 1000, "Addition": [ 800, @@ -1026,10 +898,8 @@ { "key": 65, "libraryid": 10032, - "attr": [ - "atk", - "42" - ], + "attrkey": "atk", + "attrvar": 42, "probability": 150, "Addition": [ 800, @@ -1042,10 +912,8 @@ { "key": 66, "libraryid": 10032, - "attr": [ - "def", - "42" - ], + "attrkey": "def", + "attrvar": 42, "probability": 150, "Addition": [ 800, @@ -1058,10 +926,8 @@ { "key": 67, "libraryid": 10032, - "attr": [ - "hp", - "219" - ], + "attrkey": "hp", + "attrvar": 219, "probability": 400, "Addition": [ 800, @@ -1074,10 +940,8 @@ { "key": 68, "libraryid": 10032, - "attr": [ - "atkpro", - "42" - ], + "attrkey": "atkpro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -1090,10 +954,8 @@ { "key": 69, "libraryid": 10032, - "attr": [ - "defpro", - "42" - ], + "attrkey": "defpro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -1106,10 +968,8 @@ { "key": 70, "libraryid": 10032, - "attr": [ - "hppro", - "42" - ], + "attrkey": "hppro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -1122,10 +982,8 @@ { "key": 71, "libraryid": 10033, - "attr": [ - "def", - "42" - ], + "attrkey": "def", + "attrvar": 42, "probability": 1000, "Addition": [ 800, @@ -1138,10 +996,8 @@ { "key": 72, "libraryid": 10034, - "attr": [ - "atk", - "42" - ], + "attrkey": "atk", + "attrvar": 42, "probability": 150, "Addition": [ 800, @@ -1154,10 +1010,8 @@ { "key": 73, "libraryid": 10034, - "attr": [ - "def", - "42" - ], + "attrkey": "def", + "attrvar": 42, "probability": 150, "Addition": [ 800, @@ -1170,10 +1024,8 @@ { "key": 74, "libraryid": 10034, - "attr": [ - "hp", - "219" - ], + "attrkey": "hp", + "attrvar": 219, "probability": 400, "Addition": [ 800, @@ -1186,10 +1038,8 @@ { "key": 75, "libraryid": 10034, - "attr": [ - "atkpro", - "42" - ], + "attrkey": "atkpro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -1202,10 +1052,8 @@ { "key": 76, "libraryid": 10034, - "attr": [ - "defpro", - "42" - ], + "attrkey": "defpro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -1218,10 +1066,8 @@ { "key": 77, "libraryid": 10034, - "attr": [ - "hppro", - "42" - ], + "attrkey": "hppro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -1234,10 +1080,8 @@ { "key": 78, "libraryid": 10035, - "attr": [ - "hp", - "219" - ], + "attrkey": "hp", + "attrvar": 219, "probability": 1000, "Addition": [ 800, @@ -1250,10 +1094,8 @@ { "key": 79, "libraryid": 10036, - "attr": [ - "atk", - "42" - ], + "attrkey": "atk", + "attrvar": 42, "probability": 150, "Addition": [ 800, @@ -1266,10 +1108,8 @@ { "key": 80, "libraryid": 10036, - "attr": [ - "def", - "42" - ], + "attrkey": "def", + "attrvar": 42, "probability": 150, "Addition": [ 800, @@ -1282,10 +1122,8 @@ { "key": 81, "libraryid": 10036, - "attr": [ - "hp", - "219" - ], + "attrkey": "hp", + "attrvar": 219, "probability": 400, "Addition": [ 800, @@ -1298,10 +1136,8 @@ { "key": 82, "libraryid": 10036, - "attr": [ - "atkpro", - "42" - ], + "attrkey": "atkpro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -1314,10 +1150,8 @@ { "key": 83, "libraryid": 10036, - "attr": [ - "defpro", - "42" - ], + "attrkey": "defpro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -1330,10 +1164,8 @@ { "key": 84, "libraryid": 10036, - "attr": [ - "hppro", - "42" - ], + "attrkey": "hppro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -1346,10 +1178,8 @@ { "key": 85, "libraryid": 10041, - "attr": [ - "atk", - "54" - ], + "attrkey": "atk", + "attrvar": 54, "probability": 1000, "Addition": [ 800, @@ -1362,10 +1192,8 @@ { "key": 86, "libraryid": 10042, - "attr": [ - "atk", - "54" - ], + "attrkey": "atk", + "attrvar": 54, "probability": 150, "Addition": [ 800, @@ -1378,10 +1206,8 @@ { "key": 87, "libraryid": 10042, - "attr": [ - "def", - "54" - ], + "attrkey": "def", + "attrvar": 54, "probability": 150, "Addition": [ 800, @@ -1394,10 +1220,8 @@ { "key": 88, "libraryid": 10042, - "attr": [ - "hp", - "284" - ], + "attrkey": "hp", + "attrvar": 284, "probability": 400, "Addition": [ 800, @@ -1410,10 +1234,8 @@ { "key": 89, "libraryid": 10042, - "attr": [ - "atkpro", - "54" - ], + "attrkey": "atkpro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -1426,10 +1248,8 @@ { "key": 90, "libraryid": 10042, - "attr": [ - "defpro", - "54" - ], + "attrkey": "defpro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -1442,10 +1262,8 @@ { "key": 91, "libraryid": 10042, - "attr": [ - "hppro", - "54" - ], + "attrkey": "hppro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -1458,10 +1276,8 @@ { "key": 92, "libraryid": 10043, - "attr": [ - "def", - "54" - ], + "attrkey": "def", + "attrvar": 54, "probability": 1000, "Addition": [ 800, @@ -1474,10 +1290,8 @@ { "key": 93, "libraryid": 10044, - "attr": [ - "atk", - "54" - ], + "attrkey": "atk", + "attrvar": 54, "probability": 150, "Addition": [ 800, @@ -1490,10 +1304,8 @@ { "key": 94, "libraryid": 10044, - "attr": [ - "def", - "54" - ], + "attrkey": "def", + "attrvar": 54, "probability": 150, "Addition": [ 800, @@ -1506,10 +1318,8 @@ { "key": 95, "libraryid": 10044, - "attr": [ - "hp", - "284" - ], + "attrkey": "hp", + "attrvar": 284, "probability": 400, "Addition": [ 800, @@ -1522,10 +1332,8 @@ { "key": 96, "libraryid": 10044, - "attr": [ - "atkpro", - "54" - ], + "attrkey": "atkpro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -1538,10 +1346,8 @@ { "key": 97, "libraryid": 10044, - "attr": [ - "defpro", - "54" - ], + "attrkey": "defpro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -1554,10 +1360,8 @@ { "key": 98, "libraryid": 10044, - "attr": [ - "hppro", - "54" - ], + "attrkey": "hppro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -1570,10 +1374,8 @@ { "key": 99, "libraryid": 10045, - "attr": [ - "hp", - "284" - ], + "attrkey": "hp", + "attrvar": 284, "probability": 1000, "Addition": [ 800, @@ -1586,10 +1388,8 @@ { "key": 100, "libraryid": 10046, - "attr": [ - "atk", - "54" - ], + "attrkey": "atk", + "attrvar": 54, "probability": 150, "Addition": [ 800, @@ -1602,10 +1402,8 @@ { "key": 101, "libraryid": 10046, - "attr": [ - "def", - "54" - ], + "attrkey": "def", + "attrvar": 54, "probability": 150, "Addition": [ 800, @@ -1618,10 +1416,8 @@ { "key": 102, "libraryid": 10046, - "attr": [ - "hp", - "284" - ], + "attrkey": "hp", + "attrvar": 284, "probability": 400, "Addition": [ 800, @@ -1634,10 +1430,8 @@ { "key": 103, "libraryid": 10046, - "attr": [ - "atkpro", - "54" - ], + "attrkey": "atkpro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -1650,10 +1444,8 @@ { "key": 104, "libraryid": 10046, - "attr": [ - "defpro", - "54" - ], + "attrkey": "defpro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -1666,10 +1458,8 @@ { "key": 105, "libraryid": 10046, - "attr": [ - "hppro", - "54" - ], + "attrkey": "hppro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -1682,10 +1472,8 @@ { "key": 106, "libraryid": 10051, - "attr": [ - "atk", - "70" - ], + "attrkey": "atk", + "attrvar": 70, "probability": 1000, "Addition": [ 800, @@ -1698,10 +1486,8 @@ { "key": 107, "libraryid": 10052, - "attr": [ - "atk", - "70" - ], + "attrkey": "atk", + "attrvar": 70, "probability": 150, "Addition": [ 800, @@ -1714,10 +1500,8 @@ { "key": 108, "libraryid": 10052, - "attr": [ - "def", - "70" - ], + "attrkey": "def", + "attrvar": 70, "probability": 150, "Addition": [ 800, @@ -1730,10 +1514,8 @@ { "key": 109, "libraryid": 10052, - "attr": [ - "hp", - "369" - ], + "attrkey": "hp", + "attrvar": 369, "probability": 400, "Addition": [ 800, @@ -1746,10 +1528,8 @@ { "key": 110, "libraryid": 10052, - "attr": [ - "atkpro", - "70" - ], + "attrkey": "atkpro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -1762,10 +1542,8 @@ { "key": 111, "libraryid": 10052, - "attr": [ - "defpro", - "70" - ], + "attrkey": "defpro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -1778,10 +1556,8 @@ { "key": 112, "libraryid": 10052, - "attr": [ - "hppro", - "70" - ], + "attrkey": "hppro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -1794,10 +1570,8 @@ { "key": 113, "libraryid": 10053, - "attr": [ - "def", - "70" - ], + "attrkey": "def", + "attrvar": 70, "probability": 1000, "Addition": [ 800, @@ -1810,10 +1584,8 @@ { "key": 114, "libraryid": 10054, - "attr": [ - "atk", - "70" - ], + "attrkey": "atk", + "attrvar": 70, "probability": 150, "Addition": [ 800, @@ -1826,10 +1598,8 @@ { "key": 115, "libraryid": 10054, - "attr": [ - "def", - "70" - ], + "attrkey": "def", + "attrvar": 70, "probability": 150, "Addition": [ 800, @@ -1842,10 +1612,8 @@ { "key": 116, "libraryid": 10054, - "attr": [ - "hp", - "369" - ], + "attrkey": "hp", + "attrvar": 369, "probability": 400, "Addition": [ 800, @@ -1858,10 +1626,8 @@ { "key": 117, "libraryid": 10054, - "attr": [ - "atkpro", - "70" - ], + "attrkey": "atkpro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -1874,10 +1640,8 @@ { "key": 118, "libraryid": 10054, - "attr": [ - "defpro", - "70" - ], + "attrkey": "defpro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -1890,10 +1654,8 @@ { "key": 119, "libraryid": 10054, - "attr": [ - "hppro", - "70" - ], + "attrkey": "hppro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -1906,10 +1668,8 @@ { "key": 120, "libraryid": 10055, - "attr": [ - "hp", - "369" - ], + "attrkey": "hp", + "attrvar": 369, "probability": 1000, "Addition": [ 800, @@ -1922,10 +1682,8 @@ { "key": 121, "libraryid": 10056, - "attr": [ - "atk", - "70" - ], + "attrkey": "atk", + "attrvar": 70, "probability": 150, "Addition": [ 800, @@ -1938,10 +1696,8 @@ { "key": 122, "libraryid": 10056, - "attr": [ - "def", - "70" - ], + "attrkey": "def", + "attrvar": 70, "probability": 150, "Addition": [ 800, @@ -1954,10 +1710,8 @@ { "key": 123, "libraryid": 10056, - "attr": [ - "hp", - "369" - ], + "attrkey": "hp", + "attrvar": 369, "probability": 400, "Addition": [ 800, @@ -1970,10 +1724,8 @@ { "key": 124, "libraryid": 10056, - "attr": [ - "atkpro", - "70" - ], + "attrkey": "atkpro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -1986,10 +1738,8 @@ { "key": 125, "libraryid": 10056, - "attr": [ - "defpro", - "70" - ], + "attrkey": "defpro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -2002,10 +1752,8 @@ { "key": 126, "libraryid": 10056, - "attr": [ - "hppro", - "70" - ], + "attrkey": "hppro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -2018,10 +1766,8 @@ { "key": 127, "libraryid": 1001, - "attr": [ - "atk", - "70" - ], + "attrkey": "atk", + "attrvar": 70, "probability": 150, "Addition": [ 800, @@ -2034,10 +1780,8 @@ { "key": 128, "libraryid": 1001, - "attr": [ - "def", - "70" - ], + "attrkey": "def", + "attrvar": 70, "probability": 150, "Addition": [ 800, @@ -2050,10 +1794,8 @@ { "key": 129, "libraryid": 1001, - "attr": [ - "hp", - "369" - ], + "attrkey": "hp", + "attrvar": 369, "probability": 400, "Addition": [ 800, @@ -2066,10 +1808,8 @@ { "key": 130, "libraryid": 1001, - "attr": [ - "atkpro", - "70" - ], + "attrkey": "atkpro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -2082,10 +1822,8 @@ { "key": 131, "libraryid": 1001, - "attr": [ - "defpro", - "70" - ], + "attrkey": "defpro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -2098,10 +1836,8 @@ { "key": 132, "libraryid": 1001, - "attr": [ - "hppro", - "70" - ], + "attrkey": "hppro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -2114,10 +1850,8 @@ { "key": 133, "libraryid": 11001, - "attr": [ - "atk", - "20" - ], + "attrkey": "atk", + "attrvar": 20, "probability": 1000, "Addition": [ 800, @@ -2130,10 +1864,8 @@ { "key": 134, "libraryid": 11002, - "attr": [ - "atk", - "20" - ], + "attrkey": "atk", + "attrvar": 20, "probability": 150, "Addition": [ 800, @@ -2146,10 +1878,8 @@ { "key": 135, "libraryid": 11002, - "attr": [ - "def", - "20" - ], + "attrkey": "def", + "attrvar": 20, "probability": 150, "Addition": [ 800, @@ -2162,10 +1892,8 @@ { "key": 136, "libraryid": 11002, - "attr": [ - "hp", - "100" - ], + "attrkey": "hp", + "attrvar": 100, "probability": 400, "Addition": [ 800, @@ -2178,10 +1906,8 @@ { "key": 137, "libraryid": 11002, - "attr": [ - "atkpro", - "20" - ], + "attrkey": "atkpro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -2194,10 +1920,8 @@ { "key": 138, "libraryid": 11002, - "attr": [ - "defpro", - "20" - ], + "attrkey": "defpro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -2210,10 +1934,8 @@ { "key": 139, "libraryid": 11002, - "attr": [ - "hppro", - "20" - ], + "attrkey": "hppro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -2226,10 +1948,8 @@ { "key": 140, "libraryid": 11003, - "attr": [ - "def", - "20" - ], + "attrkey": "def", + "attrvar": 20, "probability": 1000, "Addition": [ 800, @@ -2242,10 +1962,8 @@ { "key": 141, "libraryid": 11004, - "attr": [ - "atk", - "20" - ], + "attrkey": "atk", + "attrvar": 20, "probability": 150, "Addition": [ 800, @@ -2258,10 +1976,8 @@ { "key": 142, "libraryid": 11004, - "attr": [ - "def", - "20" - ], + "attrkey": "def", + "attrvar": 20, "probability": 150, "Addition": [ 800, @@ -2274,10 +1990,8 @@ { "key": 143, "libraryid": 11004, - "attr": [ - "hp", - "100" - ], + "attrkey": "hp", + "attrvar": 100, "probability": 400, "Addition": [ 800, @@ -2290,10 +2004,8 @@ { "key": 144, "libraryid": 11004, - "attr": [ - "atkpro", - "20" - ], + "attrkey": "atkpro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -2306,10 +2018,8 @@ { "key": 145, "libraryid": 11004, - "attr": [ - "defpro", - "20" - ], + "attrkey": "defpro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -2322,10 +2032,8 @@ { "key": 146, "libraryid": 11004, - "attr": [ - "hppro", - "20" - ], + "attrkey": "hppro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -2338,10 +2046,8 @@ { "key": 147, "libraryid": 11005, - "attr": [ - "hp", - "100" - ], + "attrkey": "hp", + "attrvar": 100, "probability": 1000, "Addition": [ 800, @@ -2354,10 +2060,8 @@ { "key": 148, "libraryid": 11006, - "attr": [ - "atk", - "20" - ], + "attrkey": "atk", + "attrvar": 20, "probability": 150, "Addition": [ 800, @@ -2370,10 +2074,8 @@ { "key": 149, "libraryid": 11006, - "attr": [ - "def", - "20" - ], + "attrkey": "def", + "attrvar": 20, "probability": 150, "Addition": [ 800, @@ -2386,10 +2088,8 @@ { "key": 150, "libraryid": 11006, - "attr": [ - "hp", - "100" - ], + "attrkey": "hp", + "attrvar": 100, "probability": 400, "Addition": [ 800, @@ -2402,10 +2102,8 @@ { "key": 151, "libraryid": 11006, - "attr": [ - "atkpro", - "20" - ], + "attrkey": "atkpro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -2418,10 +2116,8 @@ { "key": 152, "libraryid": 11006, - "attr": [ - "defpro", - "20" - ], + "attrkey": "defpro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -2434,10 +2130,8 @@ { "key": 153, "libraryid": 11006, - "attr": [ - "hppro", - "20" - ], + "attrkey": "hppro", + "attrvar": 20, "probability": 100, "Addition": [ 800, @@ -2450,10 +2144,8 @@ { "key": 154, "libraryid": 11011, - "attr": [ - "atk", - "26" - ], + "attrkey": "atk", + "attrvar": 26, "probability": 1000, "Addition": [ 800, @@ -2466,10 +2158,8 @@ { "key": 155, "libraryid": 11012, - "attr": [ - "atk", - "26" - ], + "attrkey": "atk", + "attrvar": 26, "probability": 150, "Addition": [ 800, @@ -2482,10 +2172,8 @@ { "key": 156, "libraryid": 11012, - "attr": [ - "def", - "26" - ], + "attrkey": "def", + "attrvar": 26, "probability": 150, "Addition": [ 800, @@ -2498,10 +2186,8 @@ { "key": 157, "libraryid": 11012, - "attr": [ - "hp", - "130" - ], + "attrkey": "hp", + "attrvar": 130, "probability": 400, "Addition": [ 800, @@ -2514,10 +2200,8 @@ { "key": 158, "libraryid": 11012, - "attr": [ - "atkpro", - "26" - ], + "attrkey": "atkpro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -2530,10 +2214,8 @@ { "key": 159, "libraryid": 11012, - "attr": [ - "defpro", - "26" - ], + "attrkey": "defpro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -2546,10 +2228,8 @@ { "key": 160, "libraryid": 11012, - "attr": [ - "hppro", - "26" - ], + "attrkey": "hppro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -2562,10 +2242,8 @@ { "key": 161, "libraryid": 11013, - "attr": [ - "def", - "26" - ], + "attrkey": "def", + "attrvar": 26, "probability": 1000, "Addition": [ 800, @@ -2578,10 +2256,8 @@ { "key": 162, "libraryid": 11014, - "attr": [ - "atk", - "26" - ], + "attrkey": "atk", + "attrvar": 26, "probability": 150, "Addition": [ 800, @@ -2594,10 +2270,8 @@ { "key": 163, "libraryid": 11014, - "attr": [ - "def", - "26" - ], + "attrkey": "def", + "attrvar": 26, "probability": 150, "Addition": [ 800, @@ -2610,10 +2284,8 @@ { "key": 164, "libraryid": 11014, - "attr": [ - "hp", - "130" - ], + "attrkey": "hp", + "attrvar": 130, "probability": 400, "Addition": [ 800, @@ -2626,10 +2298,8 @@ { "key": 165, "libraryid": 11014, - "attr": [ - "atkpro", - "26" - ], + "attrkey": "atkpro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -2642,10 +2312,8 @@ { "key": 166, "libraryid": 11014, - "attr": [ - "defpro", - "26" - ], + "attrkey": "defpro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -2658,10 +2326,8 @@ { "key": 167, "libraryid": 11014, - "attr": [ - "hppro", - "26" - ], + "attrkey": "hppro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -2674,10 +2340,8 @@ { "key": 168, "libraryid": 11015, - "attr": [ - "hp", - "130" - ], + "attrkey": "hp", + "attrvar": 130, "probability": 1000, "Addition": [ 800, @@ -2690,10 +2354,8 @@ { "key": 169, "libraryid": 11016, - "attr": [ - "atk", - "26" - ], + "attrkey": "atk", + "attrvar": 26, "probability": 150, "Addition": [ 800, @@ -2706,10 +2368,8 @@ { "key": 170, "libraryid": 11016, - "attr": [ - "def", - "26" - ], + "attrkey": "def", + "attrvar": 26, "probability": 150, "Addition": [ 800, @@ -2722,10 +2382,8 @@ { "key": 171, "libraryid": 11016, - "attr": [ - "hp", - "130" - ], + "attrkey": "hp", + "attrvar": 130, "probability": 400, "Addition": [ 800, @@ -2738,10 +2396,8 @@ { "key": 172, "libraryid": 11016, - "attr": [ - "atkpro", - "26" - ], + "attrkey": "atkpro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -2754,10 +2410,8 @@ { "key": 173, "libraryid": 11016, - "attr": [ - "defpro", - "26" - ], + "attrkey": "defpro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -2770,10 +2424,8 @@ { "key": 174, "libraryid": 11016, - "attr": [ - "hppro", - "26" - ], + "attrkey": "hppro", + "attrvar": 26, "probability": 100, "Addition": [ 800, @@ -2786,10 +2438,8 @@ { "key": 175, "libraryid": 11021, - "attr": [ - "atk", - "33" - ], + "attrkey": "atk", + "attrvar": 33, "probability": 1000, "Addition": [ 800, @@ -2802,10 +2452,8 @@ { "key": 176, "libraryid": 11022, - "attr": [ - "atk", - "33" - ], + "attrkey": "atk", + "attrvar": 33, "probability": 150, "Addition": [ 800, @@ -2818,10 +2466,8 @@ { "key": 177, "libraryid": 11022, - "attr": [ - "def", - "33" - ], + "attrkey": "def", + "attrvar": 33, "probability": 150, "Addition": [ 800, @@ -2834,10 +2480,8 @@ { "key": 178, "libraryid": 11022, - "attr": [ - "hp", - "169" - ], + "attrkey": "hp", + "attrvar": 169, "probability": 400, "Addition": [ 800, @@ -2850,10 +2494,8 @@ { "key": 179, "libraryid": 11022, - "attr": [ - "atkpro", - "33" - ], + "attrkey": "atkpro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -2866,10 +2508,8 @@ { "key": 180, "libraryid": 11022, - "attr": [ - "defpro", - "33" - ], + "attrkey": "defpro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -2882,10 +2522,8 @@ { "key": 181, "libraryid": 11022, - "attr": [ - "hppro", - "33" - ], + "attrkey": "hppro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -2898,10 +2536,8 @@ { "key": 182, "libraryid": 11023, - "attr": [ - "def", - "33" - ], + "attrkey": "def", + "attrvar": 33, "probability": 1000, "Addition": [ 800, @@ -2914,10 +2550,8 @@ { "key": 183, "libraryid": 11024, - "attr": [ - "atk", - "33" - ], + "attrkey": "atk", + "attrvar": 33, "probability": 150, "Addition": [ 800, @@ -2930,10 +2564,8 @@ { "key": 184, "libraryid": 11024, - "attr": [ - "def", - "33" - ], + "attrkey": "def", + "attrvar": 33, "probability": 150, "Addition": [ 800, @@ -2946,10 +2578,8 @@ { "key": 185, "libraryid": 11024, - "attr": [ - "hp", - "169" - ], + "attrkey": "hp", + "attrvar": 169, "probability": 400, "Addition": [ 800, @@ -2962,10 +2592,8 @@ { "key": 186, "libraryid": 11024, - "attr": [ - "atkpro", - "33" - ], + "attrkey": "atkpro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -2978,10 +2606,8 @@ { "key": 187, "libraryid": 11024, - "attr": [ - "defpro", - "33" - ], + "attrkey": "defpro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -2994,10 +2620,8 @@ { "key": 188, "libraryid": 11024, - "attr": [ - "hppro", - "33" - ], + "attrkey": "hppro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -3010,10 +2634,8 @@ { "key": 189, "libraryid": 11025, - "attr": [ - "hp", - "169" - ], + "attrkey": "hp", + "attrvar": 169, "probability": 1000, "Addition": [ 800, @@ -3026,10 +2648,8 @@ { "key": 190, "libraryid": 11026, - "attr": [ - "atk", - "33" - ], + "attrkey": "atk", + "attrvar": 33, "probability": 150, "Addition": [ 800, @@ -3042,10 +2662,8 @@ { "key": 191, "libraryid": 11026, - "attr": [ - "def", - "33" - ], + "attrkey": "def", + "attrvar": 33, "probability": 150, "Addition": [ 800, @@ -3058,10 +2676,8 @@ { "key": 192, "libraryid": 11026, - "attr": [ - "hp", - "169" - ], + "attrkey": "hp", + "attrvar": 169, "probability": 400, "Addition": [ 800, @@ -3074,10 +2690,8 @@ { "key": 193, "libraryid": 11026, - "attr": [ - "atkpro", - "33" - ], + "attrkey": "atkpro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -3090,10 +2704,8 @@ { "key": 194, "libraryid": 11026, - "attr": [ - "defpro", - "33" - ], + "attrkey": "defpro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -3106,10 +2718,8 @@ { "key": 195, "libraryid": 11026, - "attr": [ - "hppro", - "33" - ], + "attrkey": "hppro", + "attrvar": 33, "probability": 100, "Addition": [ 800, @@ -3122,10 +2732,8 @@ { "key": 196, "libraryid": 11031, - "attr": [ - "atk", - "42" - ], + "attrkey": "atk", + "attrvar": 42, "probability": 1000, "Addition": [ 800, @@ -3138,10 +2746,8 @@ { "key": 197, "libraryid": 11032, - "attr": [ - "atk", - "42" - ], + "attrkey": "atk", + "attrvar": 42, "probability": 150, "Addition": [ 800, @@ -3154,10 +2760,8 @@ { "key": 198, "libraryid": 11032, - "attr": [ - "def", - "42" - ], + "attrkey": "def", + "attrvar": 42, "probability": 150, "Addition": [ 800, @@ -3170,10 +2774,8 @@ { "key": 199, "libraryid": 11032, - "attr": [ - "hp", - "219" - ], + "attrkey": "hp", + "attrvar": 219, "probability": 400, "Addition": [ 800, @@ -3186,10 +2788,8 @@ { "key": 200, "libraryid": 11032, - "attr": [ - "atkpro", - "42" - ], + "attrkey": "atkpro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -3202,10 +2802,8 @@ { "key": 201, "libraryid": 11032, - "attr": [ - "defpro", - "42" - ], + "attrkey": "defpro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -3218,10 +2816,8 @@ { "key": 202, "libraryid": 11032, - "attr": [ - "hppro", - "42" - ], + "attrkey": "hppro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -3234,10 +2830,8 @@ { "key": 203, "libraryid": 11033, - "attr": [ - "def", - "42" - ], + "attrkey": "def", + "attrvar": 42, "probability": 1000, "Addition": [ 800, @@ -3250,10 +2844,8 @@ { "key": 204, "libraryid": 11034, - "attr": [ - "atk", - "42" - ], + "attrkey": "atk", + "attrvar": 42, "probability": 150, "Addition": [ 800, @@ -3266,10 +2858,8 @@ { "key": 205, "libraryid": 11034, - "attr": [ - "def", - "42" - ], + "attrkey": "def", + "attrvar": 42, "probability": 150, "Addition": [ 800, @@ -3282,10 +2872,8 @@ { "key": 206, "libraryid": 11034, - "attr": [ - "hp", - "219" - ], + "attrkey": "hp", + "attrvar": 219, "probability": 400, "Addition": [ 800, @@ -3298,10 +2886,8 @@ { "key": 207, "libraryid": 11034, - "attr": [ - "atkpro", - "42" - ], + "attrkey": "atkpro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -3314,10 +2900,8 @@ { "key": 208, "libraryid": 11034, - "attr": [ - "defpro", - "42" - ], + "attrkey": "defpro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -3330,10 +2914,8 @@ { "key": 209, "libraryid": 11034, - "attr": [ - "hppro", - "42" - ], + "attrkey": "hppro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -3346,10 +2928,8 @@ { "key": 210, "libraryid": 11035, - "attr": [ - "hp", - "219" - ], + "attrkey": "hp", + "attrvar": 219, "probability": 1000, "Addition": [ 800, @@ -3362,10 +2942,8 @@ { "key": 211, "libraryid": 11036, - "attr": [ - "atk", - "42" - ], + "attrkey": "atk", + "attrvar": 42, "probability": 150, "Addition": [ 800, @@ -3378,10 +2956,8 @@ { "key": 212, "libraryid": 11036, - "attr": [ - "def", - "42" - ], + "attrkey": "def", + "attrvar": 42, "probability": 150, "Addition": [ 800, @@ -3394,10 +2970,8 @@ { "key": 213, "libraryid": 11036, - "attr": [ - "hp", - "219" - ], + "attrkey": "hp", + "attrvar": 219, "probability": 400, "Addition": [ 800, @@ -3410,10 +2984,8 @@ { "key": 214, "libraryid": 11036, - "attr": [ - "atkpro", - "42" - ], + "attrkey": "atkpro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -3426,10 +2998,8 @@ { "key": 215, "libraryid": 11036, - "attr": [ - "defpro", - "42" - ], + "attrkey": "defpro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -3442,10 +3012,8 @@ { "key": 216, "libraryid": 11036, - "attr": [ - "hppro", - "42" - ], + "attrkey": "hppro", + "attrvar": 42, "probability": 100, "Addition": [ 800, @@ -3458,10 +3026,8 @@ { "key": 217, "libraryid": 11041, - "attr": [ - "atk", - "54" - ], + "attrkey": "atk", + "attrvar": 54, "probability": 1000, "Addition": [ 800, @@ -3474,10 +3040,8 @@ { "key": 218, "libraryid": 11042, - "attr": [ - "atk", - "54" - ], + "attrkey": "atk", + "attrvar": 54, "probability": 150, "Addition": [ 800, @@ -3490,10 +3054,8 @@ { "key": 219, "libraryid": 11042, - "attr": [ - "def", - "54" - ], + "attrkey": "def", + "attrvar": 54, "probability": 150, "Addition": [ 800, @@ -3506,10 +3068,8 @@ { "key": 220, "libraryid": 11042, - "attr": [ - "hp", - "284" - ], + "attrkey": "hp", + "attrvar": 284, "probability": 400, "Addition": [ 800, @@ -3522,10 +3082,8 @@ { "key": 221, "libraryid": 11042, - "attr": [ - "atkpro", - "54" - ], + "attrkey": "atkpro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -3538,10 +3096,8 @@ { "key": 222, "libraryid": 11042, - "attr": [ - "defpro", - "54" - ], + "attrkey": "defpro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -3554,10 +3110,8 @@ { "key": 223, "libraryid": 11042, - "attr": [ - "hppro", - "54" - ], + "attrkey": "hppro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -3570,10 +3124,8 @@ { "key": 224, "libraryid": 11043, - "attr": [ - "def", - "54" - ], + "attrkey": "def", + "attrvar": 54, "probability": 1000, "Addition": [ 800, @@ -3586,10 +3138,8 @@ { "key": 225, "libraryid": 11044, - "attr": [ - "atk", - "54" - ], + "attrkey": "atk", + "attrvar": 54, "probability": 150, "Addition": [ 800, @@ -3602,10 +3152,8 @@ { "key": 226, "libraryid": 11044, - "attr": [ - "def", - "54" - ], + "attrkey": "def", + "attrvar": 54, "probability": 150, "Addition": [ 800, @@ -3618,10 +3166,8 @@ { "key": 227, "libraryid": 11044, - "attr": [ - "hp", - "284" - ], + "attrkey": "hp", + "attrvar": 284, "probability": 400, "Addition": [ 800, @@ -3634,10 +3180,8 @@ { "key": 228, "libraryid": 11044, - "attr": [ - "atkpro", - "54" - ], + "attrkey": "atkpro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -3650,10 +3194,8 @@ { "key": 229, "libraryid": 11044, - "attr": [ - "defpro", - "54" - ], + "attrkey": "defpro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -3666,10 +3208,8 @@ { "key": 230, "libraryid": 11044, - "attr": [ - "hppro", - "54" - ], + "attrkey": "hppro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -3682,10 +3222,8 @@ { "key": 231, "libraryid": 11045, - "attr": [ - "hp", - "284" - ], + "attrkey": "hp", + "attrvar": 284, "probability": 1000, "Addition": [ 800, @@ -3698,10 +3236,8 @@ { "key": 232, "libraryid": 11046, - "attr": [ - "atk", - "54" - ], + "attrkey": "atk", + "attrvar": 54, "probability": 150, "Addition": [ 800, @@ -3714,10 +3250,8 @@ { "key": 233, "libraryid": 11046, - "attr": [ - "def", - "54" - ], + "attrkey": "def", + "attrvar": 54, "probability": 150, "Addition": [ 800, @@ -3730,10 +3264,8 @@ { "key": 234, "libraryid": 11046, - "attr": [ - "hp", - "284" - ], + "attrkey": "hp", + "attrvar": 284, "probability": 400, "Addition": [ 800, @@ -3746,10 +3278,8 @@ { "key": 235, "libraryid": 11046, - "attr": [ - "atkpro", - "54" - ], + "attrkey": "atkpro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -3762,10 +3292,8 @@ { "key": 236, "libraryid": 11046, - "attr": [ - "defpro", - "54" - ], + "attrkey": "defpro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -3778,10 +3306,8 @@ { "key": 237, "libraryid": 11046, - "attr": [ - "hppro", - "54" - ], + "attrkey": "hppro", + "attrvar": 54, "probability": 100, "Addition": [ 800, @@ -3794,10 +3320,8 @@ { "key": 238, "libraryid": 11051, - "attr": [ - "atk", - "70" - ], + "attrkey": "atk", + "attrvar": 70, "probability": 1000, "Addition": [ 800, @@ -3810,10 +3334,8 @@ { "key": 239, "libraryid": 11052, - "attr": [ - "atk", - "70" - ], + "attrkey": "atk", + "attrvar": 70, "probability": 150, "Addition": [ 800, @@ -3826,10 +3348,8 @@ { "key": 240, "libraryid": 11052, - "attr": [ - "def", - "70" - ], + "attrkey": "def", + "attrvar": 70, "probability": 150, "Addition": [ 800, @@ -3842,10 +3362,8 @@ { "key": 241, "libraryid": 11052, - "attr": [ - "hp", - "369" - ], + "attrkey": "hp", + "attrvar": 369, "probability": 400, "Addition": [ 800, @@ -3858,10 +3376,8 @@ { "key": 242, "libraryid": 11052, - "attr": [ - "atkpro", - "70" - ], + "attrkey": "atkpro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -3874,10 +3390,8 @@ { "key": 243, "libraryid": 11052, - "attr": [ - "defpro", - "70" - ], + "attrkey": "defpro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -3890,10 +3404,8 @@ { "key": 244, "libraryid": 11052, - "attr": [ - "hppro", - "70" - ], + "attrkey": "hppro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -3906,10 +3418,8 @@ { "key": 245, "libraryid": 11053, - "attr": [ - "def", - "70" - ], + "attrkey": "def", + "attrvar": 70, "probability": 1000, "Addition": [ 800, @@ -3922,10 +3432,8 @@ { "key": 246, "libraryid": 11054, - "attr": [ - "atk", - "70" - ], + "attrkey": "atk", + "attrvar": 70, "probability": 150, "Addition": [ 800, @@ -3938,10 +3446,8 @@ { "key": 247, "libraryid": 11054, - "attr": [ - "def", - "70" - ], + "attrkey": "def", + "attrvar": 70, "probability": 150, "Addition": [ 800, @@ -3954,10 +3460,8 @@ { "key": 248, "libraryid": 11054, - "attr": [ - "hp", - "369" - ], + "attrkey": "hp", + "attrvar": 369, "probability": 400, "Addition": [ 800, @@ -3970,10 +3474,8 @@ { "key": 249, "libraryid": 11054, - "attr": [ - "atkpro", - "70" - ], + "attrkey": "atkpro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -3986,10 +3488,8 @@ { "key": 250, "libraryid": 11054, - "attr": [ - "defpro", - "70" - ], + "attrkey": "defpro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -4002,10 +3502,8 @@ { "key": 251, "libraryid": 11054, - "attr": [ - "hppro", - "70" - ], + "attrkey": "hppro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -4018,10 +3516,8 @@ { "key": 252, "libraryid": 11055, - "attr": [ - "hp", - "369" - ], + "attrkey": "hp", + "attrvar": 369, "probability": 1000, "Addition": [ 800, @@ -4034,10 +3530,8 @@ { "key": 253, "libraryid": 11056, - "attr": [ - "atk", - "70" - ], + "attrkey": "atk", + "attrvar": 70, "probability": 150, "Addition": [ 800, @@ -4050,10 +3544,8 @@ { "key": 254, "libraryid": 11056, - "attr": [ - "def", - "70" - ], + "attrkey": "def", + "attrvar": 70, "probability": 150, "Addition": [ 800, @@ -4066,10 +3558,8 @@ { "key": 255, "libraryid": 11056, - "attr": [ - "hp", - "369" - ], + "attrkey": "hp", + "attrvar": 369, "probability": 400, "Addition": [ 800, @@ -4082,10 +3572,8 @@ { "key": 256, "libraryid": 11056, - "attr": [ - "atkpro", - "70" - ], + "attrkey": "atkpro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -4098,10 +3586,8 @@ { "key": 257, "libraryid": 11056, - "attr": [ - "defpro", - "70" - ], + "attrkey": "defpro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -4114,10 +3600,8 @@ { "key": 258, "libraryid": 11056, - "attr": [ - "hppro", - "70" - ], + "attrkey": "hppro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -4130,10 +3614,8 @@ { "key": 259, "libraryid": 1101, - "attr": [ - "atk", - "70" - ], + "attrkey": "atk", + "attrvar": 70, "probability": 150, "Addition": [ 800, @@ -4146,10 +3628,8 @@ { "key": 260, "libraryid": 1101, - "attr": [ - "def", - "70" - ], + "attrkey": "def", + "attrvar": 70, "probability": 150, "Addition": [ 800, @@ -4162,10 +3642,8 @@ { "key": 261, "libraryid": 1101, - "attr": [ - "hp", - "369" - ], + "attrkey": "hp", + "attrvar": 369, "probability": 400, "Addition": [ 800, @@ -4178,10 +3656,8 @@ { "key": 262, "libraryid": 1101, - "attr": [ - "atkpro", - "70" - ], + "attrkey": "atkpro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -4194,10 +3670,8 @@ { "key": 263, "libraryid": 1101, - "attr": [ - "defpro", - "70" - ], + "attrkey": "defpro", + "attrvar": 70, "probability": 100, "Addition": [ 800, @@ -4210,10 +3684,8 @@ { "key": 264, "libraryid": 1101, - "attr": [ - "hppro", - "70" - ], + "attrkey": "hppro", + "attrvar": 70, "probability": 100, "Addition": [ 800, diff --git a/bin/json/game_equipintensify.json b/bin/json/game_equipintensify.json index 162fcf358..9e4d37563 100644 --- a/bin/json/game_equipintensify.json +++ b/bin/json/game_equipintensify.json @@ -495,7 +495,7 @@ "level": 15, "need": [], "bonus": 4500, - "activation": false, + "activation": true, "probability": 250, "num": 16 }, @@ -559,7 +559,7 @@ } ], "bonus": 900, - "activation": false, + "activation": true, "probability": 850, "num": 4 }, @@ -607,7 +607,7 @@ } ], "bonus": 1800, - "activation": false, + "activation": true, "probability": 700, "num": 7 }, @@ -655,7 +655,7 @@ } ], "bonus": 2700, - "activation": false, + "activation": true, "probability": 550, "num": 10 }, @@ -703,7 +703,7 @@ } ], "bonus": 3600, - "activation": false, + "activation": true, "probability": 400, "num": 13 }, @@ -745,7 +745,7 @@ "level": 15, "need": [], "bonus": 4500, - "activation": false, + "activation": true, "probability": 250, "num": 16 }, @@ -809,7 +809,7 @@ } ], "bonus": 900, - "activation": false, + "activation": true, "probability": 850, "num": 4 }, @@ -857,7 +857,7 @@ } ], "bonus": 1800, - "activation": false, + "activation": true, "probability": 700, "num": 7 }, @@ -905,7 +905,7 @@ } ], "bonus": 2700, - "activation": false, + "activation": true, "probability": 550, "num": 10 }, @@ -953,7 +953,7 @@ } ], "bonus": 3600, - "activation": false, + "activation": true, "probability": 400, "num": 13 }, @@ -995,7 +995,7 @@ "level": 15, "need": [], "bonus": 4500, - "activation": false, + "activation": true, "probability": 250, "num": 16 }, @@ -1059,7 +1059,7 @@ } ], "bonus": 900, - "activation": false, + "activation": true, "probability": 850, "num": 4 }, @@ -1107,7 +1107,7 @@ } ], "bonus": 1800, - "activation": false, + "activation": true, "probability": 700, "num": 7 }, @@ -1155,7 +1155,7 @@ } ], "bonus": 2700, - "activation": false, + "activation": true, "probability": 550, "num": 10 }, @@ -1203,7 +1203,7 @@ } ], "bonus": 3600, - "activation": false, + "activation": true, "probability": 400, "num": 13 }, @@ -1245,7 +1245,7 @@ "level": 15, "need": [], "bonus": 4500, - "activation": false, + "activation": true, "probability": 250, "num": 16 }, @@ -1309,7 +1309,7 @@ } ], "bonus": 900, - "activation": false, + "activation": true, "probability": 850, "num": 4 }, @@ -1357,7 +1357,7 @@ } ], "bonus": 1800, - "activation": false, + "activation": true, "probability": 700, "num": 7 }, @@ -1405,7 +1405,7 @@ } ], "bonus": 2700, - "activation": false, + "activation": true, "probability": 550, "num": 10 }, @@ -1453,7 +1453,7 @@ } ], "bonus": 3600, - "activation": false, + "activation": true, "probability": 400, "num": 13 }, @@ -1495,7 +1495,7 @@ "level": 15, "need": [], "bonus": 4500, - "activation": false, + "activation": true, "probability": 250, "num": 16 } diff --git a/comm/imodule.go b/comm/imodule.go index 731be8541..5c82bbf6b 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -59,10 +59,10 @@ type ( //武器模块 IEquipment interface { //查询服务资源数量 db id - QueryEquipment(source *ModuleCallSource, uid string, Id int32) (equipment pb.DB_Equipment, code pb.ErrorCode) + QueryEquipment(source *ModuleCallSource, uid string, Id string) (equipment *pb.DB_Equipment, code pb.ErrorCode) //查询服务资源数量 参数武器配置id QueryEquipmentAmount(source *ModuleCallSource, uid string, equipmentId int32) (amount uint32) - //新加武器 - AddNewEquipments(source *ModuleCallSource, uid string, eid int, add int32) (code pb.ErrorCode) + //添加新武器 + AddNewEquipments(source *ModuleCallSource, uid string, cIds map[int32]uint32) (code pb.ErrorCode) } ) diff --git a/modules/equipment/api_equip.go b/modules/equipment/api_equip.go index b02cca51b..bea0f569f 100644 --- a/modules/equipment/api_equip.go +++ b/modules/equipment/api_equip.go @@ -20,7 +20,7 @@ func (this *Api_Comp) Equip_Check(session comm.IUserSession, req *pb.Equipment_E equipments = make([]*pb.DB_Equipment, len(req.EquipmentId)) for i, v := range req.EquipmentId { if v != "" { - if equipments[i], err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsPackById(session.GetUserId(), v); err != nil { + if equipments[i], err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsById(session.GetUserId(), v); err != nil { log.Errorf("Equip_Check err:%v", err) code.Code = pb.ErrorCode_EquipmentOnFoundEquipment return @@ -68,7 +68,7 @@ func (this *Api_Comp) Equip(session comm.IUserSession, agrs map[string]interface for i, v := range hero.EquipID { if v != "" { if equipments[i] != nil && v != equipments[i].Id { - if equipment, err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsPackById(session.GetUserId(), v); err != nil { + if equipment, err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsById(session.GetUserId(), v); err != nil { log.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), v, err) code = pb.ErrorCode_SystemError return @@ -77,7 +77,7 @@ func (this *Api_Comp) Equip(session comm.IUserSession, agrs map[string]interface equipments[i].HeroId = hero.Id updatequipment = append(updatequipment, equipment, equipments[i]) } else if equipments[i] == nil { - if equipment, err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsPackById(session.GetUserId(), v); err != nil { + if equipment, err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsById(session.GetUserId(), v); err != nil { log.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), v, err) code = pb.ErrorCode_SystemError return @@ -100,7 +100,7 @@ func (this *Api_Comp) Equip(session comm.IUserSession, agrs map[string]interface } } if code = this.module.hero.UpdateEquipment(hero, equipments); code == pb.ErrorCode_Success { - if err = this.module.model_equipment_comp.Equipment_UpdateIsEquip(session.GetUserId(), updatequipment...); err != nil { + if err = this.module.model_equipment_comp.Equipment_UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil { log.Errorf("Equip err%v", err) code = pb.ErrorCode_SystemError return diff --git a/modules/equipment/api_getlist.go b/modules/equipment/api_getlist.go index 1c76a3178..89b79a60f 100644 --- a/modules/equipment/api_getlist.go +++ b/modules/equipment/api_getlist.go @@ -23,7 +23,7 @@ func (this *Api_Comp) Getlist(session comm.IUserSession, agrs map[string]interfa session.SendMsg(string(this.module.GetType()), "", &pb.Equipment_GetList_Resp{Equipments: items}) } }() - if items, err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsPack(session.GetUserId()); err != nil { + if items, err = this.module.model_equipment_comp.Equipment_QueryUserEquipments(session.GetUserId()); err != nil { log.Errorf("QueryUserPackReq err:%v", err) code = pb.ErrorCode_CacheReadError return diff --git a/modules/equipment/api_upgrade.go b/modules/equipment/api_upgrade.go index 055c645c7..da605b8e7 100644 --- a/modules/equipment/api_upgrade.go +++ b/modules/equipment/api_upgrade.go @@ -24,7 +24,7 @@ func (this *Api_Comp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment code.Code = pb.ErrorCode_ReqParameterError return } - if equipment, err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsPackById(session.GetUserId(), req.EquipmentId); err != nil { + if equipment, err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsById(session.GetUserId(), req.EquipmentId); err != nil { log.Errorf("Equip_Check err:%v", err) code.Code = pb.ErrorCode_EquipmentOnFoundEquipment return @@ -35,7 +35,7 @@ func (this *Api_Comp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment return } //找到下一个等级的相关配置 - if intensify, err = this.module.configure_comp.GetEquipmentIntensifyConfigureById(equipment.Lv + 1); err != nil { + if intensify, err = this.module.configure_comp.GetEquipmentIntensifyConfigureById(equipment.Lv); err != nil { log.Errorf("Equip_Check err:%v", err) code.Code = pb.ErrorCode_EquipmentLvlimitReached return @@ -97,7 +97,11 @@ func (this *Api_Comp) Upgrade(session comm.IUserSession, agrs map[string]interfa equipment.Id = primitive.NewObjectID().Hex() equipment.IsInitialState = false equipment.OverlayNum = 1 - equipment.Lv++ + if err = this.module.model_equipment_comp.upgradeEquipment(equipment, conf, intensify); err != nil { + code = pb.ErrorCode_SystemError + log.Errorf("Upgrade err:%v", err) + return + } if err = this.module.model_equipment_comp.AddList(session.GetUserId(), equipment.Id, equipment); err != nil { log.Errorf("Upgrade err:%v", err) code = pb.ErrorCode_SystemError @@ -105,9 +109,15 @@ func (this *Api_Comp) Upgrade(session comm.IUserSession, agrs map[string]interfa } } else { equipment.IsInitialState = false - equipment.Lv++ + if err = this.module.model_equipment_comp.upgradeEquipment(equipment, conf, intensify); err != nil { + code = pb.ErrorCode_SystemError + log.Errorf("Upgrade err:%v", err) + return + } if err = this.module.model_equipment_comp.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{ "lv": equipment.Lv, + "mainEntry": equipment.MainEntry, + "adverbEntry": equipment.AdverbEntry, "isInitialState": false, }); err != nil { log.Errorf("Upgrade err:%v", err) @@ -126,7 +136,7 @@ func (this *Api_Comp) Upgrade(session comm.IUserSession, agrs map[string]interfa for i, v := range hero.EquipID { if v != "" { if v != equipment.Id { - if equipments[i], err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsPackById(session.GetUserId(), v); err != nil { + if equipments[i], err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsById(session.GetUserId(), v); err != nil { log.Errorf("Upgrade err:%v", err) code = pb.ErrorCode_EquipmentOnFoundEquipment return diff --git a/modules/equipment/configure_comp.go b/modules/equipment/configure_comp.go index 4a662006f..fc8e81615 100644 --- a/modules/equipment/configure_comp.go +++ b/modules/equipment/configure_comp.go @@ -6,13 +6,14 @@ import ( cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/log" ) const ( - game_equip = "game_equip.json" //装备信息表 - equip_attrlibrary = "equip_attrlibrary.json" //装备属性配置表 - equip_intensify = "equip_intensify.json" //装备等级消耗表 - equip_suit = "equip_suit.json" //装备套装表 + game_equip = "game_equip.json" //装备信息表 + equip_attrlibrary = "game_equipattrlibrary.json" //装备属性配置表 + equip_intensify = "game_equipintensify.json" //装备等级消耗表 + equip_suit = "game_equipsuit.json" //装备套装表 ) ///背包配置管理组件 @@ -35,10 +36,12 @@ func (this *Configure_Comp) GetEquipmentConfigure() (configure *cfg.Game_equip, ok bool ) if v, err = this.GetConfigure(game_equip); err != nil { + log.Errorf("err:%v", err) return } else { if configure, ok = v.(*cfg.Game_equip); !ok { err = fmt.Errorf("%T no is *cfg.Game_equipment", v) + log.Errorf("err:%v", err) return } } @@ -52,10 +55,12 @@ func (this *Configure_Comp) GetEquipmentConfigureById(equipmentId int32) (config ok bool ) if v, err = this.GetConfigure(game_equip); err != nil { + log.Errorf("err:%v", err) return } else { if configure, ok = v.(*cfg.Game_equip).GetDataMap()[equipmentId]; !ok { err = fmt.Errorf("EquipmentConfigure not found:%d ", equipmentId) + log.Errorf("err:%v", err) return } } @@ -69,10 +74,31 @@ func (this *Configure_Comp) GetEquipmentAttrlibraryConfigure() (configure *cfg.G ok bool ) if v, err = this.GetConfigure(equip_attrlibrary); err != nil { + log.Errorf("err:%v", err) return } else { if configure, ok = v.(*cfg.Game_equipAttrlibrary); !ok { err = fmt.Errorf("%T no is *cfg.Game_equipment", v) + log.Errorf("err:%v", err) + return + } + } + return +} + +//获取属性词列表 +func (this *Configure_Comp) GetEquipmentAttrlibraryConfigureByKey(key int32) (configure *cfg.Game_equipAttrlibraryData, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(equip_attrlibrary); err != nil { + log.Errorf("err:%v", err) + return + } else { + if configure, ok = v.(*cfg.Game_equipAttrlibrary).GetDataMap()[key]; !ok { + err = fmt.Errorf("EquipmentConfigure GetEquipmentAttrlibraryConfigureByKey not found:%d ", key) + log.Errorf("err:%v", err) return } } @@ -85,6 +111,7 @@ func (this *Configure_Comp) GetEquipmentAttrlibraryConfigureById(Id int32) (conf v interface{} ) if v, err = this.GetConfigure(equip_attrlibrary); err != nil { + log.Errorf("err:%v", err) return } else { configure = make([]*cfg.Game_equipAttrlibraryData, 0) @@ -104,10 +131,12 @@ func (this *Configure_Comp) GetEquipmentIntensifyConfigure() (configure *cfg.Gam ok bool ) if v, err = this.GetConfigure(equip_intensify); err != nil { + log.Errorf("err:%v", err) return } else { if configure, ok = v.(*cfg.Game_equipIntensify); !ok { err = fmt.Errorf("%T no is *cfg.Game_equipment", v) + log.Errorf("err:%v", err) return } } @@ -121,10 +150,12 @@ func (this *Configure_Comp) GetEquipmentIntensifyConfigureById(Id int32) (config ok bool ) if v, err = this.GetConfigure(equip_intensify); err != nil { + log.Errorf("err:%v", err) return } else { if configure, ok = v.(*cfg.Game_equipIntensify).GetDataMap()[Id]; !ok { err = fmt.Errorf("EquipmentConfigure not found:%d ", Id) + log.Errorf("err:%v", err) return } } diff --git a/modules/equipment/model_equipment_comp.go b/modules/equipment/model_equipment_comp.go index 13ad347cb..92b0941ea 100644 --- a/modules/equipment/model_equipment_comp.go +++ b/modules/equipment/model_equipment_comp.go @@ -33,21 +33,39 @@ func (this *Model_Equipment_Comp) Init(service core.IService, module core.IModul } //查询用户装备数据 -func (this *Model_Equipment_Comp) Equipment_QueryUserEquipmentsPackById(uId, id string) (equipment *pb.DB_Equipment, err error) { +func (this *Model_Equipment_Comp) Equipment_QueryUserEquipmentsById(uId, id string) (equipment *pb.DB_Equipment, err error) { equipment = &pb.DB_Equipment{} err = this.GetListObj(uId, id, equipment) return } ///查询用户的武器背包 -func (this *Model_Equipment_Comp) Equipment_QueryUserEquipmentsPack(uId string) (equipments []*pb.DB_Equipment, err error) { +func (this *Model_Equipment_Comp) Equipment_QueryUserEquipments(uId string) (equipments []*pb.DB_Equipment, err error) { equipments = make([]*pb.DB_Equipment, 0) err = this.GetList(uId, &equipments) return } +///查询目标卡片数量 +func (this *Model_Equipment_Comp) QueryEquipmentAmount(uid string, equipmentId int32) (amount uint32) { + var ( + equipments []*pb.DB_Equipment + err error + ) + amount = 0 + if equipments, err = this.Equipment_QueryUserEquipments(uid); err != nil { + return + } + for _, v := range equipments { + if v.CId == equipmentId { + amount += v.OverlayNum + } + } + return +} + //添加装备 -func (this *Model_Equipment_Comp) Equipment_AddEquipmentsToPack(uId string, cIds map[int32]uint32) (err error) { +func (this *Model_Equipment_Comp) Equipment_AddEquipments(uId string, cIds map[int32]uint32) (err error) { var ( configure *cfg.Game_equip equipments []*pb.DB_Equipment @@ -58,7 +76,7 @@ func (this *Model_Equipment_Comp) Equipment_AddEquipmentsToPack(uId string, cIds if configure, err = this.module.configure_comp.GetEquipmentConfigure(); err != nil { return } - if equipments, err = this.Equipment_QueryUserEquipmentsPack(uId); err != nil { + if equipments, err = this.Equipment_QueryUserEquipments(uId); err != nil { return } add = make(map[string]*pb.DB_Equipment) @@ -84,24 +102,25 @@ func (this *Model_Equipment_Comp) Equipment_AddEquipmentsToPack(uId string, cIds } } if err = this.AddLists(uId, add); err != nil { - log.Errorf("[Equipment] Equipment_AddEquipmentsToPack err:%v", err) + log.Errorf("err:%v", err) return } for _, v := range update { if err = this.ChangeList(uId, v.Id, map[string]interface{}{"overlayNum": v.OverlayNum}); err != nil { - log.Errorf("[Equipment] Equipment_AddEquipmentsToPack err:%v", err) + log.Errorf("err:%v", err) return } } return } -func (this *Model_Equipment_Comp) Equipment_UpdateIsEquip(uid string, equipments ...*pb.DB_Equipment) (err error) { +//更新武器挂载信息 +func (this *Model_Equipment_Comp) Equipment_UpdateByHeroId(uid string, equipments ...*pb.DB_Equipment) (err error) { for _, v := range equipments { if err = this.ChangeList(uid, v.Id, map[string]interface{}{ "heroId": v.HeroId, }); err != nil { - log.Errorf("Equipment_UpdateIsEquip err:%v", err) + log.Errorf("err:%v", err) return } } @@ -119,10 +138,11 @@ func (this *Model_Equipment_Comp) newEquipment(uid string, conf *cfg.Game_equipD equipment = &pb.DB_Equipment{ Id: primitive.NewObjectID().Hex(), CId: conf.Id, + Lv: 1, UId: uid, OverlayNum: num, IsInitialState: true, - AdverbEntry: make([]*pb.EquipmentAttributeEntry, 4), + AdverbEntry: make([]*pb.EquipmentAttributeEntry, 0), } if mattr, err = this.module.configure_comp.GetEquipmentAttrlibraryConfigureById(conf.Leadlibrary); err != nil || len(mattr) == 0 { return @@ -130,9 +150,9 @@ func (this *Model_Equipment_Comp) newEquipment(uid string, conf *cfg.Game_equipD equipment.MainEntry = &pb.EquipmentAttributeEntry{ Id: mattr[0].Key, Libraryid: mattr[0].Libraryid, - Lv: 0, - AttrName: mattr[0].Attr[0], - Value: 0, + Lv: 1, + AttrName: mattr[0].Attrkey, + Value: mattr[0].Attrvar, } if sattr, err = this.module.configure_comp.GetEquipmentAttrlibraryConfigureById(conf.Addlibrary); err != nil || len(mattr) == 0 { return @@ -148,18 +168,67 @@ func (this *Model_Equipment_Comp) newEquipment(uid string, conf *cfg.Game_equipD break } } - if satterNum > 0 { + if satterNum > 0 && satterNum <= 4 { r := rand.New(rand.NewSource(time.Now().Unix())) - for i, v := range r.Perm(len(sattr))[:satterNum] { - equipment.AdverbEntry[i] = &pb.EquipmentAttributeEntry{ + for _, v := range r.Perm(len(sattr))[:satterNum] { + equipment.AdverbEntry = append(equipment.AdverbEntry, &pb.EquipmentAttributeEntry{ Id: sattr[v].Key, Libraryid: sattr[v].Libraryid, - Lv: 0, - AttrName: sattr[v].Attr[0], - Value: 0, - } + Lv: 1, + AttrName: sattr[v].Attrkey, + Value: sattr[v].Attrvar, + }) } } - + return +} + +//升级武器 +func (this *Model_Equipment_Comp) upgradeEquipment(equipment *pb.DB_Equipment, equip *cfg.Game_equipData, intensify *cfg.Game_equipIntensifyData) (err error) { + equipment.Lv++ + equipment.MainEntry.Lv++ + equipment.MainEntry.Value += equipment.MainEntry.Value * (intensify.Bonus / 1000.0) + if !intensify.Activation { //不触发副词条变化 + return + } + if len(equipment.AdverbEntry) < 4 { //去随机副词条 + var temp []*cfg.Game_equipAttrlibraryData + var sattr []*cfg.Game_equipAttrlibraryData + if temp, err = this.module.configure_comp.GetEquipmentAttrlibraryConfigureById(equip.Addlibrary); err != nil || len(temp) == 0 { + log.Errorf("升级服务错误 读取副词条配置错误!") + return + } + //检索出未使用的词条 + for _, v := range sattr { + iskeep := false + for _, v1 := range equipment.AdverbEntry { + if v.Key == v1.Id { + iskeep = true + } + } + if !iskeep { + sattr = append(sattr, v) + } + } + r := rand.New(rand.NewSource(time.Now().Unix())) + index := r.Perm(len(sattr))[0] + equipment.AdverbEntry = append(equipment.AdverbEntry, &pb.EquipmentAttributeEntry{ + Id: sattr[index].Key, + Libraryid: sattr[index].Libraryid, + Lv: 1, + AttrName: sattr[index].Attrkey, + Value: sattr[index].Attrvar, + }) + } else { //随机一个副词条 强化 + var attrlibrary *cfg.Game_equipAttrlibraryData + r := rand.New(rand.NewSource(time.Now().Unix())) + index := r.Perm(len(equipment.AdverbEntry))[0] + + if attrlibrary, err = this.module.configure_comp.GetEquipmentAttrlibraryConfigureByKey(equipment.AdverbEntry[index].Id); err != nil { + return + } + equipment.AdverbEntry[index].Value += attrlibrary.Addition[equipment.AdverbEntry[index].Lv-1] / 1000.0 * attrlibrary.Attrvar + equipment.AdverbEntry[index].Lv++ + } return } diff --git a/modules/equipment/module.go b/modules/equipment/module.go index 78eb4b435..dbacf2ca0 100644 --- a/modules/equipment/module.go +++ b/modules/equipment/module.go @@ -4,7 +4,9 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" + "go_dreamfactory/pb" + "github.com/go-redis/redis/v8" "github.com/smallnest/rpcx/log" ) @@ -58,3 +60,33 @@ func (this *Equipment) OnInstallComp() { this.model_equipment_comp = this.RegisterComp(new(Model_Equipment_Comp)).(*Model_Equipment_Comp) this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp) } + +//IEquipment------------------------------------------------------------------------------------------------------------------------------- +//查询武器信息 +func (this *Equipment) QueryEquipment(source *comm.ModuleCallSource, uid string, Id string) (equipment *pb.DB_Equipment, code pb.ErrorCode) { + var err error + if equipment, err = this.model_equipment_comp.Equipment_QueryUserEquipmentsById(uid, Id); err != nil { + if err == redis.Nil { + code = pb.ErrorCode_EquipmentOnFoundEquipment + } else { + code = pb.ErrorCode_SystemError + } + } + return +} + +//查询卡片数量 +func (this *Equipment) QueryEquipmentAmount(source *comm.ModuleCallSource, uid string, equipmentId int32) (amount uint32) { + amount = this.model_equipment_comp.QueryEquipmentAmount(uid, equipmentId) + return +} + +//添加武器 +func (this *Equipment) AddNewEquipments(source *comm.ModuleCallSource, uid string, cIds map[int32]uint32) (code pb.ErrorCode) { + var err error + if err = this.model_equipment_comp.Equipment_AddEquipments(uid, cIds); err != nil { + log.Errorf("err%v", err) + code = pb.ErrorCode_SystemError + } + return +} diff --git a/modules/equipment/module_test.go b/modules/equipment/module_test.go index 5a8a34a5a..d30f57b02 100644 --- a/modules/equipment/module_test.go +++ b/modules/equipment/module_test.go @@ -7,6 +7,7 @@ import ( "go_dreamfactory/lego/base/rpcx" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" + "go_dreamfactory/modules/hero" "go_dreamfactory/services" "go_dreamfactory/sys/cache" "go_dreamfactory/sys/configure" @@ -40,7 +41,7 @@ func (this *TestService) InitSys() { } else { log.Infof("init sys.db success!") } - if err := configure.OnInit(this.GetSettings().Sys["configure"]); err != nil { + if err := configure.OnInit(this.GetSettings().Sys["configure"], configure.SetConfigPath("F:/work/go/go_dreamfactory/bin/json")); err != nil { panic(fmt.Sprintf("init sys.configure err: %s", err.Error())) } else { log.Infof("init sys.configure success!") @@ -63,6 +64,7 @@ func TestMain(m *testing.M) { go func() { lego.Run(service, //运行模块 module, + hero.NewModule(), ) }() time.Sleep(time.Second * 3) @@ -70,5 +72,10 @@ func TestMain(m *testing.M) { } func Test_Module(t *testing.T) { - + code := module.AddNewEquipments(&comm.ModuleCallSource{ + Module: "Test", + FuncName: "Test_Module", + Describe: "摸底测试", + }, "0_62b16dda909b2f8faeff788d", map[int32]uint32{10001: 1}) + log.Debugf("Test_Module Code:%d", code) } diff --git a/modules/items/module.go b/modules/items/module.go index 772acbc45..8c95f3ab5 100644 --- a/modules/items/module.go +++ b/modules/items/module.go @@ -46,7 +46,7 @@ func (this *Items) OnInstallComp() { this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp) } -//IPack------------------------------------------------------------------------------------------------------------------------------- +//IItems------------------------------------------------------------------------------------------------------------------------------- ///查询用户背包物品数量 func (this *Items) QueryItemAmount(source *comm.ModuleCallSource, uId string, itemid int32) (amount uint32) { defer log.Debugf("获取物品 uId:%s itemid:%d addnum:%d ", uId, itemid, amount) diff --git a/modules/model_comp.go b/modules/model_comp.go index 215c2bb9e..289172ccf 100644 --- a/modules/model_comp.go +++ b/modules/model_comp.go @@ -294,6 +294,9 @@ func (this *Model_Comp) GetList(uid string, data interface{}) (err error) { } temp[_id] = elem.Elem().Addr().Interface() } + if len(temp) == 0 { //没有数据自己返回 + return + } for k, v := range temp { key := this.ukeylist(uid, k) if err = this.Redis.HMSet(key, v); err != nil { diff --git a/modules/modulebase.go b/modules/modulebase.go index 8c22c5f66..c2220b59a 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -80,36 +80,36 @@ func (this *ModuleBase) SendMsgToUsers(mainType, subType string, msg proto.Messa //校验消耗资源 func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code pb.ErrorCode) { var ( - module core.IModule - err error - resID int - amount int32 - user comm.IUser //用户模块 - items comm.IItems //道具背包模块 - hero comm.IHero //英雄模块 - equipment comm.IEquipment //装备模块 + module core.IModule + err error + resID int + amount int32 + user comm.IUser //用户模块 + items comm.IItems //道具背包模块 + hero comm.IHero //英雄模块 + // equipment comm.IEquipment //装备模块 ) if module, err = this.service.GetModule(comm.SM_UserModule); err == nil { return } user = module.(comm.IUser) - if module, err = this.service.GetModule(comm.SM_UserModule); err == nil { + if module, err = this.service.GetModule(comm.SM_ItemsModule); err == nil { return } items = module.(comm.IItems) - if module, err = this.service.GetModule(comm.SM_UserModule); err == nil { + if module, err = this.service.GetModule(comm.SM_HeroModule); err == nil { return } hero = module.(comm.IHero) - if module, err = this.service.GetModule(comm.SM_UserModule); err == nil { - return - } + // if module, err = this.service.GetModule(comm.SM_EquipmentModule); err == nil { + // return + // } + // equipment = module.(comm.IEquipment) source := &comm.ModuleCallSource{ Module: string(this.module.GetType()), FuncName: "CheckConsumeRes", Describe: "消耗资源", } - equipment = module.(comm.IEquipment) //校验消费资源是否充足 for _, v := range res { if v.A == comm.AttrType { //用户属性资源 @@ -135,16 +135,18 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p code = pb.ErrorCode_ResNoEnough return } - } else if v.A == comm.EquipmentType { - if resID, err = strconv.Atoi(v.T); err != nil { - code = pb.ErrorCode_ConfigurationException - return - } - if amount = int32(equipment.QueryEquipmentAmount(source, uid, int32(resID))); amount < v.N { - code = pb.ErrorCode_ResNoEnough - return - } } + //不存在消耗武器的情况 + // } else if v.A == comm.EquipmentType { + // if resID, err = strconv.Atoi(v.T); err != nil { + // code = pb.ErrorCode_ConfigurationException + // return + // } + // if amount = int32(equipment.QueryEquipmentAmount(source, uid, int32(resID))); amount < v.N { + // code = pb.ErrorCode_ResNoEnough + // return + // } + // } } for _, v := range res { @@ -156,10 +158,12 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p } else if v.A == comm.CardType { //卡片资源 resID, _ = strconv.Atoi(v.T) hero.AddCard(uid, int32(resID), -1*v.N) - } else if v.A == comm.EquipmentType { - resID, _ = strconv.Atoi(v.T) - equipment.AddNewEquipments(source, uid, resID, -1*v.N) } + //不存在消耗武器的情况 + // } else if v.A == comm.EquipmentType { + // resID, _ = strconv.Atoi(v.T) + // equipment.AddNewEquipments(source, uid, resID, -1*v.N) + // } } return diff --git a/sys/configure/structs/game.equipAttrlibraryData.go b/sys/configure/structs/game.equipAttrlibraryData.go index 9d8ac77f4..b3c9988dd 100644 --- a/sys/configure/structs/game.equipAttrlibraryData.go +++ b/sys/configure/structs/game.equipAttrlibraryData.go @@ -1,4 +1,3 @@ - //------------------------------------------------------------------------------ // // This code was generated by a tool. @@ -11,49 +10,87 @@ package cfg import "errors" type Game_equipAttrlibraryData struct { - Key int32 - Libraryid int32 - Attr []string - Probability int32 - Addition []int32 + Key int32 + Libraryid int32 + Attrkey string + Attrvar int32 + Probability int32 + Addition []int32 } func (Game_equipAttrlibraryData) GetTypeId() int { - return -437457248 + return -437457248 } func NewGame_equipAttrlibraryData(_buf map[string]interface{}) (_v *Game_equipAttrlibraryData, err error) { - _v = &Game_equipAttrlibraryData{} - { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["key"].(float64); !_ok_ { err = errors.New("key error"); return }; _v.Key = int32(_tempNum_) } - { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["libraryid"].(float64); !_ok_ { err = errors.New("libraryid error"); return }; _v.Libraryid = int32(_tempNum_) } - { - var _arr_ []interface{} - var _ok_ bool - if _arr_, _ok_ = _buf["attr"].([]interface{}); !_ok_ { err = errors.New("attr error"); return } + _v = &Game_equipAttrlibraryData{} + { + var _ok_ bool + var _tempNum_ float64 + if _tempNum_, _ok_ = _buf["key"].(float64); !_ok_ { + err = errors.New("key error") + return + } + _v.Key = int32(_tempNum_) + } + { + var _ok_ bool + var _tempNum_ float64 + if _tempNum_, _ok_ = _buf["libraryid"].(float64); !_ok_ { + err = errors.New("libraryid error") + return + } + _v.Libraryid = int32(_tempNum_) + } + { + var _ok_ bool + if _v.Attrkey, _ok_ = _buf["attrkey"].(string); !_ok_ { + err = errors.New("attrkey error") + return + } + } + { + var _ok_ bool + var _tempNum_ float64 + if _tempNum_, _ok_ = _buf["attrvar"].(float64); !_ok_ { + err = errors.New("attrvar error") + return + } + _v.Attrvar = int32(_tempNum_) + } + { + var _ok_ bool + var _tempNum_ float64 + if _tempNum_, _ok_ = _buf["probability"].(float64); !_ok_ { + err = errors.New("probability error") + return + } + _v.Probability = int32(_tempNum_) + } + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["Addition"].([]interface{}); !_ok_ { + err = errors.New("Addition error") + return + } - _v.Attr = make([]string, 0, len(_arr_)) - - for _, _e_ := range _arr_ { - var _list_v_ string - { if _list_v_, _ok_ = _e_.(string); !_ok_ { err = errors.New("_list_v_ error"); return } } - _v.Attr = append(_v.Attr, _list_v_) - } - } + _v.Addition = make([]int32, 0, len(_arr_)) - { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["probability"].(float64); !_ok_ { err = errors.New("probability error"); return }; _v.Probability = int32(_tempNum_) } - { - var _arr_ []interface{} - var _ok_ bool - if _arr_, _ok_ = _buf["Addition"].([]interface{}); !_ok_ { err = errors.New("Addition error"); return } + for _, _e_ := range _arr_ { + var _list_v_ int32 + { + var _ok_ bool + var _x_ float64 + if _x_, _ok_ = _e_.(float64); !_ok_ { + err = errors.New("_list_v_ error") + return + } + _list_v_ = int32(_x_) + } + _v.Addition = append(_v.Addition, _list_v_) + } + } - _v.Addition = make([]int32, 0, len(_arr_)) - - for _, _e_ := range _arr_ { - var _list_v_ int32 - { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } - _v.Addition = append(_v.Addition, _list_v_) - } - } - - return + return } From b6a3ce955a11f5a689176310eb9ee3e78590c4ff Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 28 Jun 2022 14:51:58 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=20=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=91=BD=E5=90=8D=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{configure_comp.go => comp_configure.go} | 10 ++--- modules/{gate_comp.go => comp_gate.go} | 16 +++---- modules/{model_comp.go => comp_model.go} | 42 +++++++++---------- modules/dbservice/db_comp.go | 6 +-- modules/equipment/api.go | 12 +++--- modules/equipment/api_equip.go | 20 ++++----- modules/equipment/api_getlist.go | 17 ++++---- modules/equipment/api_upgrade.go | 22 +++++----- .../{configure_comp.go => configure.go} | 20 ++++----- ...l_equipment_comp.go => model_equipment.go} | 36 ++++++++-------- modules/equipment/module.go | 22 +++++----- modules/equipment/module_test.go | 5 ++- modules/game/module.go | 8 ++-- modules/gateway/agentmgr_comp.go | 20 ++++----- modules/gateway/module.go | 32 +++++++------- modules/gateway/wservice_comp.go | 6 +-- modules/items/api.go | 12 +++--- modules/items/api_getlist.go | 12 +++--- modules/items/api_sellItem.go | 4 +- modules/items/api_useItem.go | 4 +- .../items/{configure_comp.go => configure.go} | 10 ++--- .../{model_pack_comp.go => modelitems.go} | 30 ++++++------- modules/items/module.go | 21 +++++----- modules/items/module_test.go | 5 ++- pb/proto/comm.proto | 5 ++- services/comp_gateroute.go | 20 ++++----- 26 files changed, 208 insertions(+), 209 deletions(-) rename modules/{configure_comp.go => comp_configure.go} (62%) rename modules/{gate_comp.go => comp_gate.go} (86%) rename modules/{model_comp.go => comp_model.go} (88%) rename modules/equipment/{configure_comp.go => configure.go} (75%) rename modules/equipment/{model_equipment_comp.go => model_equipment.go} (72%) rename modules/items/{configure_comp.go => configure.go} (75%) rename modules/items/{model_pack_comp.go => modelitems.go} (80%) diff --git a/modules/configure_comp.go b/modules/comp_configure.go similarity index 62% rename from modules/configure_comp.go rename to modules/comp_configure.go index 6986c981f..2a45b932e 100644 --- a/modules/configure_comp.go +++ b/modules/comp_configure.go @@ -8,14 +8,14 @@ import ( ) ///配置管理基础组件 -type MComp_Configure struct { +type MCompConfigure struct { cbase.ModuleCompBase S base.IRPCXService //rpc服务对象 M IModule //当前业务模块 } //组件初始化接口 -func (this *MComp_Configure) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { +func (this *MCompConfigure) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { this.ModuleCompBase.Init(service, module, comp, options) this.S = service.(base.IRPCXService) this.M = module.(IModule) @@ -23,12 +23,12 @@ func (this *MComp_Configure) Init(service core.IService, module core.IModule, co } //加载一个配置文件 -func (this *MComp_Configure) LoadConfigure(name string, fn interface{}) (err error) { +func (this *MCompConfigure) LoadConfigure(name string, fn interface{}) (err error) { return configure.RegisterConfigure(name, fn) } //加载多个配置文件 -func (this *MComp_Configure) LoadMultiConfigure(confs map[string]interface{}) (err error) { +func (this *MCompConfigure) LoadMultiConfigure(confs map[string]interface{}) (err error) { for k, v := range confs { err = configure.RegisterConfigure(k, v) if err != nil { @@ -39,6 +39,6 @@ func (this *MComp_Configure) LoadMultiConfigure(confs map[string]interface{}) (e } //读取配置数据 -func (this *MComp_Configure) GetConfigure(name string) (v interface{}, err error) { +func (this *MCompConfigure) GetConfigure(name string) (v interface{}, err error) { return configure.GetConfigure(name) } diff --git a/modules/gate_comp.go b/modules/comp_gate.go similarity index 86% rename from modules/gate_comp.go rename to modules/comp_gate.go index 89ba53cf0..e2a0bc3e6 100644 --- a/modules/gate_comp.go +++ b/modules/comp_gate.go @@ -28,7 +28,7 @@ var typeOfError = reflect.TypeOf((*error)(nil)).Elem() /* 模块 网关组件 接收处理用户传递消息 */ -type MComp_GateComp struct { +type MCompGate struct { cbase.ModuleCompBase service base.IRPCXService //rpc服务对象 module core.IModule //当前业务模块 @@ -37,7 +37,7 @@ type MComp_GateComp struct { } //组件初始化接口 -func (this *MComp_GateComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { +func (this *MCompGate) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { this.ModuleCompBase.Init(service, module, comp, options) this.service = service.(base.IRPCXService) this.module = module @@ -46,7 +46,7 @@ func (this *MComp_GateComp) Init(service core.IService, module core.IModule, com } //组件启动接口,启动时将自己接收用户消息的处理函数注册到services/comp_gateroute.go 对象中 -func (this *MComp_GateComp) Start() (err error) { +func (this *MCompGate) Start() (err error) { if err = this.ModuleCompBase.Start(); err != nil { return } @@ -61,7 +61,7 @@ func (this *MComp_GateComp) Start() (err error) { } //反射注册相关接口道services/comp_gateroute.go 对象中 -func (this *MComp_GateComp) suitableMethods(typ reflect.Type) { +func (this *MCompGate) suitableMethods(typ reflect.Type) { for m := 0; m < typ.NumMethod(); m++ { method := typ.Method(m) this.reflectionRouteHandle(method) @@ -70,7 +70,7 @@ func (this *MComp_GateComp) suitableMethods(typ reflect.Type) { } //反射注册路由处理函数 -func (this *MComp_GateComp) reflectionRouteHandle(method reflect.Method) { +func (this *MCompGate) reflectionRouteHandle(method reflect.Method) { mtype := method.Type mname := method.Name if method.PkgPath != "" { @@ -105,7 +105,7 @@ func (this *MComp_GateComp) reflectionRouteHandle(method reflect.Method) { } //反射注册路由校验函数 -func (this *MComp_GateComp) reflectionRouteCheck(method reflect.Method) { +func (this *MCompGate) reflectionRouteCheck(method reflect.Method) { mtype := method.Type mname := strings.Split(method.Name, "_") if len(mname) != 2 || mname[1] != "Check" { @@ -142,14 +142,14 @@ func (this *MComp_GateComp) reflectionRouteCheck(method reflect.Method) { this.scomp.RegisterRouteCheck(fmt.Sprintf("%s.%s", this.module.GetType(), strings.ToLower(mname[0])), reflect.ValueOf(this.comp), replyType, method) } -func (this *MComp_GateComp) isExportedOrBuiltinType(t reflect.Type) bool { +func (this *MCompGate) isExportedOrBuiltinType(t reflect.Type) bool { for t.Kind() == reflect.Ptr { t = t.Elem() } return this.isExported(t.Name()) || t.PkgPath() == "" } -func (this *MComp_GateComp) isExported(name string) bool { +func (this *MCompGate) isExported(name string) bool { rune, _ := utf8.DecodeRuneInString(name) return unicode.IsUpper(rune) } diff --git a/modules/model_comp.go b/modules/comp_model.go similarity index 88% rename from modules/model_comp.go rename to modules/comp_model.go index 289172ccf..473023f51 100644 --- a/modules/model_comp.go +++ b/modules/comp_model.go @@ -23,7 +23,7 @@ import ( 基础组件 缓存组件 读写缓存数据 DB组件也封装进来 */ -type Model_Comp struct { +type MCompModel struct { cbase.ModuleCompBase Redis redis.ISys DB mgo.ISys @@ -35,25 +35,25 @@ const ( ) //组件初始化接口 -func (this *Model_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { +func (this *MCompModel) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { this.ModuleCompBase.Init(service, module, comp, options) this.Redis = cache.Redis() this.DB = db.Mgo() return } -func (this *Model_Comp) Start() (err error) { +func (this *MCompModel) Start() (err error) { err = this.ModuleCompBase.Start() return } -func (this *Model_Comp) ukey(uid string) string { +func (this *MCompModel) ukey(uid string) string { return fmt.Sprintf("%s:%s", this.TableName, uid) } -func (this *Model_Comp) ukeylist(uid string, id string) string { +func (this *MCompModel) ukeylist(uid string, id string) string { return fmt.Sprintf("%s:%s-%s", this.TableName, uid, id) } -func (this *Model_Comp) InsertModelLogs(table string, uID string, target interface{}) (err error) { +func (this *MCompModel) InsertModelLogs(table string, uID string, target interface{}) (err error) { data := &comm.Autogenerated{ ID: primitive.NewObjectID().Hex(), @@ -70,7 +70,7 @@ func (this *Model_Comp) InsertModelLogs(table string, uID string, target interfa return err } -func (this *Model_Comp) DeleteModelLogs(table string, uID string, where interface{}) (err error) { +func (this *MCompModel) DeleteModelLogs(table string, uID string, where interface{}) (err error) { data := &comm.Autogenerated{ ID: primitive.NewObjectID().Hex(), @@ -88,7 +88,7 @@ func (this *Model_Comp) DeleteModelLogs(table string, uID string, where interfac return err } -func (this *Model_Comp) UpdateModelLogs(table string, uID string, where bson.M, target interface{}) (err error) { +func (this *MCompModel) UpdateModelLogs(table string, uID string, where bson.M, target interface{}) (err error) { data := &comm.Autogenerated{ ID: primitive.NewObjectID().Hex(), @@ -108,7 +108,7 @@ func (this *Model_Comp) UpdateModelLogs(table string, uID string, where bson.M, } //添加新的数据 -func (this *Model_Comp) Add(uid string, data interface{}, attrs ...*cache.OperationAttr) (err error) { +func (this *MCompModel) Add(uid string, data interface{}, attrs ...*cache.OperationAttr) (err error) { if err = this.Redis.HMSet(this.ukey(uid), data); err != nil { return } @@ -122,7 +122,7 @@ func (this *Model_Comp) Add(uid string, data interface{}, attrs ...*cache.Operat } //添加新的数据到列表 -func (this *Model_Comp) AddList(uid string, id string, data interface{}, attrs ...*cache.OperationAttr) (err error) { +func (this *MCompModel) AddList(uid string, id string, data interface{}, attrs ...*cache.OperationAttr) (err error) { key := this.ukeylist(uid, id) if err = this.Redis.HMSet(key, data); err != nil { return @@ -140,7 +140,7 @@ func (this *Model_Comp) AddList(uid string, id string, data interface{}, attrs . } //添加新的多个数据到列表 data map[string]type -func (this *Model_Comp) AddLists(uid string, data interface{}, attrs ...*cache.OperationAttr) (err error) { +func (this *MCompModel) AddLists(uid string, data interface{}, attrs ...*cache.OperationAttr) (err error) { vof := reflect.ValueOf(data) if !vof.IsValid() { return fmt.Errorf("Model_Comp: AddLists(nil)") @@ -180,7 +180,7 @@ func (this *Model_Comp) AddLists(uid string, data interface{}, attrs ...*cache.O } //修改数据多个字段 uid 作为主键 -func (this *Model_Comp) Change(uid string, data map[string]interface{}, attrs ...*cache.OperationAttr) (err error) { +func (this *MCompModel) Change(uid string, data map[string]interface{}, attrs ...*cache.OperationAttr) (err error) { if err = this.Redis.HMSet(this.ukey(uid), data); err != nil { return } @@ -194,7 +194,7 @@ func (this *Model_Comp) Change(uid string, data map[string]interface{}, attrs .. } //修改数据多个字段 uid 作为主键 -func (this *Model_Comp) ChangeList(uid string, _id string, data map[string]interface{}, attrs ...*cache.OperationAttr) (err error) { +func (this *MCompModel) ChangeList(uid string, _id string, data map[string]interface{}, attrs ...*cache.OperationAttr) (err error) { if err = this.Redis.HMSet(this.ukeylist(uid, _id), data); err != nil { return } @@ -208,7 +208,7 @@ func (this *Model_Comp) ChangeList(uid string, _id string, data map[string]inter } //读取全部数据 -func (this *Model_Comp) Get(uid string, data interface{}) (err error) { +func (this *MCompModel) Get(uid string, data interface{}) (err error) { if err = this.Redis.HGetAll(this.ukey(uid), data); err != nil { return } @@ -223,7 +223,7 @@ func (this *Model_Comp) Get(uid string, data interface{}) (err error) { } //获取列表数据 注意 data 必须啊转 切片的指针 *[]type -func (this *Model_Comp) GetList(uid string, data interface{}) (err error) { +func (this *MCompModel) GetList(uid string, data interface{}) (err error) { var keys map[string]string = make(map[string]string) var c *mongo.Cursor t := reflect.TypeOf(data) @@ -314,25 +314,25 @@ func (this *Model_Comp) GetList(uid string, data interface{}) (err error) { } //读取单个数据中 多个字段数据 -func (this *Model_Comp) GetFields(uid string, data interface{}, fields ...string) (err error) { +func (this *MCompModel) GetFields(uid string, data interface{}, fields ...string) (err error) { this.Redis.HMGet(this.ukey(uid), data, fields...) return } //读取List列表中单个数据中 多个字段数据 -func (this *Model_Comp) GetListFields(uid string, id string, data interface{}, fields ...string) (err error) { +func (this *MCompModel) GetListFields(uid string, id string, data interface{}, fields ...string) (err error) { this.Redis.HMGet(this.ukeylist(uid, id), data, fields...) return } //读取列表数据中单个数据 -func (this *Model_Comp) GetListObj(uid string, id string, data interface{}) (err error) { +func (this *MCompModel) GetListObj(uid string, id string, data interface{}) (err error) { err = this.Redis.HGetAll(this.ukeylist(uid, id), data) return } //删除用户数据 -func (this *Model_Comp) Del(uid string) (err error) { +func (this *MCompModel) Del(uid string) (err error) { err = this.Redis.Delete(this.ukey(uid)) if err != nil { return err @@ -342,7 +342,7 @@ func (this *Model_Comp) Del(uid string) (err error) { } //删除多条数据 -func (this *Model_Comp) DelListlds(uid string, ids ...string) (err error) { +func (this *MCompModel) DelListlds(uid string, ids ...string) (err error) { listkey := this.ukey(uid) for _, v := range ids { key := this.ukeylist(uid, v) @@ -357,7 +357,7 @@ func (this *Model_Comp) DelListlds(uid string, ids ...string) (err error) { } //日志操作可选项 -func (this *Model_Comp) logOpt(uid string, data interface{}, attrs ...*cache.OperationAttr) error { +func (this *MCompModel) logOpt(uid string, data interface{}, attrs ...*cache.OperationAttr) error { ret := cache.OperationAttrs(attrs).Find(cache.ATTR_MGOLOG).Unwrap_Or(nil) if ret == nil { //启用mgolog ir := cache.OperationAttrs(attrs).Find(cache.ATTR_INSERT).Unwrap_Or(nil) diff --git a/modules/dbservice/db_comp.go b/modules/dbservice/db_comp.go index 24383fe2f..7ce216013 100644 --- a/modules/dbservice/db_comp.go +++ b/modules/dbservice/db_comp.go @@ -14,20 +14,20 @@ import ( ) type DB_Comp struct { - modules.Model_Comp + modules.MCompModel task chan string isInit bool } func (this *DB_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - this.Model_Comp.Init(service, module, comp, options) + this.MCompModel.Init(service, module, comp, options) this.task = make(chan string, TaskMaxNum) return } func (this *DB_Comp) Start() (err error) { - err = this.Model_Comp.Start() + err = this.MCompModel.Start() model_count := this.Model_TotalCount() if model_count > 0 { //1000 this.Redis.Set(comm.DBService_Status, true, -1) diff --git a/modules/equipment/api.go b/modules/equipment/api.go index 992842bdc..ae992f1a5 100644 --- a/modules/equipment/api.go +++ b/modules/equipment/api.go @@ -9,21 +9,21 @@ import ( /* 装备模块 API */ -type Api_Comp struct { - modules.MComp_GateComp +type ApiComp struct { + modules.MCompGate service core.IService module *Equipment } //组件初始化接口 -func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - this.MComp_GateComp.Init(service, module, comp, options) +func (this *ApiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.MCompGate.Init(service, module, comp, options) this.module = module.(*Equipment) this.service = service return } -func (this *Api_Comp) Start() (err error) { - err = this.MComp_GateComp.Start() +func (this *ApiComp) Start() (err error) { + err = this.MCompGate.Start() return } diff --git a/modules/equipment/api_equip.go b/modules/equipment/api_equip.go index bea0f569f..69c4148e6 100644 --- a/modules/equipment/api_equip.go +++ b/modules/equipment/api_equip.go @@ -8,7 +8,7 @@ import ( ) //参数校验 -func (this *Api_Comp) Equip_Check(session comm.IUserSession, req *pb.Equipment_Equip_Req) (result map[string]interface{}, code comm.ErrorCode) { +func (this *ApiComp) Equip_Check(session comm.IUserSession, req *pb.Equipment_Equip_Req) (result map[string]interface{}, code comm.ErrorCode) { var ( err error errorCode pb.ErrorCode @@ -20,12 +20,12 @@ func (this *Api_Comp) Equip_Check(session comm.IUserSession, req *pb.Equipment_E equipments = make([]*pb.DB_Equipment, len(req.EquipmentId)) for i, v := range req.EquipmentId { if v != "" { - if equipments[i], err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsById(session.GetUserId(), v); err != nil { + if equipments[i], err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil { log.Errorf("Equip_Check err:%v", err) code.Code = pb.ErrorCode_EquipmentOnFoundEquipment return } - if confs[i], err = this.module.configure_comp.GetEquipmentConfigureById(equipments[i].CId); err != nil { + if confs[i], err = this.module.configure.GetEquipmentConfigureById(equipments[i].CId); err != nil { log.Errorf("Equip_Check err:%v", err) code.Code = pb.ErrorCode_EquipmentOnFoundEquipment return @@ -46,7 +46,7 @@ func (this *Api_Comp) Equip_Check(session comm.IUserSession, req *pb.Equipment_E } ///英雄挂在装备 -func (this *Api_Comp) Equip(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_Equip_Req) (code pb.ErrorCode) { +func (this *ApiComp) Equip(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_Equip_Req) (code pb.ErrorCode) { var ( err error confs []*cfg.Game_equipData @@ -55,11 +55,7 @@ func (this *Api_Comp) Equip(session comm.IUserSession, agrs map[string]interface updatequipment []*pb.DB_Equipment hero *pb.DB_HeroData ) - defer func() { - if code == pb.ErrorCode_Success { - session.SendMsg(string(this.module.GetType()), "", &pb.Equipment_Equip_Resp{}) - } - }() + confs = agrs["conf"].([]*cfg.Game_equipData) equipments = agrs["equipment"].([]*pb.DB_Equipment) updatequipment = make([]*pb.DB_Equipment, 0) @@ -68,7 +64,7 @@ func (this *Api_Comp) Equip(session comm.IUserSession, agrs map[string]interface for i, v := range hero.EquipID { if v != "" { if equipments[i] != nil && v != equipments[i].Id { - if equipment, err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsById(session.GetUserId(), v); err != nil { + if equipment, err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil { log.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), v, err) code = pb.ErrorCode_SystemError return @@ -77,7 +73,7 @@ func (this *Api_Comp) Equip(session comm.IUserSession, agrs map[string]interface equipments[i].HeroId = hero.Id updatequipment = append(updatequipment, equipment, equipments[i]) } else if equipments[i] == nil { - if equipment, err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsById(session.GetUserId(), v); err != nil { + if equipment, err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil { log.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), v, err) code = pb.ErrorCode_SystemError return @@ -100,7 +96,7 @@ func (this *Api_Comp) Equip(session comm.IUserSession, agrs map[string]interface } } if code = this.module.hero.UpdateEquipment(hero, equipments); code == pb.ErrorCode_Success { - if err = this.module.model_equipment_comp.Equipment_UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil { + if err = this.module.modelequipment.UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil { log.Errorf("Equip err%v", err) code = pb.ErrorCode_SystemError return diff --git a/modules/equipment/api_getlist.go b/modules/equipment/api_getlist.go index 89b79a60f..9de1c44ae 100644 --- a/modules/equipment/api_getlist.go +++ b/modules/equipment/api_getlist.go @@ -7,26 +7,27 @@ import ( ) //参数校验 -func (this *Api_Comp) Getlist_Check(session comm.IUserSession, req *pb.Equipment_GetList_Req) (result map[string]interface{}, code comm.ErrorCode) { +func (this *ApiComp) Getlist_Check(session comm.IUserSession, req *pb.Equipment_GetList_Req) (result map[string]interface{}, code comm.ErrorCode) { return } ///获取用户装备列表 -func (this *Api_Comp) Getlist(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_GetList_Req) (code pb.ErrorCode) { +func (this *ApiComp) Getlist(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_GetList_Req, resp *pb.Equipment_GetList_Resp) (code pb.ErrorCode) { var ( err error items []*pb.DB_Equipment ) - defer func() { - if code == pb.ErrorCode_Success { - session.SendMsg(string(this.module.GetType()), "", &pb.Equipment_GetList_Resp{Equipments: items}) - } - }() - if items, err = this.module.model_equipment_comp.Equipment_QueryUserEquipments(session.GetUserId()); err != nil { + // defer func() { + // if code == pb.ErrorCode_Success { + // session.SendMsg(string(this.module.GetType()), "", &pb.Equipment_GetList_Resp{Equipments: items}) + // } + // }() + if items, err = this.module.modelequipment.QueryUserEquipments(session.GetUserId()); err != nil { log.Errorf("QueryUserPackReq err:%v", err) code = pb.ErrorCode_CacheReadError return } + resp.Equipments = items return } diff --git a/modules/equipment/api_upgrade.go b/modules/equipment/api_upgrade.go index da605b8e7..6b98ff2cc 100644 --- a/modules/equipment/api_upgrade.go +++ b/modules/equipment/api_upgrade.go @@ -12,7 +12,7 @@ import ( ) //参数校验 -func (this *Api_Comp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment_Upgrade_Req) (result map[string]interface{}, code comm.ErrorCode) { +func (this *ApiComp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment_Upgrade_Req) (result map[string]interface{}, code comm.ErrorCode) { var ( err error conf *cfg.Game_equipData @@ -24,18 +24,18 @@ func (this *Api_Comp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment code.Code = pb.ErrorCode_ReqParameterError return } - if equipment, err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsById(session.GetUserId(), req.EquipmentId); err != nil { + if equipment, err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), req.EquipmentId); err != nil { log.Errorf("Equip_Check err:%v", err) code.Code = pb.ErrorCode_EquipmentOnFoundEquipment return } - if conf, err = this.module.configure_comp.GetEquipmentConfigureById(equipment.CId); err != nil { + if conf, err = this.module.configure.GetEquipmentConfigureById(equipment.CId); err != nil { log.Errorf("Equip_Check err:%v", err) code.Code = pb.ErrorCode_EquipmentOnFoundEquipment return } //找到下一个等级的相关配置 - if intensify, err = this.module.configure_comp.GetEquipmentIntensifyConfigureById(equipment.Lv); err != nil { + if intensify, err = this.module.configure.GetEquipmentIntensifyConfigureById(equipment.Lv); err != nil { log.Errorf("Equip_Check err:%v", err) code.Code = pb.ErrorCode_EquipmentLvlimitReached return @@ -49,7 +49,7 @@ func (this *Api_Comp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment } ///英雄挂在装备 -func (this *Api_Comp) Upgrade(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_Upgrade_Req) (code pb.ErrorCode) { +func (this *ApiComp) Upgrade(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_Upgrade_Req) (code pb.ErrorCode) { var ( err error conf *cfg.Game_equipData @@ -85,7 +85,7 @@ func (this *Api_Comp) Upgrade(session comm.IUserSession, agrs map[string]interfa //叠加装备 拆分处理 if equipment.IsInitialState && equipment.OverlayNum > 1 { equipment.OverlayNum-- - if err = this.module.model_equipment_comp.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{ + if err = this.module.modelequipment.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{ "overlayNum": equipment.OverlayNum, "heroId": "", }); err != nil { @@ -97,24 +97,24 @@ func (this *Api_Comp) Upgrade(session comm.IUserSession, agrs map[string]interfa equipment.Id = primitive.NewObjectID().Hex() equipment.IsInitialState = false equipment.OverlayNum = 1 - if err = this.module.model_equipment_comp.upgradeEquipment(equipment, conf, intensify); err != nil { + if err = this.module.modelequipment.upgradeEquipment(equipment, conf, intensify); err != nil { code = pb.ErrorCode_SystemError log.Errorf("Upgrade err:%v", err) return } - if err = this.module.model_equipment_comp.AddList(session.GetUserId(), equipment.Id, equipment); err != nil { + if err = this.module.modelequipment.AddList(session.GetUserId(), equipment.Id, equipment); err != nil { log.Errorf("Upgrade err:%v", err) code = pb.ErrorCode_SystemError return } } else { equipment.IsInitialState = false - if err = this.module.model_equipment_comp.upgradeEquipment(equipment, conf, intensify); err != nil { + if err = this.module.modelequipment.upgradeEquipment(equipment, conf, intensify); err != nil { code = pb.ErrorCode_SystemError log.Errorf("Upgrade err:%v", err) return } - if err = this.module.model_equipment_comp.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{ + if err = this.module.modelequipment.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{ "lv": equipment.Lv, "mainEntry": equipment.MainEntry, "adverbEntry": equipment.AdverbEntry, @@ -136,7 +136,7 @@ func (this *Api_Comp) Upgrade(session comm.IUserSession, agrs map[string]interfa for i, v := range hero.EquipID { if v != "" { if v != equipment.Id { - if equipments[i], err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsById(session.GetUserId(), v); err != nil { + if equipments[i], err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil { log.Errorf("Upgrade err:%v", err) code = pb.ErrorCode_EquipmentOnFoundEquipment return diff --git a/modules/equipment/configure_comp.go b/modules/equipment/configure.go similarity index 75% rename from modules/equipment/configure_comp.go rename to modules/equipment/configure.go index fc8e81615..19085ec81 100644 --- a/modules/equipment/configure_comp.go +++ b/modules/equipment/configure.go @@ -17,12 +17,12 @@ const ( ) ///背包配置管理组件 -type Configure_Comp struct { - modules.MComp_Configure +type ConfigureComp struct { + modules.MCompConfigure } //组件初始化接口 -func (this *Configure_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { +func (this *ConfigureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { this.ModuleCompBase.Init(service, module, comp, options) this.LoadConfigure(game_equip, cfg.NewGame_equip) this.LoadConfigure(equip_attrlibrary, cfg.NewGame_equipAttrlibrary) @@ -30,7 +30,7 @@ func (this *Configure_Comp) Init(service core.IService, module core.IModule, com } //获取装备配置数据 -func (this *Configure_Comp) GetEquipmentConfigure() (configure *cfg.Game_equip, err error) { +func (this *ConfigureComp) GetEquipmentConfigure() (configure *cfg.Game_equip, err error) { var ( v interface{} ok bool @@ -49,7 +49,7 @@ func (this *Configure_Comp) GetEquipmentConfigure() (configure *cfg.Game_equip, } //获取装备配置数据 -func (this *Configure_Comp) GetEquipmentConfigureById(equipmentId int32) (configure *cfg.Game_equipData, err error) { +func (this *ConfigureComp) GetEquipmentConfigureById(equipmentId int32) (configure *cfg.Game_equipData, err error) { var ( v interface{} ok bool @@ -68,7 +68,7 @@ func (this *Configure_Comp) GetEquipmentConfigureById(equipmentId int32) (config } //获取装备属性表 -func (this *Configure_Comp) GetEquipmentAttrlibraryConfigure() (configure *cfg.Game_equipAttrlibrary, err error) { +func (this *ConfigureComp) GetEquipmentAttrlibraryConfigure() (configure *cfg.Game_equipAttrlibrary, err error) { var ( v interface{} ok bool @@ -87,7 +87,7 @@ func (this *Configure_Comp) GetEquipmentAttrlibraryConfigure() (configure *cfg.G } //获取属性词列表 -func (this *Configure_Comp) GetEquipmentAttrlibraryConfigureByKey(key int32) (configure *cfg.Game_equipAttrlibraryData, err error) { +func (this *ConfigureComp) GetEquipmentAttrlibraryConfigureByKey(key int32) (configure *cfg.Game_equipAttrlibraryData, err error) { var ( v interface{} ok bool @@ -106,7 +106,7 @@ func (this *Configure_Comp) GetEquipmentAttrlibraryConfigureByKey(key int32) (co } //获取属性词列表 -func (this *Configure_Comp) GetEquipmentAttrlibraryConfigureById(Id int32) (configure []*cfg.Game_equipAttrlibraryData, err error) { +func (this *ConfigureComp) GetEquipmentAttrlibraryConfigureById(Id int32) (configure []*cfg.Game_equipAttrlibraryData, err error) { var ( v interface{} ) @@ -125,7 +125,7 @@ func (this *Configure_Comp) GetEquipmentAttrlibraryConfigureById(Id int32) (conf } //获取武器等级消耗表 -func (this *Configure_Comp) GetEquipmentIntensifyConfigure() (configure *cfg.Game_equipIntensify, err error) { +func (this *ConfigureComp) GetEquipmentIntensifyConfigure() (configure *cfg.Game_equipIntensify, err error) { var ( v interface{} ok bool @@ -144,7 +144,7 @@ func (this *Configure_Comp) GetEquipmentIntensifyConfigure() (configure *cfg.Gam } //获取武器等级消耗表 -func (this *Configure_Comp) GetEquipmentIntensifyConfigureById(Id int32) (configure *cfg.Game_equipIntensifyData, err error) { +func (this *ConfigureComp) GetEquipmentIntensifyConfigureById(Id int32) (configure *cfg.Game_equipIntensifyData, err error) { var ( v interface{} ok bool diff --git a/modules/equipment/model_equipment_comp.go b/modules/equipment/model_equipment.go similarity index 72% rename from modules/equipment/model_equipment_comp.go rename to modules/equipment/model_equipment.go index 92b0941ea..a7a911885 100644 --- a/modules/equipment/model_equipment_comp.go +++ b/modules/equipment/model_equipment.go @@ -15,14 +15,14 @@ import ( ) ///装备 数据组件 -type Model_Equipment_Comp struct { - modules.Model_Comp +type ModelEquipmentComp struct { + modules.MCompModel module *Equipment } //组件初始化接口 -func (this *Model_Equipment_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { - this.Model_Comp.Init(service, module, comp, opt) +func (this *ModelEquipmentComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { + this.MCompModel.Init(service, module, comp, opt) this.module = module.(*Equipment) this.TableName = "equipment" //创建uid索引 @@ -33,27 +33,27 @@ func (this *Model_Equipment_Comp) Init(service core.IService, module core.IModul } //查询用户装备数据 -func (this *Model_Equipment_Comp) Equipment_QueryUserEquipmentsById(uId, id string) (equipment *pb.DB_Equipment, err error) { +func (this *ModelEquipmentComp) QueryUserEquipmentsById(uId, id string) (equipment *pb.DB_Equipment, err error) { equipment = &pb.DB_Equipment{} err = this.GetListObj(uId, id, equipment) return } ///查询用户的武器背包 -func (this *Model_Equipment_Comp) Equipment_QueryUserEquipments(uId string) (equipments []*pb.DB_Equipment, err error) { +func (this *ModelEquipmentComp) QueryUserEquipments(uId string) (equipments []*pb.DB_Equipment, err error) { equipments = make([]*pb.DB_Equipment, 0) err = this.GetList(uId, &equipments) return } ///查询目标卡片数量 -func (this *Model_Equipment_Comp) QueryEquipmentAmount(uid string, equipmentId int32) (amount uint32) { +func (this *ModelEquipmentComp) QueryEquipmentAmount(uid string, equipmentId int32) (amount uint32) { var ( equipments []*pb.DB_Equipment err error ) amount = 0 - if equipments, err = this.Equipment_QueryUserEquipments(uid); err != nil { + if equipments, err = this.QueryUserEquipments(uid); err != nil { return } for _, v := range equipments { @@ -65,7 +65,7 @@ func (this *Model_Equipment_Comp) QueryEquipmentAmount(uid string, equipmentId i } //添加装备 -func (this *Model_Equipment_Comp) Equipment_AddEquipments(uId string, cIds map[int32]uint32) (err error) { +func (this *ModelEquipmentComp) AddEquipments(uId string, cIds map[int32]uint32) (err error) { var ( configure *cfg.Game_equip equipments []*pb.DB_Equipment @@ -73,10 +73,10 @@ func (this *Model_Equipment_Comp) Equipment_AddEquipments(uId string, cIds map[i add map[string]*pb.DB_Equipment update map[string]*pb.DB_Equipment ) - if configure, err = this.module.configure_comp.GetEquipmentConfigure(); err != nil { + if configure, err = this.module.configure.GetEquipmentConfigure(); err != nil { return } - if equipments, err = this.Equipment_QueryUserEquipments(uId); err != nil { + if equipments, err = this.QueryUserEquipments(uId); err != nil { return } add = make(map[string]*pb.DB_Equipment) @@ -115,7 +115,7 @@ func (this *Model_Equipment_Comp) Equipment_AddEquipments(uId string, cIds map[i } //更新武器挂载信息 -func (this *Model_Equipment_Comp) Equipment_UpdateByHeroId(uid string, equipments ...*pb.DB_Equipment) (err error) { +func (this *ModelEquipmentComp) UpdateByHeroId(uid string, equipments ...*pb.DB_Equipment) (err error) { for _, v := range equipments { if err = this.ChangeList(uid, v.Id, map[string]interface{}{ "heroId": v.HeroId, @@ -128,7 +128,7 @@ func (this *Model_Equipment_Comp) Equipment_UpdateByHeroId(uid string, equipment } //创建新的武器对象 -func (this *Model_Equipment_Comp) newEquipment(uid string, conf *cfg.Game_equipData, num uint32) (equipment *pb.DB_Equipment, err error) { +func (this *ModelEquipmentComp) newEquipment(uid string, conf *cfg.Game_equipData, num uint32) (equipment *pb.DB_Equipment, err error) { var ( mattr []*cfg.Game_equipAttrlibraryData sattr []*cfg.Game_equipAttrlibraryData @@ -144,7 +144,7 @@ func (this *Model_Equipment_Comp) newEquipment(uid string, conf *cfg.Game_equipD IsInitialState: true, AdverbEntry: make([]*pb.EquipmentAttributeEntry, 0), } - if mattr, err = this.module.configure_comp.GetEquipmentAttrlibraryConfigureById(conf.Leadlibrary); err != nil || len(mattr) == 0 { + if mattr, err = this.module.configure.GetEquipmentAttrlibraryConfigureById(conf.Leadlibrary); err != nil || len(mattr) == 0 { return } equipment.MainEntry = &pb.EquipmentAttributeEntry{ @@ -154,7 +154,7 @@ func (this *Model_Equipment_Comp) newEquipment(uid string, conf *cfg.Game_equipD AttrName: mattr[0].Attrkey, Value: mattr[0].Attrvar, } - if sattr, err = this.module.configure_comp.GetEquipmentAttrlibraryConfigureById(conf.Addlibrary); err != nil || len(mattr) == 0 { + if sattr, err = this.module.configure.GetEquipmentAttrlibraryConfigureById(conf.Addlibrary); err != nil || len(mattr) == 0 { return } @@ -184,7 +184,7 @@ func (this *Model_Equipment_Comp) newEquipment(uid string, conf *cfg.Game_equipD } //升级武器 -func (this *Model_Equipment_Comp) upgradeEquipment(equipment *pb.DB_Equipment, equip *cfg.Game_equipData, intensify *cfg.Game_equipIntensifyData) (err error) { +func (this *ModelEquipmentComp) upgradeEquipment(equipment *pb.DB_Equipment, equip *cfg.Game_equipData, intensify *cfg.Game_equipIntensifyData) (err error) { equipment.Lv++ equipment.MainEntry.Lv++ equipment.MainEntry.Value += equipment.MainEntry.Value * (intensify.Bonus / 1000.0) @@ -194,7 +194,7 @@ func (this *Model_Equipment_Comp) upgradeEquipment(equipment *pb.DB_Equipment, e if len(equipment.AdverbEntry) < 4 { //去随机副词条 var temp []*cfg.Game_equipAttrlibraryData var sattr []*cfg.Game_equipAttrlibraryData - if temp, err = this.module.configure_comp.GetEquipmentAttrlibraryConfigureById(equip.Addlibrary); err != nil || len(temp) == 0 { + if temp, err = this.module.configure.GetEquipmentAttrlibraryConfigureById(equip.Addlibrary); err != nil || len(temp) == 0 { log.Errorf("升级服务错误 读取副词条配置错误!") return } @@ -224,7 +224,7 @@ func (this *Model_Equipment_Comp) upgradeEquipment(equipment *pb.DB_Equipment, e r := rand.New(rand.NewSource(time.Now().Unix())) index := r.Perm(len(equipment.AdverbEntry))[0] - if attrlibrary, err = this.module.configure_comp.GetEquipmentAttrlibraryConfigureByKey(equipment.AdverbEntry[index].Id); err != nil { + if attrlibrary, err = this.module.configure.GetEquipmentAttrlibraryConfigureByKey(equipment.AdverbEntry[index].Id); err != nil { return } equipment.AdverbEntry[index].Value += attrlibrary.Addition[equipment.AdverbEntry[index].Lv-1] / 1000.0 * attrlibrary.Attrvar diff --git a/modules/equipment/module.go b/modules/equipment/module.go index dbacf2ca0..5bb3b92c7 100644 --- a/modules/equipment/module.go +++ b/modules/equipment/module.go @@ -22,11 +22,11 @@ func NewModule() core.IModule { type Equipment struct { modules.ModuleBase - service core.IService - api_comp *Api_Comp - configure_comp *Configure_Comp - model_equipment_comp *Model_Equipment_Comp - hero comm.IHero + service core.IService + api *ApiComp + configure *ConfigureComp + modelequipment *ModelEquipmentComp + hero comm.IHero } //模块名 @@ -56,16 +56,16 @@ func (this *Equipment) Start() (err error) { //装备组件 func (this *Equipment) OnInstallComp() { this.ModuleBase.OnInstallComp() - this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp) - this.model_equipment_comp = this.RegisterComp(new(Model_Equipment_Comp)).(*Model_Equipment_Comp) - this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp) + this.api = this.RegisterComp(new(ApiComp)).(*ApiComp) + this.modelequipment = this.RegisterComp(new(ModelEquipmentComp)).(*ModelEquipmentComp) + this.configure = this.RegisterComp(new(ConfigureComp)).(*ConfigureComp) } //IEquipment------------------------------------------------------------------------------------------------------------------------------- //查询武器信息 func (this *Equipment) QueryEquipment(source *comm.ModuleCallSource, uid string, Id string) (equipment *pb.DB_Equipment, code pb.ErrorCode) { var err error - if equipment, err = this.model_equipment_comp.Equipment_QueryUserEquipmentsById(uid, Id); err != nil { + if equipment, err = this.modelequipment.QueryUserEquipmentsById(uid, Id); err != nil { if err == redis.Nil { code = pb.ErrorCode_EquipmentOnFoundEquipment } else { @@ -77,14 +77,14 @@ func (this *Equipment) QueryEquipment(source *comm.ModuleCallSource, uid string, //查询卡片数量 func (this *Equipment) QueryEquipmentAmount(source *comm.ModuleCallSource, uid string, equipmentId int32) (amount uint32) { - amount = this.model_equipment_comp.QueryEquipmentAmount(uid, equipmentId) + amount = this.modelequipment.QueryEquipmentAmount(uid, equipmentId) return } //添加武器 func (this *Equipment) AddNewEquipments(source *comm.ModuleCallSource, uid string, cIds map[int32]uint32) (code pb.ErrorCode) { var err error - if err = this.model_equipment_comp.Equipment_AddEquipments(uid, cIds); err != nil { + if err = this.modelequipment.AddEquipments(uid, cIds); err != nil { log.Errorf("err%v", err) code = pb.ErrorCode_SystemError } diff --git a/modules/equipment/module_test.go b/modules/equipment/module_test.go index d30f57b02..811d65168 100644 --- a/modules/equipment/module_test.go +++ b/modules/equipment/module_test.go @@ -1,4 +1,4 @@ -package equipment +package equipment_test import ( "fmt" @@ -7,6 +7,7 @@ import ( "go_dreamfactory/lego/base/rpcx" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" + "go_dreamfactory/modules/equipment" "go_dreamfactory/modules/hero" "go_dreamfactory/services" "go_dreamfactory/sys/cache" @@ -50,7 +51,7 @@ func (this *TestService) InitSys() { var service core.IService var s_gateComp comm.ISC_GateRouteComp = services.NewGateRouteComp() -var module = new(Equipment) +var module = new(equipment.Equipment) //测试环境下初始化db和cache 系统 func TestMain(m *testing.M) { diff --git a/modules/game/module.go b/modules/game/module.go index 0d62a9443..54a4bf566 100644 --- a/modules/game/module.go +++ b/modules/game/module.go @@ -18,8 +18,8 @@ func NewModule() core.IModule { type Game struct { modules.ModuleBase - api_comp *Api_Comp - configure_comp *Configure_Comp + api *ApiComp + configure *ConfigureComp } //模块名 @@ -36,6 +36,6 @@ func (this *Game) Init(service core.IService, module core.IModule, options core. //装备组件 func (this *Game) OnInstallComp() { this.ModuleBase.OnInstallComp() - this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp) - this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp) + this.api = this.RegisterComp(new(ApiComp)).(*ApiComp) + this.configure = this.RegisterComp(new(ConfigureComp)).(*ConfigureComp) } diff --git a/modules/gateway/agentmgr_comp.go b/modules/gateway/agentmgr_comp.go index 56c73e7b0..d9c22f9c3 100644 --- a/modules/gateway/agentmgr_comp.go +++ b/modules/gateway/agentmgr_comp.go @@ -16,13 +16,13 @@ import ( /* 用户代理对象管理组件 */ -type AgentMgr_Comp struct { +type AgentMgrComp struct { cbase.ModuleCompBase service base.IRPCXService agents *sync.Map } -func (this *AgentMgr_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { +func (this *AgentMgrComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { err = this.ModuleCompBase.Init(service, module, comp, options) this.service = service.(base.IRPCXService) this.agents = new(sync.Map) @@ -30,12 +30,12 @@ func (this *AgentMgr_Comp) Init(service core.IService, module core.IModule, comp } //加入新的用户 -func (this *AgentMgr_Comp) Connect(a IAgent) { +func (this *AgentMgrComp) Connect(a IAgent) { this.agents.Store(a.SessionId(), a) } //移除断开的用户 -func (this *AgentMgr_Comp) DisConnect(a IAgent) { +func (this *AgentMgrComp) DisConnect(a IAgent) { this.agents.Delete(a.SessionId()) if a.UserId() != "" { //登录用户 通知业务服务处理玩家离线相关 reply := &pb.RPCMessageReply{} @@ -48,7 +48,7 @@ func (this *AgentMgr_Comp) DisConnect(a IAgent) { } //用户登录绑定Id -func (this *AgentMgr_Comp) Bind(ctx context.Context, args *pb.AgentBuildReq, reply *pb.RPCMessageReply) error { +func (this *AgentMgrComp) Bind(ctx context.Context, args *pb.AgentBuildReq, reply *pb.RPCMessageReply) error { if a, ok := this.agents.Load(args.UserSessionId); ok { a.(IAgent).Bind(args.UserId, args.WorkerId) } else { @@ -59,7 +59,7 @@ func (this *AgentMgr_Comp) Bind(ctx context.Context, args *pb.AgentBuildReq, rep } //用户登录解绑Id -func (this *AgentMgr_Comp) UnBind(ctx context.Context, args *pb.AgentUnBuildReq, reply *pb.RPCMessageReply) error { +func (this *AgentMgrComp) UnBind(ctx context.Context, args *pb.AgentUnBuildReq, reply *pb.RPCMessageReply) error { if a, ok := this.agents.Load(args.UserSessionId); ok { a.(IAgent).UnBind() } else { @@ -70,7 +70,7 @@ func (this *AgentMgr_Comp) UnBind(ctx context.Context, args *pb.AgentUnBuildReq, } //向用户发送消息 -func (this *AgentMgr_Comp) SendMsgToAgent(ctx context.Context, args *pb.AgentSendMessageReq, reply *pb.RPCMessageReply) error { +func (this *AgentMgrComp) SendMsgToAgent(ctx context.Context, args *pb.AgentSendMessageReq, reply *pb.RPCMessageReply) error { if a, ok := this.agents.Load(args.UserSessionId); ok { a.(IAgent).WriteMsg(&pb.UserMessage{ MainType: args.MainType, @@ -85,7 +85,7 @@ func (this *AgentMgr_Comp) SendMsgToAgent(ctx context.Context, args *pb.AgentSen } //向多个户发送消息 -func (this *AgentMgr_Comp) SendMsgToAgents(ctx context.Context, args *pb.BatchMessageReq, reply *pb.RPCMessageReply) error { +func (this *AgentMgrComp) SendMsgToAgents(ctx context.Context, args *pb.BatchMessageReq, reply *pb.RPCMessageReply) error { msg := &pb.UserMessage{ MainType: args.MainType, SubType: args.SubType, @@ -100,7 +100,7 @@ func (this *AgentMgr_Comp) SendMsgToAgents(ctx context.Context, args *pb.BatchMe } //向所有户发送消息 -func (this *AgentMgr_Comp) SendMsgToAllAgent(ctx context.Context, args *pb.BroadCastMessageReq, reply *pb.RPCMessageReply) error { +func (this *AgentMgrComp) SendMsgToAllAgent(ctx context.Context, args *pb.BroadCastMessageReq, reply *pb.RPCMessageReply) error { msg := &pb.UserMessage{ MainType: args.MainType, SubType: args.SubType, @@ -114,7 +114,7 @@ func (this *AgentMgr_Comp) SendMsgToAllAgent(ctx context.Context, args *pb.Broad } //关闭代理 -func (this *AgentMgr_Comp) CloseAgent(ctx context.Context, args *pb.AgentCloseeReq, reply *pb.RPCMessageReply) error { +func (this *AgentMgrComp) CloseAgent(ctx context.Context, args *pb.AgentCloseeReq, reply *pb.RPCMessageReply) error { if a, ok := this.agents.Load(args.UserSessionId); ok { a.(IAgent).Close() } else { diff --git a/modules/gateway/module.go b/modules/gateway/module.go index ec6f45569..b2c452f95 100644 --- a/modules/gateway/module.go +++ b/modules/gateway/module.go @@ -21,10 +21,10 @@ func NewModule() core.IModule { type Gateway struct { modules.ModuleBase - service base.IRPCXService - wsservice_comp *WSService_Comp //websocket 服务组件 提供websocket服务监听 - agentmgr_comp *AgentMgr_Comp //用户代理对象管理组件 管理用户socekt对象 - configure_comp *Configure_Comp + service base.IRPCXService + wsservice *WSServiceComp //websocket 服务组件 提供websocket服务监听 + agentmgr *AgentMgrComp //用户代理对象管理组件 管理用户socekt对象 + configure *ConfigureComp } //模块名 @@ -52,17 +52,17 @@ func (this *Gateway) Init(service core.IService, module core.IModule, options co //模块启动函数 注册rpc服务接口提供用户相关的rpc接口服务 func (this *Gateway) Start() (err error) { //注册用户绑定uid接口 登录成功后触发 - this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentBind), this.agentmgr_comp.Bind) + this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentBind), this.agentmgr.Bind) //注册用户解绑uid接口 登出或则切换账号是触发 - this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentUnBind), this.agentmgr_comp.UnBind) + this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentUnBind), this.agentmgr.UnBind) //向用户发送消息接口 - this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentSendMsg), this.agentmgr_comp.SendMsgToAgent) + this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentSendMsg), this.agentmgr.SendMsgToAgent) //向多个用户对象发送消息接口 - this.service.RegisterFunctionName(string(comm.Rpc_GatewaySendBatchMsg), this.agentmgr_comp.SendMsgToAgents) + this.service.RegisterFunctionName(string(comm.Rpc_GatewaySendBatchMsg), this.agentmgr.SendMsgToAgents) //向所有用户发送消息接口 - this.service.RegisterFunctionName(string(comm.Rpc_GatewaySendRadioMsg), this.agentmgr_comp.SendMsgToAllAgent) + this.service.RegisterFunctionName(string(comm.Rpc_GatewaySendRadioMsg), this.agentmgr.SendMsgToAllAgent) //关闭用户socket连接接口 - this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentClose), this.agentmgr_comp.CloseAgent) + this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentClose), this.agentmgr.CloseAgent) err = this.ModuleBase.Start() return } @@ -70,24 +70,24 @@ func (this *Gateway) Start() (err error) { //装备组件 func (this *Gateway) OnInstallComp() { this.ModuleBase.OnInstallComp() - this.agentmgr_comp = this.RegisterComp(new(AgentMgr_Comp)).(*AgentMgr_Comp) - this.wsservice_comp = this.RegisterComp(new(WSService_Comp)).(*WSService_Comp) - this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp) + this.agentmgr = this.RegisterComp(new(AgentMgrComp)).(*AgentMgrComp) + this.wsservice = this.RegisterComp(new(WSServiceComp)).(*WSServiceComp) + this.configure = this.RegisterComp(new(ConfigureComp)).(*ConfigureComp) } //有新的连接对象进入 func (this *Gateway) Connect(a IAgent) { log.Debugf("[Module.Gateway] have new connect:Ip[%s] SessionId:[%s]", a.IP(), a.SessionId()) - this.agentmgr_comp.Connect(a) + this.agentmgr.Connect(a) } //有用户断开连接 func (this *Gateway) DisConnect(a IAgent) { log.Debugf("[Module.Gateway] have disConnect:Ip[%s] SessionId:[%s] uid:[%s]", a.IP(), a.SessionId(), a.UserId()) - this.agentmgr_comp.DisConnect(a) + this.agentmgr.DisConnect(a) } //读取消息分发规则 func (this *Gateway) GetMsgDistribRule(mtype, stype string) (rule string, ok bool) { - return this.configure_comp.GetMsgDistribRule(mtype, stype) + return this.configure.GetMsgDistribRule(mtype, stype) } diff --git a/modules/gateway/wservice_comp.go b/modules/gateway/wservice_comp.go index be7304e2a..0a75bd650 100644 --- a/modules/gateway/wservice_comp.go +++ b/modules/gateway/wservice_comp.go @@ -12,7 +12,7 @@ import ( "github.com/gorilla/websocket" ) -type WSService_Comp struct { +type WSServiceComp struct { cbase.ModuleCompBase options *Options @@ -20,7 +20,7 @@ type WSService_Comp struct { gin gin.ISys } -func (this *WSService_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { +func (this *WSServiceComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { err = this.ModuleCompBase.Init(service, module, comp, options) this.options = options.(*Options) this.module = module.(IGateway) @@ -29,7 +29,7 @@ func (this *WSService_Comp) Init(service core.IService, module core.IModule, com return } -func (this *WSService_Comp) ws(c *engine.Context) { +func (this *WSServiceComp) ws(c *engine.Context) { upGrader := websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool { return true diff --git a/modules/items/api.go b/modules/items/api.go index 6ceb880fe..47aca6bf4 100644 --- a/modules/items/api.go +++ b/modules/items/api.go @@ -15,21 +15,21 @@ const ( //消息回复的头名称 /* 背包 处理用户的请求组件 必须继承 modules.MComp_GateComp */ -type Api_Comp struct { - modules.MComp_GateComp +type apiComp struct { + modules.MCompGate service core.IService module *Items } //组件初始化接口 -func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - this.MComp_GateComp.Init(service, module, comp, options) +func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.MCompGate.Init(service, module, comp, options) this.module = module.(*Items) this.service = service return } -func (this *Api_Comp) Start() (err error) { - err = this.MComp_GateComp.Start() +func (this *apiComp) Start() (err error) { + err = this.MCompGate.Start() return } diff --git a/modules/items/api_getlist.go b/modules/items/api_getlist.go index 22fdc282a..12d5d6a9a 100644 --- a/modules/items/api_getlist.go +++ b/modules/items/api_getlist.go @@ -8,13 +8,13 @@ import ( ) //参数校验 -func (this *Api_Comp) Getlist_Check(session comm.IUserSession, req *pb.Items_Getlist_Req) (result map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) Getlist_Check(session comm.IUserSession, req *pb.Items_Getlist_Req) (result map[string]interface{}, code comm.ErrorCode) { result = map[string]interface{}{"ce": 123} return } ///获取用户道具 -func (this *Api_Comp) Getlist(session comm.IUserSession, agrs map[string]interface{}, req *pb.Items_Getlist_Req) (code pb.ErrorCode) { +func (this *apiComp) Getlist(session comm.IUserSession, agrs map[string]interface{}, req *pb.Items_Getlist_Req) (code pb.ErrorCode) { var ( err error items []*pb.DB_UserItemData @@ -28,18 +28,18 @@ func (this *Api_Comp) Getlist(session comm.IUserSession, agrs map[string]interfa session.SendMsg(string(this.module.GetType()), GetlistResp, &pb.Items_Getlist_Resp{Grids: grids}) if code == pb.ErrorCode_Success { go func() { //异步处理修改数据 - this.module.model_pack_comp.Pack_UpdateUserPack(session.GetUserId(), modifys...) - this.module.model_pack_comp.Pack_DeleteUserPack(session.GetUserId(), dels...) + this.module.modelItems.Pack_UpdateUserPack(session.GetUserId(), modifys...) + this.module.modelItems.Pack_DeleteUserPack(session.GetUserId(), dels...) }() } }() - if items, err = this.module.model_pack_comp.Pack_QueryUserPack(session.GetUserId()); err != nil { + if items, err = this.module.modelItems.Pack_QueryUserPack(session.GetUserId()); err != nil { log.Errorf("QueryUserPackReq err:%v", err) code = pb.ErrorCode_CacheReadError return } else { - tempgrids = this.module.configure_comp.GetPackItemByType(items, req.IType) + tempgrids = this.module.configure.GetPackItemByType(items, req.IType) modifys = make([]*pb.DB_UserItemData, 0, len(tempgrids)) dels = make([]string, 0, len(tempgrids)) grids = make([]*pb.DB_UserItemData, 0, len(grids)) diff --git a/modules/items/api_sellItem.go b/modules/items/api_sellItem.go index 4b803e69f..84310d85f 100644 --- a/modules/items/api_sellItem.go +++ b/modules/items/api_sellItem.go @@ -6,13 +6,13 @@ import ( ) //参数校验 -func (this *Api_Comp) SellItem_Check(session comm.IUserSession, req *pb.Items_SellItem_Req) (result map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) SellItem_Check(session comm.IUserSession, req *pb.Items_SellItem_Req) (result map[string]interface{}, code comm.ErrorCode) { return } //出售道具 -func (this *Api_Comp) SellItem(session comm.IUserSession, agrs map[string]interface{}, req *pb.Items_SellItem_Req) (code pb.ErrorCode) { +func (this *apiComp) SellItem(session comm.IUserSession, agrs map[string]interface{}, req *pb.Items_SellItem_Req) (code pb.ErrorCode) { defer func() { session.SendMsg(string(this.module.GetType()), SellItemResp, &pb.Items_SellItem_Resp{}) }() diff --git a/modules/items/api_useItem.go b/modules/items/api_useItem.go index 59cfc9113..828bf9d41 100644 --- a/modules/items/api_useItem.go +++ b/modules/items/api_useItem.go @@ -6,13 +6,13 @@ import ( ) //参数校验 -func (this *Api_Comp) Useitem_Check(session comm.IUserSession, req *pb.Items_UseItem_Req) (result map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) Useitem_Check(session comm.IUserSession, req *pb.Items_UseItem_Req) (result map[string]interface{}, code comm.ErrorCode) { return } //使用道具 -func (this *Api_Comp) Useitem(session comm.IUserSession, agrs map[string]interface{}, req *pb.Items_UseItem_Req) (code pb.ErrorCode) { +func (this *apiComp) Useitem(session comm.IUserSession, agrs map[string]interface{}, req *pb.Items_UseItem_Req) (code pb.ErrorCode) { defer func() { session.SendMsg(string(this.module.GetType()), UseItemResp, &pb.Items_UseItem_Resp{}) }() diff --git a/modules/items/configure_comp.go b/modules/items/configure.go similarity index 75% rename from modules/items/configure_comp.go rename to modules/items/configure.go index 147e9c006..a7b7fe730 100644 --- a/modules/items/configure_comp.go +++ b/modules/items/configure.go @@ -15,19 +15,19 @@ const ( ) ///背包配置管理组件 -type Configure_Comp struct { - modules.MComp_Configure +type ConfigureComp struct { + modules.MCompConfigure } //组件初始化接口 -func (this *Configure_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { +func (this *ConfigureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { this.ModuleCompBase.Init(service, module, comp, options) this.LoadConfigure(game_item, cfg.NewGame_item) return } //读取物品配置 -func (this *Configure_Comp) GetItemConfigure(id int32) (item *cfg.Game_itemData, err error) { +func (this *ConfigureComp) GetItemConfigure(id int32) (item *cfg.Game_itemData, err error) { var ( v interface{} ok bool @@ -44,7 +44,7 @@ func (this *Configure_Comp) GetItemConfigure(id int32) (item *cfg.Game_itemData, } //获取指定类型的物品列表 -func (this *Configure_Comp) GetPackItemByType(itmes []*pb.DB_UserItemData, usetype int32) (result []*pb.DB_UserItemData) { +func (this *ConfigureComp) GetPackItemByType(itmes []*pb.DB_UserItemData, usetype int32) (result []*pb.DB_UserItemData) { result = make([]*pb.DB_UserItemData, 0, len(itmes)) var ( v interface{} diff --git a/modules/items/model_pack_comp.go b/modules/items/modelitems.go similarity index 80% rename from modules/items/model_pack_comp.go rename to modules/items/modelitems.go index 982f8170e..b33c6951f 100644 --- a/modules/items/model_pack_comp.go +++ b/modules/items/modelitems.go @@ -12,14 +12,14 @@ import ( ) ///背包缓存数据管理组件 -type Model_Pack_Comp struct { - modules.Model_Comp +type ModelItemsComp struct { + modules.MCompModel module *Items } //组件初始化接口 -func (this *Model_Pack_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { - this.Model_Comp.Init(service, module, comp, opt) +func (this *ModelItemsComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { + this.MCompModel.Init(service, module, comp, opt) this.module = module.(*Items) this.TableName = "items" //创建uid索引 @@ -30,21 +30,21 @@ func (this *Model_Pack_Comp) Init(service core.IService, module core.IModule, co } ///查询用户背包数据 -func (this *Model_Pack_Comp) Pack_QueryUserPack(uId string) (itmes []*pb.DB_UserItemData, err error) { +func (this *ModelItemsComp) Pack_QueryUserPack(uId string) (itmes []*pb.DB_UserItemData, err error) { itmes = make([]*pb.DB_UserItemData, 0) err = this.GetList(uId, &itmes) return } ///查询用户指定格子的物品数据 -func (this *Model_Pack_Comp) Pack_QueryUserPackByGridId(uId string, grid string) (itme *pb.DB_UserItemData, err error) { +func (this *ModelItemsComp) Pack_QueryUserPackByGridId(uId string, grid string) (itme *pb.DB_UserItemData, err error) { itme = &pb.DB_UserItemData{} err = this.GetListObj(uId, grid, itme) return } //更新用户的背包信息 -func (this *Model_Pack_Comp) Pack_AddUserPack(uId string, itmes ...*pb.DB_UserItemData) (err error) { +func (this *ModelItemsComp) Pack_AddUserPack(uId string, itmes ...*pb.DB_UserItemData) (err error) { for _, v := range itmes { this.AddList(uId, v.GridId, v) } @@ -52,13 +52,13 @@ func (this *Model_Pack_Comp) Pack_AddUserPack(uId string, itmes ...*pb.DB_UserIt } //更新用户的背包信息 -func (this *Model_Pack_Comp) Pack_DelUserPack(uId string, ids ...string) (err error) { +func (this *ModelItemsComp) Pack_DelUserPack(uId string, ids ...string) (err error) { err = this.DelListlds(uId, ids...) return } //更新用户的背包信息 -func (this *Model_Pack_Comp) Pack_UpdateUserPack(uId string, itmes ...*pb.DB_UserItemData) (err error) { +func (this *ModelItemsComp) Pack_UpdateUserPack(uId string, itmes ...*pb.DB_UserItemData) (err error) { for _, v := range itmes { this.ChangeList(uId, v.GridId, map[string]interface{}{ "amount": v.Amount, @@ -68,13 +68,13 @@ func (this *Model_Pack_Comp) Pack_UpdateUserPack(uId string, itmes ...*pb.DB_Use } //更新用户的背包信息 -func (this *Model_Pack_Comp) Pack_DeleteUserPack(uId string, gridIds ...string) (err error) { +func (this *ModelItemsComp) Pack_DeleteUserPack(uId string, gridIds ...string) (err error) { err = this.DelListlds(uId, gridIds...) return } //查询用户背包物品数量 -func (this *Model_Pack_Comp) Pack_QueryUserPackItemsAmount(uId string, itemid ...int32) (result map[int32]uint32) { +func (this *ModelItemsComp) Pack_QueryUserPackItemsAmount(uId string, itemid ...int32) (result map[int32]uint32) { var ( itmes []*pb.DB_UserItemData err error @@ -94,7 +94,7 @@ func (this *Model_Pack_Comp) Pack_QueryUserPackItemsAmount(uId string, itemid .. } ///添加或则减少物品到用户背包 -func (this *Model_Pack_Comp) Pack_AddItemToUserPack(uId string, itemId int32, addnum int32) (err error) { +func (this *ModelItemsComp) Pack_AddItemToUserPack(uId string, itemId int32, addnum int32) (err error) { var ( itmes []*pb.DB_UserItemData add []*pb.DB_UserItemData @@ -136,7 +136,7 @@ func (this *Model_Pack_Comp) Pack_AddItemToUserPack(uId string, itemId int32, ad } ///添加或则减少多个物品到用户背包 -func (this *Model_Pack_Comp) Pack_AddItemsToUserPack(uId string, items map[int32]int32) (err error) { +func (this *ModelItemsComp) Pack_AddItemsToUserPack(uId string, items map[int32]int32) (err error) { var ( itmes []*pb.DB_UserItemData add []*pb.DB_UserItemData @@ -176,7 +176,7 @@ func (this *Model_Pack_Comp) Pack_AddItemsToUserPack(uId string, items map[int32 } ///修改指定格子的物品数量 -func (this *Model_Pack_Comp) Pack_AddItemToUserPackByGrid(uId string, gridid string, itemId int32, addnum int32) (err error) { +func (this *ModelItemsComp) Pack_AddItemToUserPackByGrid(uId string, gridid string, itemId int32, addnum int32) (err error) { var ( itme *pb.DB_UserItemData grid *pb.DB_UserItemData @@ -211,7 +211,7 @@ func (this *Model_Pack_Comp) Pack_AddItemToUserPackByGrid(uId string, gridid str } ///添加移除物品到用户背包 -func (this *Model_Pack_Comp) pack_addItemToUserPack(items []*pb.DB_UserItemData, itemId int32, addnum int32) (add, update []*pb.DB_UserItemData, del []string, leftnum int64) { +func (this *ModelItemsComp) pack_addItemToUserPack(items []*pb.DB_UserItemData, itemId int32, addnum int32) (add, update []*pb.DB_UserItemData, del []string, leftnum int64) { var ( num int64 isNew bool diff --git a/modules/items/module.go b/modules/items/module.go index 8c95f3ab5..af4122aa2 100644 --- a/modules/items/module.go +++ b/modules/items/module.go @@ -21,10 +21,9 @@ func NewModule() core.IModule { type Items struct { modules.ModuleBase - api_comp *Api_Comp - model_pack_comp *Model_Pack_Comp - // db_comp *DB_Comp - configure_comp *Configure_Comp + api *apiComp + modelItems *ModelItemsComp + configure *ConfigureComp } //模块名称 @@ -41,9 +40,9 @@ func (this *Items) Init(service core.IService, module core.IModule, options core //装备组件 func (this *Items) OnInstallComp() { this.ModuleBase.OnInstallComp() - this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp) - this.model_pack_comp = this.RegisterComp(new(Model_Pack_Comp)).(*Model_Pack_Comp) - this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp) + this.api = this.RegisterComp(new(apiComp)).(*apiComp) + this.modelItems = this.RegisterComp(new(ModelItemsComp)).(*ModelItemsComp) + this.configure = this.RegisterComp(new(ConfigureComp)).(*ConfigureComp) } //IItems------------------------------------------------------------------------------------------------------------------------------- @@ -51,7 +50,7 @@ func (this *Items) OnInstallComp() { func (this *Items) QueryItemAmount(source *comm.ModuleCallSource, uId string, itemid int32) (amount uint32) { defer log.Debugf("获取物品 uId:%s itemid:%d addnum:%d ", uId, itemid, amount) amount = 0 - if result := this.model_pack_comp.Pack_QueryUserPackItemsAmount(uId, itemid); result != nil && len(result) > 0 { + if result := this.modelItems.Pack_QueryUserPackItemsAmount(uId, itemid); result != nil && len(result) > 0 { return result[itemid] } return @@ -59,7 +58,7 @@ func (this *Items) QueryItemAmount(source *comm.ModuleCallSource, uId string, it ///查询用户背包多个物品数量 func (this *Items) QueryItemsAmount(source *comm.ModuleCallSource, uId string, itemid ...int32) (result map[int32]uint32) { - result = this.model_pack_comp.Pack_QueryUserPackItemsAmount(uId, itemid...) + result = this.modelItems.Pack_QueryUserPackItemsAmount(uId, itemid...) return } @@ -67,7 +66,7 @@ func (this *Items) QueryItemsAmount(source *comm.ModuleCallSource, uId string, i func (this *Items) AddItem(source *comm.ModuleCallSource, uId string, itemid, addnum int32) (code pb.ErrorCode) { var err error defer log.Debugf("给用户添加物品 uId:%s itemid:%d addnum:%d issucc:%v", uId, itemid, addnum, err == nil) - if err = this.model_pack_comp.Pack_AddItemToUserPack(uId, itemid, addnum); err != nil { + if err = this.modelItems.Pack_AddItemToUserPack(uId, itemid, addnum); err != nil { log.Errorf("给用户添加物品 uId:%s itemid:%d addnum:%d err:%v", uId, itemid, addnum, err) if err == ItemNotEnoughError { code = pb.ErrorCode_ItemsNoEnough @@ -84,7 +83,7 @@ func (this *Items) AddItem(source *comm.ModuleCallSource, uId string, itemid, ad func (this *Items) AddItems(source *comm.ModuleCallSource, uId string, items map[int32]int32) (code pb.ErrorCode) { var err error defer log.Debugf("给用户添加物品 uId:%s items:%d items:%v", uId, items, err == nil) - if err = this.model_pack_comp.Pack_AddItemsToUserPack(uId, items); err != nil { + if err = this.modelItems.Pack_AddItemsToUserPack(uId, items); err != nil { log.Errorf("给用户添加物品 uId:%s items:%d err:%v", uId, items, err) if err == ItemNotEnoughError { code = pb.ErrorCode_ItemsNoEnough diff --git a/modules/items/module_test.go b/modules/items/module_test.go index c7ded52de..0b774f5e5 100644 --- a/modules/items/module_test.go +++ b/modules/items/module_test.go @@ -1,4 +1,4 @@ -package items +package items_test import ( "context" @@ -8,6 +8,7 @@ import ( "go_dreamfactory/lego/base/rpcx" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" + "go_dreamfactory/modules/items" "go_dreamfactory/pb" "go_dreamfactory/services" "go_dreamfactory/sys/cache" @@ -53,7 +54,7 @@ func (this *TestService) InitSys() { var service core.IService var s_gateComp comm.ISC_GateRouteComp = services.NewGateRouteComp() -var module = new(Items) +var module = new(items.Items) //测试环境下初始化db和cache 系统 func TestMain(m *testing.M) { diff --git a/pb/proto/comm.proto b/pb/proto/comm.proto index a04259393..36eb64791 100644 --- a/pb/proto/comm.proto +++ b/pb/proto/comm.proto @@ -25,8 +25,9 @@ message AgentMessage { // RPC 服务固定回复结构 message RPCMessageReply { ErrorCode Code = 1; - string Message = 2; - string Data = 3; + string ErrorMessage = 2; + string ErrorData = 3; + UserMessage Reply = 4; } //用户代理绑定Uid请求 diff --git a/services/comp_gateroute.go b/services/comp_gateroute.go index 8d3a0f969..d6d9287ff 100644 --- a/services/comp_gateroute.go +++ b/services/comp_gateroute.go @@ -27,7 +27,7 @@ import ( */ func NewGateRouteComp() comm.ISC_GateRouteComp { - comp := new(SComp_GateRouteComp) + comp := new(SCompGateRoute) return comp } @@ -39,7 +39,7 @@ type msghandle struct { } //服务网关组件 -type SComp_GateRouteComp struct { +type SCompGateRoute struct { cbase.ServiceCompBase service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口 mrlock sync.RWMutex //msghandles 对象的锁 @@ -48,12 +48,12 @@ type SComp_GateRouteComp struct { } //设置服务组件名称 方便业务模块中获取此组件对象 -func (this *SComp_GateRouteComp) GetName() core.S_Comps { +func (this *SCompGateRoute) GetName() core.S_Comps { return comm.SC_ServiceGateRouteComp } //组件初始化函数 -func (this *SComp_GateRouteComp) Init(service core.IService, comp core.IServiceComp, options core.ICompOptions) (err error) { +func (this *SCompGateRoute) Init(service core.IService, comp core.IServiceComp, options core.ICompOptions) (err error) { err = this.ServiceCompBase.Init(service, comp, options) this.service = service.(base.IRPCXService) this.msgcheck = make(map[string]*msghandle) @@ -62,7 +62,7 @@ func (this *SComp_GateRouteComp) Init(service core.IService, comp core.IServiceC } // //组件启动时注册rpc服务监听 -func (this *SComp_GateRouteComp) Start() (err error) { +func (this *SCompGateRoute) Start() (err error) { this.service.RegisterFunctionName(string(comm.Rpc_GatewayRoute), this.ReceiveMsg) //注册网关路由接收接口 this.service.RegisterFunctionName(string(comm.Rpc_NoticeUserClose), this.NoticeUserClose) //注册用户离线通知 err = this.ServiceCompBase.Start() @@ -84,7 +84,7 @@ func (this *SComp_GateRouteComp) Start() (err error) { } //业务模块注册用户消息处理路由 -func (this *SComp_GateRouteComp) RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, fn reflect.Method) { +func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, fn reflect.Method) { log.Debugf("注册用户路由【%s】", methodName) this.mrlock.RLock() _, ok := this.msghandles[methodName] @@ -103,7 +103,7 @@ func (this *SComp_GateRouteComp) RegisterRoute(methodName string, comp reflect.V } //业务模块注册用户消息处理路由 -func (this *SComp_GateRouteComp) RegisterRouteCheck(methodName string, comp reflect.Value, msg reflect.Type, fn reflect.Method) { +func (this *SCompGateRoute) RegisterRouteCheck(methodName string, comp reflect.Value, msg reflect.Type, fn reflect.Method) { log.Debugf("注册用户路由校验[%s]", methodName) this.mrlock.RLock() _, ok := this.msgcheck[methodName] @@ -122,7 +122,7 @@ func (this *SComp_GateRouteComp) RegisterRouteCheck(methodName string, comp refl } //Rpc_GatewayRoute服务接口的接收函数 -func (this *SComp_GateRouteComp) ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) error { +func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) error { defer func() { //程序异常 收集异常信息传递给前端显示 if r := recover(); r != nil { buf := make([]byte, 1024) @@ -132,7 +132,7 @@ func (this *SComp_GateRouteComp) ReceiveMsg(ctx context.Context, args *pb.AgentM log.Errorf("HandleUserMsg:%s err:%s", args.Method, reply.Message) } }() - log.Debugf("SComp_GateRouteComp ReceiveMsg agent:%s uId:%s MessageDistribution msg:%s", args.UserSessionId, args.UserId, args.Method) + log.Debugf("SCompGateRoute ReceiveMsg agent:%s uId:%s MessageDistribution msg:%s", args.UserSessionId, args.UserId, args.Method) //获取用户消息处理函数 this.mrlock.RLock() msghandle, ok := this.msghandles[args.Method] @@ -184,7 +184,7 @@ func (this *SComp_GateRouteComp) ReceiveMsg(ctx context.Context, args *pb.AgentM } //RPC_NoticeUserClose 接收用户离线通知 -func (this *SComp_GateRouteComp) NoticeUserClose(ctx context.Context, args *pb.NoticeUserCloseReq, reply *pb.RPCMessageReply) error { +func (this *SCompGateRoute) NoticeUserClose(ctx context.Context, args *pb.NoticeUserCloseReq, reply *pb.RPCMessageReply) error { event.TriggerEvent(comm.Event_UserOffline, args.UserId) return nil } From 6098f3edda48b8e439dbc7e3fd7acfac78b252bd Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 28 Jun 2022 15:43:02 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/core.go | 5 +- modules/comp_gate.go | 65 ++++++---- modules/comp_model.go | 2 +- modules/equipment/api.go | 6 +- modules/equipment/api_equip.go | 12 +- modules/equipment/api_getlist.go | 6 +- modules/equipment/api_upgrade.go | 18 +-- modules/equipment/configure.go | 18 +-- modules/equipment/model_equipment.go | 18 +-- modules/equipment/module.go | 18 +-- modules/forum/api.go | 12 +- modules/forum/configure_comp.go | 6 +- modules/forum/model_forum_comp.go | 8 +- modules/forum/module.go | 12 +- modules/friend/api.go | 4 +- modules/friend/model_friend.go | 4 +- modules/gateway/agent.go | 3 +- modules/gateway/agentmgr_comp.go | 8 +- modules/hero/api.go | 6 +- modules/hero/configure_comp.go | 4 +- modules/hero/model_hero.go | 4 +- modules/items/module_test.go | 2 +- modules/mail/api.go | 6 +- modules/mail/module.go | 2 +- modules/modulebase.go | 4 - modules/user/api.go | 6 +- modules/user/model_session.go | 4 +- modules/user/model_user.go | 4 +- pb/comm.pb.go | 177 +++++++++++++++------------ pb/proto/comm.proto | 5 +- services/comp_gateroute.go | 84 +++++-------- 31 files changed, 269 insertions(+), 264 deletions(-) diff --git a/comm/core.go b/comm/core.go index b6827eac9..45f6a3849 100644 --- a/comm/core.go +++ b/comm/core.go @@ -16,8 +16,7 @@ import ( type ISC_GateRouteComp interface { core.IServiceComp ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) error - RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, fn reflect.Method) - RegisterRouteCheck(methodName string, comp reflect.Value, msg reflect.Type, fn reflect.Method) + RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, reply reflect.Type, check, handle reflect.Method) } //游戏类资源类型 @@ -35,8 +34,6 @@ type Autogenerated struct { D []interface{} } - - const ( HeroStarLvRatio int32 = 10 // 卡牌等级上限系数(星级*10) ) diff --git a/modules/comp_gate.go b/modules/comp_gate.go index e2a0bc3e6..883fdf33d 100644 --- a/modules/comp_gate.go +++ b/modules/comp_gate.go @@ -4,6 +4,7 @@ import ( "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" + "log" "reflect" "strings" "unicode" @@ -56,27 +57,27 @@ func (this *MCompGate) Start() (err error) { return } this.scomp = comp.(comm.ISC_GateRouteComp) - this.suitableMethods(reflect.TypeOf(this.comp)) + this.suitableMethods() return } //反射注册相关接口道services/comp_gateroute.go 对象中 -func (this *MCompGate) suitableMethods(typ reflect.Type) { +func (this *MCompGate) suitableMethods() { + typ := reflect.TypeOf(this.comp) for m := 0; m < typ.NumMethod(); m++ { method := typ.Method(m) - this.reflectionRouteHandle(method) - this.reflectionRouteCheck(method) + this.reflectionRouteHandle(typ, method) } } //反射注册路由处理函数 -func (this *MCompGate) reflectionRouteHandle(method reflect.Method) { +func (this *MCompGate) reflectionRouteHandle(typ reflect.Type, method reflect.Method) { mtype := method.Type mname := method.Name if method.PkgPath != "" { return } - if mtype.NumIn() != 4 { + if mtype.NumIn() != 5 { return } ctxType := mtype.In(1) @@ -87,13 +88,21 @@ func (this *MCompGate) reflectionRouteHandle(method reflect.Method) { if !argType.Implements(typeOfMapStringIntface) { return } - replyType := mtype.In(3) + agrType := mtype.In(3) + if agrType.Kind() != reflect.Ptr { + return + } + if !this.isExportedOrBuiltinType(agrType) { + return + } + replyType := mtype.In(4) if replyType.Kind() != reflect.Ptr { return } if !this.isExportedOrBuiltinType(replyType) { return } + if mtype.NumOut() != 1 { return } @@ -101,45 +110,51 @@ func (this *MCompGate) reflectionRouteHandle(method reflect.Method) { if returnCodeType != typeOfErrorCode { return } - this.scomp.RegisterRoute(fmt.Sprintf("%s.%s", this.module.GetType(), strings.ToLower(mname)), reflect.ValueOf(this.comp), replyType, method) + + //寻找校验函数 + check, ok := typ.MethodByName(mname + "Check") + if !ok { + log.Panicf("反射注册用户处理函数错误 [%s-%s]没有对应的校验函数", this.module.GetType(), mname) + return + } + if err := this.reflectionRouteCheck(check, agrType); err == nil { + this.scomp.RegisterRoute(fmt.Sprintf("%s.%s", this.module.GetType(), strings.ToLower(mname)), reflect.ValueOf(this.comp), agrType, replyType, check, method) + } else { + log.Panicf("反射注册用户处理函数错误 [%s-%s]校验函数格式异常:%v", this.module.GetType(), mname, err) + return + } } //反射注册路由校验函数 -func (this *MCompGate) reflectionRouteCheck(method reflect.Method) { +func (this *MCompGate) reflectionRouteCheck(method reflect.Method, msgtype reflect.Type) error { mtype := method.Type - mname := strings.Split(method.Name, "_") - if len(mname) != 2 || mname[1] != "Check" { - return - } + if method.PkgPath != "" { - return + return fmt.Errorf("method.PkgPath:%v", method.PkgPath) } if mtype.NumIn() != 3 { - return + return fmt.Errorf("mtype.NumIn():%v", mtype.NumIn()) } ctxType := mtype.In(1) if !ctxType.Implements(typeOfSession) { - return + return fmt.Errorf("ctxType:%T", ctxType) } replyType := mtype.In(2) - if replyType.Kind() != reflect.Ptr { - return - } - if !this.isExportedOrBuiltinType(replyType) { - return + if replyType != msgtype { + return fmt.Errorf("replyType:%T", replyType) } if mtype.NumOut() != 2 { - return + return fmt.Errorf("mtype.NumOut():%d", mtype.NumOut()) } returnMapType := mtype.Out(0) if !returnMapType.Implements(typeOfMapStringIntface) { - return + return fmt.Errorf("returnMapType:%T", returnMapType) } returnCodeType := mtype.Out(1) if returnCodeType != typeOfCode { - return + return fmt.Errorf("returnCodeType:%T", returnCodeType) } - this.scomp.RegisterRouteCheck(fmt.Sprintf("%s.%s", this.module.GetType(), strings.ToLower(mname[0])), reflect.ValueOf(this.comp), replyType, method) + return nil } func (this *MCompGate) isExportedOrBuiltinType(t reflect.Type) bool { diff --git a/modules/comp_model.go b/modules/comp_model.go index 473023f51..04e2b1e0a 100644 --- a/modules/comp_model.go +++ b/modules/comp_model.go @@ -134,7 +134,7 @@ func (this *MCompModel) AddList(uid string, id string, data interface{}, attrs . this.Redis.Expire(this.ukey(uid), ret.(time.Duration)) } if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_MGOLOG).Unwrap_Or(nil); ret == nil { - err = this.InsertModelLogs(this.TableName, uid, data) + err = this.InsertModelLogs(this.TableName, uid, []interface{}{data}) } return } diff --git a/modules/equipment/api.go b/modules/equipment/api.go index ae992f1a5..251c573ae 100644 --- a/modules/equipment/api.go +++ b/modules/equipment/api.go @@ -9,21 +9,21 @@ import ( /* 装备模块 API */ -type ApiComp struct { +type apiComp struct { modules.MCompGate service core.IService module *Equipment } //组件初始化接口 -func (this *ApiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { +func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { this.MCompGate.Init(service, module, comp, options) this.module = module.(*Equipment) this.service = service return } -func (this *ApiComp) Start() (err error) { +func (this *apiComp) Start() (err error) { err = this.MCompGate.Start() return } diff --git a/modules/equipment/api_equip.go b/modules/equipment/api_equip.go index 69c4148e6..7ad3d8300 100644 --- a/modules/equipment/api_equip.go +++ b/modules/equipment/api_equip.go @@ -8,7 +8,7 @@ import ( ) //参数校验 -func (this *ApiComp) Equip_Check(session comm.IUserSession, req *pb.Equipment_Equip_Req) (result map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) Equip_Check(session comm.IUserSession, req *pb.Equipment_Equip_Req) (result map[string]interface{}, code comm.ErrorCode) { var ( err error errorCode pb.ErrorCode @@ -20,7 +20,7 @@ func (this *ApiComp) Equip_Check(session comm.IUserSession, req *pb.Equipment_Eq equipments = make([]*pb.DB_Equipment, len(req.EquipmentId)) for i, v := range req.EquipmentId { if v != "" { - if equipments[i], err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil { + if equipments[i], err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil { log.Errorf("Equip_Check err:%v", err) code.Code = pb.ErrorCode_EquipmentOnFoundEquipment return @@ -46,7 +46,7 @@ func (this *ApiComp) Equip_Check(session comm.IUserSession, req *pb.Equipment_Eq } ///英雄挂在装备 -func (this *ApiComp) Equip(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_Equip_Req) (code pb.ErrorCode) { +func (this *apiComp) Equip(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_Equip_Req) (code pb.ErrorCode) { var ( err error confs []*cfg.Game_equipData @@ -64,7 +64,7 @@ func (this *ApiComp) Equip(session comm.IUserSession, agrs map[string]interface{ for i, v := range hero.EquipID { if v != "" { if equipments[i] != nil && v != equipments[i].Id { - if equipment, err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil { + if equipment, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil { log.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), v, err) code = pb.ErrorCode_SystemError return @@ -73,7 +73,7 @@ func (this *ApiComp) Equip(session comm.IUserSession, agrs map[string]interface{ equipments[i].HeroId = hero.Id updatequipment = append(updatequipment, equipment, equipments[i]) } else if equipments[i] == nil { - if equipment, err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil { + if equipment, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil { log.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), v, err) code = pb.ErrorCode_SystemError return @@ -96,7 +96,7 @@ func (this *ApiComp) Equip(session comm.IUserSession, agrs map[string]interface{ } } if code = this.module.hero.UpdateEquipment(hero, equipments); code == pb.ErrorCode_Success { - if err = this.module.modelequipment.UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil { + if err = this.module.modelEquipment.UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil { log.Errorf("Equip err%v", err) code = pb.ErrorCode_SystemError return diff --git a/modules/equipment/api_getlist.go b/modules/equipment/api_getlist.go index 9de1c44ae..08496c491 100644 --- a/modules/equipment/api_getlist.go +++ b/modules/equipment/api_getlist.go @@ -7,13 +7,13 @@ import ( ) //参数校验 -func (this *ApiComp) Getlist_Check(session comm.IUserSession, req *pb.Equipment_GetList_Req) (result map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) Getlist_Check(session comm.IUserSession, req *pb.Equipment_GetList_Req) (result map[string]interface{}, code comm.ErrorCode) { return } ///获取用户装备列表 -func (this *ApiComp) Getlist(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_GetList_Req, resp *pb.Equipment_GetList_Resp) (code pb.ErrorCode) { +func (this *apiComp) Getlist(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_GetList_Req, resp *pb.Equipment_GetList_Resp) (code pb.ErrorCode) { var ( err error items []*pb.DB_Equipment @@ -23,7 +23,7 @@ func (this *ApiComp) Getlist(session comm.IUserSession, agrs map[string]interfac // session.SendMsg(string(this.module.GetType()), "", &pb.Equipment_GetList_Resp{Equipments: items}) // } // }() - if items, err = this.module.modelequipment.QueryUserEquipments(session.GetUserId()); err != nil { + if items, err = this.module.modelEquipment.QueryUserEquipments(session.GetUserId()); err != nil { log.Errorf("QueryUserPackReq err:%v", err) code = pb.ErrorCode_CacheReadError return diff --git a/modules/equipment/api_upgrade.go b/modules/equipment/api_upgrade.go index 6b98ff2cc..db3f0710b 100644 --- a/modules/equipment/api_upgrade.go +++ b/modules/equipment/api_upgrade.go @@ -12,7 +12,7 @@ import ( ) //参数校验 -func (this *ApiComp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment_Upgrade_Req) (result map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment_Upgrade_Req) (result map[string]interface{}, code comm.ErrorCode) { var ( err error conf *cfg.Game_equipData @@ -24,7 +24,7 @@ func (this *ApiComp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment_ code.Code = pb.ErrorCode_ReqParameterError return } - if equipment, err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), req.EquipmentId); err != nil { + if equipment, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), req.EquipmentId); err != nil { log.Errorf("Equip_Check err:%v", err) code.Code = pb.ErrorCode_EquipmentOnFoundEquipment return @@ -49,7 +49,7 @@ func (this *ApiComp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment_ } ///英雄挂在装备 -func (this *ApiComp) Upgrade(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_Upgrade_Req) (code pb.ErrorCode) { +func (this *apiComp) Upgrade(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_Upgrade_Req) (code pb.ErrorCode) { var ( err error conf *cfg.Game_equipData @@ -85,7 +85,7 @@ func (this *ApiComp) Upgrade(session comm.IUserSession, agrs map[string]interfac //叠加装备 拆分处理 if equipment.IsInitialState && equipment.OverlayNum > 1 { equipment.OverlayNum-- - if err = this.module.modelequipment.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{ + if err = this.module.modelEquipment.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{ "overlayNum": equipment.OverlayNum, "heroId": "", }); err != nil { @@ -97,24 +97,24 @@ func (this *ApiComp) Upgrade(session comm.IUserSession, agrs map[string]interfac equipment.Id = primitive.NewObjectID().Hex() equipment.IsInitialState = false equipment.OverlayNum = 1 - if err = this.module.modelequipment.upgradeEquipment(equipment, conf, intensify); err != nil { + if err = this.module.modelEquipment.upgradeEquipment(equipment, conf, intensify); err != nil { code = pb.ErrorCode_SystemError log.Errorf("Upgrade err:%v", err) return } - if err = this.module.modelequipment.AddList(session.GetUserId(), equipment.Id, equipment); err != nil { + if err = this.module.modelEquipment.AddList(session.GetUserId(), equipment.Id, equipment); err != nil { log.Errorf("Upgrade err:%v", err) code = pb.ErrorCode_SystemError return } } else { equipment.IsInitialState = false - if err = this.module.modelequipment.upgradeEquipment(equipment, conf, intensify); err != nil { + if err = this.module.modelEquipment.upgradeEquipment(equipment, conf, intensify); err != nil { code = pb.ErrorCode_SystemError log.Errorf("Upgrade err:%v", err) return } - if err = this.module.modelequipment.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{ + if err = this.module.modelEquipment.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{ "lv": equipment.Lv, "mainEntry": equipment.MainEntry, "adverbEntry": equipment.AdverbEntry, @@ -136,7 +136,7 @@ func (this *ApiComp) Upgrade(session comm.IUserSession, agrs map[string]interfac for i, v := range hero.EquipID { if v != "" { if v != equipment.Id { - if equipments[i], err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil { + if equipments[i], err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil { log.Errorf("Upgrade err:%v", err) code = pb.ErrorCode_EquipmentOnFoundEquipment return diff --git a/modules/equipment/configure.go b/modules/equipment/configure.go index 19085ec81..918d36308 100644 --- a/modules/equipment/configure.go +++ b/modules/equipment/configure.go @@ -17,12 +17,12 @@ const ( ) ///背包配置管理组件 -type ConfigureComp struct { +type configureComp struct { modules.MCompConfigure } //组件初始化接口 -func (this *ConfigureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { +func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { this.ModuleCompBase.Init(service, module, comp, options) this.LoadConfigure(game_equip, cfg.NewGame_equip) this.LoadConfigure(equip_attrlibrary, cfg.NewGame_equipAttrlibrary) @@ -30,7 +30,7 @@ func (this *ConfigureComp) Init(service core.IService, module core.IModule, comp } //获取装备配置数据 -func (this *ConfigureComp) GetEquipmentConfigure() (configure *cfg.Game_equip, err error) { +func (this *configureComp) GetEquipmentConfigure() (configure *cfg.Game_equip, err error) { var ( v interface{} ok bool @@ -49,7 +49,7 @@ func (this *ConfigureComp) GetEquipmentConfigure() (configure *cfg.Game_equip, e } //获取装备配置数据 -func (this *ConfigureComp) GetEquipmentConfigureById(equipmentId int32) (configure *cfg.Game_equipData, err error) { +func (this *configureComp) GetEquipmentConfigureById(equipmentId int32) (configure *cfg.Game_equipData, err error) { var ( v interface{} ok bool @@ -68,7 +68,7 @@ func (this *ConfigureComp) GetEquipmentConfigureById(equipmentId int32) (configu } //获取装备属性表 -func (this *ConfigureComp) GetEquipmentAttrlibraryConfigure() (configure *cfg.Game_equipAttrlibrary, err error) { +func (this *configureComp) GetEquipmentAttrlibraryConfigure() (configure *cfg.Game_equipAttrlibrary, err error) { var ( v interface{} ok bool @@ -87,7 +87,7 @@ func (this *ConfigureComp) GetEquipmentAttrlibraryConfigure() (configure *cfg.Ga } //获取属性词列表 -func (this *ConfigureComp) GetEquipmentAttrlibraryConfigureByKey(key int32) (configure *cfg.Game_equipAttrlibraryData, err error) { +func (this *configureComp) GetEquipmentAttrlibraryConfigureByKey(key int32) (configure *cfg.Game_equipAttrlibraryData, err error) { var ( v interface{} ok bool @@ -106,7 +106,7 @@ func (this *ConfigureComp) GetEquipmentAttrlibraryConfigureByKey(key int32) (con } //获取属性词列表 -func (this *ConfigureComp) GetEquipmentAttrlibraryConfigureById(Id int32) (configure []*cfg.Game_equipAttrlibraryData, err error) { +func (this *configureComp) GetEquipmentAttrlibraryConfigureById(Id int32) (configure []*cfg.Game_equipAttrlibraryData, err error) { var ( v interface{} ) @@ -125,7 +125,7 @@ func (this *ConfigureComp) GetEquipmentAttrlibraryConfigureById(Id int32) (confi } //获取武器等级消耗表 -func (this *ConfigureComp) GetEquipmentIntensifyConfigure() (configure *cfg.Game_equipIntensify, err error) { +func (this *configureComp) GetEquipmentIntensifyConfigure() (configure *cfg.Game_equipIntensify, err error) { var ( v interface{} ok bool @@ -144,7 +144,7 @@ func (this *ConfigureComp) GetEquipmentIntensifyConfigure() (configure *cfg.Game } //获取武器等级消耗表 -func (this *ConfigureComp) GetEquipmentIntensifyConfigureById(Id int32) (configure *cfg.Game_equipIntensifyData, err error) { +func (this *configureComp) GetEquipmentIntensifyConfigureById(Id int32) (configure *cfg.Game_equipIntensifyData, err error) { var ( v interface{} ok bool diff --git a/modules/equipment/model_equipment.go b/modules/equipment/model_equipment.go index a7a911885..c1268de44 100644 --- a/modules/equipment/model_equipment.go +++ b/modules/equipment/model_equipment.go @@ -15,13 +15,13 @@ import ( ) ///装备 数据组件 -type ModelEquipmentComp struct { +type modelEquipmentComp struct { modules.MCompModel module *Equipment } //组件初始化接口 -func (this *ModelEquipmentComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { +func (this *modelEquipmentComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { this.MCompModel.Init(service, module, comp, opt) this.module = module.(*Equipment) this.TableName = "equipment" @@ -33,21 +33,21 @@ func (this *ModelEquipmentComp) Init(service core.IService, module core.IModule, } //查询用户装备数据 -func (this *ModelEquipmentComp) QueryUserEquipmentsById(uId, id string) (equipment *pb.DB_Equipment, err error) { +func (this *modelEquipmentComp) QueryUserEquipmentsById(uId, id string) (equipment *pb.DB_Equipment, err error) { equipment = &pb.DB_Equipment{} err = this.GetListObj(uId, id, equipment) return } ///查询用户的武器背包 -func (this *ModelEquipmentComp) QueryUserEquipments(uId string) (equipments []*pb.DB_Equipment, err error) { +func (this *modelEquipmentComp) QueryUserEquipments(uId string) (equipments []*pb.DB_Equipment, err error) { equipments = make([]*pb.DB_Equipment, 0) err = this.GetList(uId, &equipments) return } ///查询目标卡片数量 -func (this *ModelEquipmentComp) QueryEquipmentAmount(uid string, equipmentId int32) (amount uint32) { +func (this *modelEquipmentComp) QueryEquipmentAmount(uid string, equipmentId int32) (amount uint32) { var ( equipments []*pb.DB_Equipment err error @@ -65,7 +65,7 @@ func (this *ModelEquipmentComp) QueryEquipmentAmount(uid string, equipmentId int } //添加装备 -func (this *ModelEquipmentComp) AddEquipments(uId string, cIds map[int32]uint32) (err error) { +func (this *modelEquipmentComp) AddEquipments(uId string, cIds map[int32]uint32) (err error) { var ( configure *cfg.Game_equip equipments []*pb.DB_Equipment @@ -115,7 +115,7 @@ func (this *ModelEquipmentComp) AddEquipments(uId string, cIds map[int32]uint32) } //更新武器挂载信息 -func (this *ModelEquipmentComp) UpdateByHeroId(uid string, equipments ...*pb.DB_Equipment) (err error) { +func (this *modelEquipmentComp) UpdateByHeroId(uid string, equipments ...*pb.DB_Equipment) (err error) { for _, v := range equipments { if err = this.ChangeList(uid, v.Id, map[string]interface{}{ "heroId": v.HeroId, @@ -128,7 +128,7 @@ func (this *ModelEquipmentComp) UpdateByHeroId(uid string, equipments ...*pb.DB_ } //创建新的武器对象 -func (this *ModelEquipmentComp) newEquipment(uid string, conf *cfg.Game_equipData, num uint32) (equipment *pb.DB_Equipment, err error) { +func (this *modelEquipmentComp) newEquipment(uid string, conf *cfg.Game_equipData, num uint32) (equipment *pb.DB_Equipment, err error) { var ( mattr []*cfg.Game_equipAttrlibraryData sattr []*cfg.Game_equipAttrlibraryData @@ -184,7 +184,7 @@ func (this *ModelEquipmentComp) newEquipment(uid string, conf *cfg.Game_equipDat } //升级武器 -func (this *ModelEquipmentComp) upgradeEquipment(equipment *pb.DB_Equipment, equip *cfg.Game_equipData, intensify *cfg.Game_equipIntensifyData) (err error) { +func (this *modelEquipmentComp) upgradeEquipment(equipment *pb.DB_Equipment, equip *cfg.Game_equipData, intensify *cfg.Game_equipIntensifyData) (err error) { equipment.Lv++ equipment.MainEntry.Lv++ equipment.MainEntry.Value += equipment.MainEntry.Value * (intensify.Bonus / 1000.0) diff --git a/modules/equipment/module.go b/modules/equipment/module.go index 5bb3b92c7..d17fed2cb 100644 --- a/modules/equipment/module.go +++ b/modules/equipment/module.go @@ -23,9 +23,9 @@ func NewModule() core.IModule { type Equipment struct { modules.ModuleBase service core.IService - api *ApiComp - configure *ConfigureComp - modelequipment *ModelEquipmentComp + api *apiComp + configure *configureComp + modelEquipment *modelEquipmentComp hero comm.IHero } @@ -56,16 +56,16 @@ func (this *Equipment) Start() (err error) { //装备组件 func (this *Equipment) OnInstallComp() { this.ModuleBase.OnInstallComp() - this.api = this.RegisterComp(new(ApiComp)).(*ApiComp) - this.modelequipment = this.RegisterComp(new(ModelEquipmentComp)).(*ModelEquipmentComp) - this.configure = this.RegisterComp(new(ConfigureComp)).(*ConfigureComp) + this.api = this.RegisterComp(new(apiComp)).(*apiComp) + this.modelEquipment = this.RegisterComp(new(modelEquipmentComp)).(*modelEquipmentComp) + this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } //IEquipment------------------------------------------------------------------------------------------------------------------------------- //查询武器信息 func (this *Equipment) QueryEquipment(source *comm.ModuleCallSource, uid string, Id string) (equipment *pb.DB_Equipment, code pb.ErrorCode) { var err error - if equipment, err = this.modelequipment.QueryUserEquipmentsById(uid, Id); err != nil { + if equipment, err = this.modelEquipment.QueryUserEquipmentsById(uid, Id); err != nil { if err == redis.Nil { code = pb.ErrorCode_EquipmentOnFoundEquipment } else { @@ -77,14 +77,14 @@ func (this *Equipment) QueryEquipment(source *comm.ModuleCallSource, uid string, //查询卡片数量 func (this *Equipment) QueryEquipmentAmount(source *comm.ModuleCallSource, uid string, equipmentId int32) (amount uint32) { - amount = this.modelequipment.QueryEquipmentAmount(uid, equipmentId) + amount = this.modelEquipment.QueryEquipmentAmount(uid, equipmentId) return } //添加武器 func (this *Equipment) AddNewEquipments(source *comm.ModuleCallSource, uid string, cIds map[int32]uint32) (code pb.ErrorCode) { var err error - if err = this.modelequipment.AddEquipments(uid, cIds); err != nil { + if err = this.modelEquipment.AddEquipments(uid, cIds); err != nil { log.Errorf("err%v", err) code = pb.ErrorCode_SystemError } diff --git a/modules/forum/api.go b/modules/forum/api.go index dd3dd45c5..50f78a228 100644 --- a/modules/forum/api.go +++ b/modules/forum/api.go @@ -9,21 +9,21 @@ import ( /* 装备模块 API */ -type Api_Comp struct { - modules.MComp_GateComp +type apiComp struct { + modules.MCompGate service core.IService module *Forum } //组件初始化接口 -func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - this.MComp_GateComp.Init(service, module, comp, options) +func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.MCompGate.Init(service, module, comp, options) this.module = module.(*Forum) this.service = service return } -func (this *Api_Comp) Start() (err error) { - err = this.MComp_GateComp.Start() +func (this *apiComp) Start() (err error) { + err = this.MCompGate.Start() return } diff --git a/modules/forum/configure_comp.go b/modules/forum/configure_comp.go index 03090d3b2..584696ccd 100644 --- a/modules/forum/configure_comp.go +++ b/modules/forum/configure_comp.go @@ -11,12 +11,12 @@ const ( ) ///背包配置管理组件 -type Configure_Comp struct { - modules.MComp_Configure +type configureComp struct { + modules.MCompConfigure } //组件初始化接口 -func (this *Configure_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { +func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { this.ModuleCompBase.Init(service, module, comp, options) return diff --git a/modules/forum/model_forum_comp.go b/modules/forum/model_forum_comp.go index a54914256..fa4eda3dd 100644 --- a/modules/forum/model_forum_comp.go +++ b/modules/forum/model_forum_comp.go @@ -9,14 +9,14 @@ import ( ) ///论坛 数据组件 -type Model_Forum_Comp struct { - modules.Model_Comp +type modelForumComp struct { + modules.MCompModel module *Forum } //组件初始化接口 -func (this *Model_Forum_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { - this.Model_Comp.Init(service, module, comp, opt) +func (this *modelForumComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { + this.MCompModel.Init(service, module, comp, opt) this.module = module.(*Forum) this.TableName = "forum" //创建uid索引 diff --git a/modules/forum/module.go b/modules/forum/module.go index 63c03bb8d..228ef1db7 100644 --- a/modules/forum/module.go +++ b/modules/forum/module.go @@ -18,9 +18,9 @@ func NewModule() core.IModule { type Forum struct { modules.ModuleBase - api_comp *Api_Comp - configure_comp *Configure_Comp - model_forum_comp *Model_Forum_Comp + api_comp *apiComp + configure_comp *configureComp + model_forum_comp *modelForumComp } //模块名 @@ -37,7 +37,7 @@ func (this *Forum) Init(service core.IService, module core.IModule, options core //装备组件 func (this *Forum) OnInstallComp() { this.ModuleBase.OnInstallComp() - this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp) - this.model_forum_comp = this.RegisterComp(new(Model_Forum_Comp)).(*Model_Forum_Comp) - this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp) + this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp) + this.model_forum_comp = this.RegisterComp(new(modelForumComp)).(*modelForumComp) + this.configure_comp = this.RegisterComp(new(configureComp)).(*configureComp) } diff --git a/modules/friend/api.go b/modules/friend/api.go index b8b83edd2..463058f6f 100644 --- a/modules/friend/api.go +++ b/modules/friend/api.go @@ -18,12 +18,12 @@ const ( ) type ApiComp struct { - modules.MComp_GateComp + modules.MCompGate module *Friend } func (this *ApiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - this.MComp_GateComp.Init(service, module, comp, options) + this.MCompGate.Init(service, module, comp, options) this.module = module.(*Friend) return } diff --git a/modules/friend/model_friend.go b/modules/friend/model_friend.go index f3402fe9e..7c8faeef1 100644 --- a/modules/friend/model_friend.go +++ b/modules/friend/model_friend.go @@ -15,11 +15,11 @@ const ( ) type ModelFriend struct { - modules.Model_Comp + modules.MCompModel } func (this *ModelFriend) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - err = this.Model_Comp.Init(service, module, comp, options) + err = this.MCompModel.Init(service, module, comp, options) this.TableName = "friend" return } diff --git a/modules/gateway/agent.go b/modules/gateway/agent.go index 0ba488c6b..854a6fd24 100644 --- a/modules/gateway/agent.go +++ b/modules/gateway/agent.go @@ -224,7 +224,8 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) error { UserSessionId: this.sessionId, UserId: this.uId, GatewayServiceId: this.gateway.Service().GetId(), - Method: fmt.Sprintf("%s.%s", msg.MainType, msg.SubType), + MainType: msg.MainType, + SubType: msg.SubType, Message: msg.Data, }, reply); err != nil { log.Errorf("agent:%s uId:%s MessageDistribution err:%v", this.sessionId, this.uId, err) diff --git a/modules/gateway/agentmgr_comp.go b/modules/gateway/agentmgr_comp.go index d9c22f9c3..8ac746d99 100644 --- a/modules/gateway/agentmgr_comp.go +++ b/modules/gateway/agentmgr_comp.go @@ -53,7 +53,7 @@ func (this *AgentMgrComp) Bind(ctx context.Context, args *pb.AgentBuildReq, repl a.(IAgent).Bind(args.UserId, args.WorkerId) } else { reply.Code = pb.ErrorCode_UserSessionNobeing - reply.Message = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing) + reply.ErrorMessage = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing) } return nil } @@ -64,7 +64,7 @@ func (this *AgentMgrComp) UnBind(ctx context.Context, args *pb.AgentUnBuildReq, a.(IAgent).UnBind() } else { reply.Code = pb.ErrorCode_UserSessionNobeing - reply.Message = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing) + reply.ErrorMessage = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing) } return nil } @@ -79,7 +79,7 @@ func (this *AgentMgrComp) SendMsgToAgent(ctx context.Context, args *pb.AgentSend }) } else { reply.Code = pb.ErrorCode_UserSessionNobeing - reply.Message = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing) + reply.ErrorMessage = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing) } return nil } @@ -119,7 +119,7 @@ func (this *AgentMgrComp) CloseAgent(ctx context.Context, args *pb.AgentCloseeRe a.(IAgent).Close() } else { reply.Code = pb.ErrorCode_UserSessionNobeing - reply.Message = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing) + reply.ErrorMessage = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing) } return nil } diff --git a/modules/hero/api.go b/modules/hero/api.go index b3a310eb9..7e25a8e85 100644 --- a/modules/hero/api.go +++ b/modules/hero/api.go @@ -7,7 +7,7 @@ import ( ) type apiComp struct { - modules.MComp_GateComp + modules.MCompGate service core.IService moduleHero *Hero user comm.IUser @@ -21,14 +21,14 @@ const ( //消息回复的头名称 //组件初始化接口 func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - this.MComp_GateComp.Init(service, module, comp, options) + this.MCompGate.Init(service, module, comp, options) this.moduleHero = module.(*Hero) this.service = service return } func (this *apiComp) Start() (err error) { - err = this.MComp_GateComp.Start() + err = this.MCompGate.Start() var module core.IModule diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index 6bce3469c..165c3e587 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -19,13 +19,13 @@ const ( ///配置管理组件 type configureComp struct { - modules.MComp_Configure + modules.MCompConfigure } //组件初始化接口 func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - err = this.MComp_Configure.Init(service, module, comp, options) + err = this.MCompConfigure.Init(service, module, comp, options) err = this.LoadMultiConfigure(map[string]interface{}{ new_hero: cfg.NewGame_newHero, hero_stargrow: cfg.NewGame_heroStargrow, diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 7f21d6add..034982236 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -15,12 +15,12 @@ import ( ) type ModelHero struct { - modules.Model_Comp + modules.MCompModel moduleHero *Hero } func (this *ModelHero) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - err = this.Model_Comp.Init(service, module, comp, options) + err = this.MCompModel.Init(service, module, comp, options) this.moduleHero = module.(*Hero) this.TableName = "hero" return diff --git a/modules/items/module_test.go b/modules/items/module_test.go index 0b774f5e5..14031d9a0 100644 --- a/modules/items/module_test.go +++ b/modules/items/module_test.go @@ -76,7 +76,7 @@ func TestMain(m *testing.M) { func Test_Modules(t *testing.T) { data, _ := ptypes.MarshalAny(&pb.Items_Getlist_Req{}) - s_gateComp.ReceiveMsg(context.Background(), &pb.AgentMessage{Method: "pack.getlist", Message: data}, &pb.RPCMessageReply{}) + s_gateComp.ReceiveMsg(context.Background(), &pb.AgentMessage{MainType: "pack", SubType: "getlist", Message: data}, &pb.RPCMessageReply{}) // items, err := module.db_comp.Pack_QueryUserPack("liwei1dao") // log.Debugf("item:%v err:%v", items, err) } diff --git a/modules/mail/api.go b/modules/mail/api.go index 74e4a8f22..3b1e7540c 100644 --- a/modules/mail/api.go +++ b/modules/mail/api.go @@ -16,14 +16,14 @@ const ( ) type apiComp struct { - modules.MComp_GateComp + modules.MCompGate service core.IService module *Mail items comm.IItems } func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - this.MComp_GateComp.Init(service, module, comp, options) + this.MCompGate.Init(service, module, comp, options) this.service = service this.module = module.(*Mail) @@ -31,7 +31,7 @@ func (this *apiComp) Init(service core.IService, module core.IModule, comp core. } func (this *apiComp) Start() (err error) { - err = this.MComp_GateComp.Start() + err = this.MCompGate.Start() var module core.IModule if module, err = this.service.GetModule(comm.SM_ItemsModule); err != nil { diff --git a/modules/mail/module.go b/modules/mail/module.go index a7b5f879c..881ae6379 100644 --- a/modules/mail/module.go +++ b/modules/mail/module.go @@ -57,7 +57,7 @@ func (this *Mail) CreateNewMail(uId string) { } // 通知玩家 var _cache = &pb.Cache_UserData{} - err = this.modelMail.Model_Comp.Get(uId, _cache) + err = this.modelMail.MCompModel.Get(uId, _cache) if err == nil { return } diff --git a/modules/modulebase.go b/modules/modulebase.go index f05534673..c05563aaf 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -158,11 +158,7 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p } else if v.A == comm.CardType { //卡片资源 resID, _ = strconv.Atoi(v.T) hero.ChangeCard(uid, int32(resID), -1*v.N) - } else if v.A == comm.EquipmentType { - resID, _ = strconv.Atoi(v.T) - equipment.AddNewEquipments(source, uid, resID, -1*v.N) } - //不存在消耗武器的情况 // } else if v.A == comm.EquipmentType { // resID, _ = strconv.Atoi(v.T) // equipment.AddNewEquipments(source, uid, resID, -1*v.N) diff --git a/modules/user/api.go b/modules/user/api.go index 3bf8f576e..73622a297 100644 --- a/modules/user/api.go +++ b/modules/user/api.go @@ -15,21 +15,21 @@ const ( ) type apiComp struct { - modules.MComp_GateComp + modules.MCompGate service base.IRPCXService module *User hero comm.IHero } func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - this.MComp_GateComp.Init(service, module, comp, options) + this.MCompGate.Init(service, module, comp, options) this.service = service.(base.IRPCXService) this.module = module.(*User) return } func (this *apiComp) Start() (err error) { - err = this.MComp_GateComp.Start() + err = this.MCompGate.Start() var module core.IModule //get module hero diff --git a/modules/user/model_session.go b/modules/user/model_session.go index 4c2bf90f5..6442f45e4 100644 --- a/modules/user/model_session.go +++ b/modules/user/model_session.go @@ -6,11 +6,11 @@ import ( ) type ModelSession struct { - modules.Model_Comp + modules.MCompModel } func (this *ModelSession) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - err = this.Model_Comp.Init(service, module, comp, options) + err = this.MCompModel.Init(service, module, comp, options) this.TableName = "session" return } diff --git a/modules/user/model_user.go b/modules/user/model_user.go index 1869cf0a3..b1aed8e7c 100644 --- a/modules/user/model_user.go +++ b/modules/user/model_user.go @@ -17,11 +17,11 @@ const ( //Redis ) type ModelUser struct { - modules.Model_Comp + modules.MCompModel } func (this *ModelUser) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - err = this.Model_Comp.Init(service, module, comp, options) + err = this.MCompModel.Init(service, module, comp, options) this.TableName = "user" return } diff --git a/pb/comm.pb.go b/pb/comm.pb.go index 1c68904ea..88b90b6a8 100644 --- a/pb/comm.pb.go +++ b/pb/comm.pb.go @@ -160,8 +160,9 @@ type AgentMessage struct { UserSessionId string `protobuf:"bytes,2,opt,name=UserSessionId,proto3" json:"UserSessionId"` UserId string `protobuf:"bytes,3,opt,name=UserId,proto3" json:"UserId"` GatewayServiceId string `protobuf:"bytes,4,opt,name=GatewayServiceId,proto3" json:"GatewayServiceId"` - Method string `protobuf:"bytes,5,opt,name=Method,proto3" json:"Method"` - Message *anypb.Any `protobuf:"bytes,6,opt,name=Message,proto3" json:"Message"` + MainType string `protobuf:"bytes,5,opt,name=MainType,proto3" json:"MainType"` + SubType string `protobuf:"bytes,6,opt,name=SubType,proto3" json:"SubType"` + Message *anypb.Any `protobuf:"bytes,7,opt,name=Message,proto3" json:"Message"` } func (x *AgentMessage) Reset() { @@ -224,9 +225,16 @@ func (x *AgentMessage) GetGatewayServiceId() string { return "" } -func (x *AgentMessage) GetMethod() string { +func (x *AgentMessage) GetMainType() string { if x != nil { - return x.Method + return x.MainType + } + return "" +} + +func (x *AgentMessage) GetSubType() string { + if x != nil { + return x.SubType } return "" } @@ -244,9 +252,10 @@ type RPCMessageReply struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code"` - Message string `protobuf:"bytes,2,opt,name=Message,proto3" json:"Message"` - Data string `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data"` + Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code"` + ErrorMessage string `protobuf:"bytes,2,opt,name=ErrorMessage,proto3" json:"ErrorMessage"` + ErrorData string `protobuf:"bytes,3,opt,name=ErrorData,proto3" json:"ErrorData"` + Reply *UserMessage `protobuf:"bytes,4,opt,name=Reply,proto3" json:"Reply"` } func (x *RPCMessageReply) Reset() { @@ -288,20 +297,27 @@ func (x *RPCMessageReply) GetCode() ErrorCode { return ErrorCode_Success } -func (x *RPCMessageReply) GetMessage() string { +func (x *RPCMessageReply) GetErrorMessage() string { if x != nil { - return x.Message + return x.ErrorMessage } return "" } -func (x *RPCMessageReply) GetData() string { +func (x *RPCMessageReply) GetErrorData() string { if x != nil { - return x.Data + return x.ErrorData } return "" } +func (x *RPCMessageReply) GetReply() *UserMessage { + if x != nil { + return x.Reply + } + return nil +} + //用户代理绑定Uid请求 type AgentBuildReq struct { state protoimpl.MessageState @@ -732,7 +748,7 @@ var file_comm_proto_rawDesc = []byte{ 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x63, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x65, 0x63, 0x22, 0xd0, 0x01, 0x0a, 0x0c, 0x41, 0x67, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x65, 0x63, 0x22, 0xee, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, @@ -741,66 +757,72 @@ var file_comm_proto_rawDesc = []byte{ 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x2e, 0x0a, 0x07, - 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, + 0x63, 0x65, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2e, 0x0a, 0x07, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, + 0x79, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x97, 0x01, 0x0a, 0x0f, 0x52, + 0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1e, + 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, + 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x22, + 0x0a, 0x0c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x44, 0x61, 0x74, 0x61, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x44, 0x61, 0x74, 0x61, + 0x12, 0x22, 0x0a, 0x05, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0c, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x05, 0x52, + 0x65, 0x70, 0x6c, 0x79, 0x22, 0x69, 0x0a, 0x0d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x69, + 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, + 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, + 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, + 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x49, 0x64, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x49, 0x64, 0x22, + 0x37, 0x0a, 0x0f, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, + 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x9b, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65, + 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, + 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, + 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, + 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, + 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x99, 0x01, 0x0a, 0x0f, 0x42, 0x61, 0x74, 0x63, 0x68, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x0e, 0x55, 0x73, + 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, + 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, + 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, + 0x74, 0x61, 0x22, 0x75, 0x0a, 0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, + 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, + 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x41, 0x6e, 0x79, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x5f, 0x0a, 0x0f, - 0x52, 0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, - 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, - 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, - 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, - 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x69, 0x0a, - 0x0d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, - 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, - 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x0f, 0x41, 0x67, 0x65, 0x6e, - 0x74, 0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, + 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, + 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, - 0x64, 0x22, 0x9b, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, - 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, - 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, - 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, - 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, - 0x99, 0x01, 0x0a, 0x0f, 0x42, 0x61, 0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, - 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x4d, - 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, - 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, - 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x75, 0x0a, 0x13, 0x42, - 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, - 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, - 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, - 0x74, 0x61, 0x22, 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, - 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, - 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x2c, 0x0a, 0x12, 0x4e, 0x6f, - 0x74, 0x69, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x71, - 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x2a, 0x43, 0x0a, 0x12, 0x48, 0x65, 0x72, 0x6f, - 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x06, - 0x0a, 0x02, 0x48, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x74, 0x6b, 0x10, 0x01, 0x12, - 0x07, 0x0a, 0x03, 0x44, 0x65, 0x66, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x70, 0x65, 0x65, - 0x64, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x72, 0x69, 0x74, 0x10, 0x04, 0x42, 0x06, 0x5a, - 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x22, 0x2c, 0x0a, 0x12, 0x4e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x43, + 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x2a, + 0x43, 0x0a, 0x12, 0x48, 0x65, 0x72, 0x6f, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, + 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x06, 0x0a, 0x02, 0x48, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, + 0x03, 0x41, 0x74, 0x6b, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x65, 0x66, 0x10, 0x02, 0x12, + 0x09, 0x0a, 0x05, 0x53, 0x70, 0x65, 0x65, 0x64, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x72, + 0x69, 0x74, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -836,14 +858,15 @@ var file_comm_proto_depIdxs = []int32{ 11, // 0: UserMessage.data:type_name -> google.protobuf.Any 11, // 1: AgentMessage.Message:type_name -> google.protobuf.Any 12, // 2: RPCMessageReply.Code:type_name -> ErrorCode - 11, // 3: AgentSendMessageReq.Data:type_name -> google.protobuf.Any - 11, // 4: BatchMessageReq.Data:type_name -> google.protobuf.Any - 11, // 5: BroadCastMessageReq.Data:type_name -> google.protobuf.Any - 6, // [6:6] is the sub-list for method output_type - 6, // [6:6] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 1, // 3: RPCMessageReply.Reply:type_name -> UserMessage + 11, // 4: AgentSendMessageReq.Data:type_name -> google.protobuf.Any + 11, // 5: BatchMessageReq.Data:type_name -> google.protobuf.Any + 11, // 6: BroadCastMessageReq.Data:type_name -> google.protobuf.Any + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_comm_proto_init() } diff --git a/pb/proto/comm.proto b/pb/proto/comm.proto index 36eb64791..2e32a2ee0 100644 --- a/pb/proto/comm.proto +++ b/pb/proto/comm.proto @@ -18,8 +18,9 @@ message AgentMessage { string UserSessionId = 2; string UserId = 3; string GatewayServiceId = 4; - string Method = 5; - google.protobuf.Any Message = 6; + string MainType = 5; + string SubType = 6; + google.protobuf.Any Message = 7; } // RPC 服务固定回复结构 diff --git a/services/comp_gateroute.go b/services/comp_gateroute.go index d6d9287ff..6a761e498 100644 --- a/services/comp_gateroute.go +++ b/services/comp_gateroute.go @@ -33,9 +33,11 @@ func NewGateRouteComp() comm.ISC_GateRouteComp { //用户协议处理函数注册的反射对象 type msghandle struct { - rcvr reflect.Value - msgType reflect.Type - fn reflect.Method + rcvr reflect.Value + msgType reflect.Type //消息请求类型 + replyType reflect.Type //消息回应类型 + check reflect.Method //校验函数 + handle reflect.Method //处理函数 } //服务网关组件 @@ -43,7 +45,6 @@ type SCompGateRoute struct { cbase.ServiceCompBase service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口 mrlock sync.RWMutex //msghandles 对象的锁 - msgcheck map[string]*msghandle //处理函数的校验接口 msghandles map[string]*msghandle //处理函数的管理对象 } @@ -56,7 +57,6 @@ func (this *SCompGateRoute) GetName() core.S_Comps { func (this *SCompGateRoute) Init(service core.IService, comp core.IServiceComp, options core.ICompOptions) (err error) { err = this.ServiceCompBase.Init(service, comp, options) this.service = service.(base.IRPCXService) - this.msgcheck = make(map[string]*msghandle) this.msghandles = make(map[string]*msghandle) return err } // @@ -66,25 +66,11 @@ func (this *SCompGateRoute) Start() (err error) { this.service.RegisterFunctionName(string(comm.Rpc_GatewayRoute), this.ReceiveMsg) //注册网关路由接收接口 this.service.RegisterFunctionName(string(comm.Rpc_NoticeUserClose), this.NoticeUserClose) //注册用户离线通知 err = this.ServiceCompBase.Start() - event.RegisterGO(core.Event_ServiceStartEnd, func() { - for k, v := range this.msghandles { - if v1, ok := this.msgcheck[k]; !ok { - log.Panicf("注册用户消息处理函数:%s 没有实现参数校验接口", k) - return - } else if v.msgType != v1.msgType { - log.Panicf("注册用户消息处理函数:%s 实现参数校验接口不一致 请检查代码!", k) - return - } - } - }) - event.RegisterGO(core.Event_FindNewService, func() { - log.Debugf("find new service") - }) return } //业务模块注册用户消息处理路由 -func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, fn reflect.Method) { +func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, replyType reflect.Type, check, handele reflect.Method) { log.Debugf("注册用户路由【%s】", methodName) this.mrlock.RLock() _, ok := this.msghandles[methodName] @@ -95,28 +81,11 @@ func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value, } this.mrlock.Lock() this.msghandles[methodName] = &msghandle{ - rcvr: comp, - msgType: msg, - fn: fn, - } - this.mrlock.Unlock() -} - -//业务模块注册用户消息处理路由 -func (this *SCompGateRoute) RegisterRouteCheck(methodName string, comp reflect.Value, msg reflect.Type, fn reflect.Method) { - log.Debugf("注册用户路由校验[%s]", methodName) - this.mrlock.RLock() - _, ok := this.msgcheck[methodName] - this.mrlock.RUnlock() - if ok { - log.Errorf("重复 注册用户路由校验[%s]", methodName) - return - } - this.mrlock.Lock() - this.msgcheck[methodName] = &msghandle{ - rcvr: comp, - msgType: msg, - fn: fn, + rcvr: comp, + msgType: msg, + replyType: replyType, + check: check, + handle: handele, } this.mrlock.Unlock() } @@ -128,15 +97,15 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag buf := make([]byte, 1024) l := runtime.Stack(buf, false) reply.Code = pb.ErrorCode_Exception - reply.Message = fmt.Sprintf("%v: %s", r, buf[:l]) - log.Errorf("HandleUserMsg:%s err:%s", args.Method, reply.Message) + reply.ErrorMessage = fmt.Sprintf("%v: %s", r, buf[:l]) + log.Errorf("HandleUserMsg:[%s-%s] err:%s", args.MainType, args.SubType, reply.ErrorMessage) } }() - log.Debugf("SCompGateRoute ReceiveMsg agent:%s uId:%s MessageDistribution msg:%s", args.UserSessionId, args.UserId, args.Method) + log.Debugf("SCompGateRoute ReceiveMsg agent:%s uId:%s MessageDistribution:[%s-%s]", args.UserSessionId, args.UserId, args.MainType, args.SubType) + method := fmt.Sprintf("%s.%s", args.MainType, args.SubType) //获取用户消息处理函数 this.mrlock.RLock() - msghandle, ok := this.msghandles[args.Method] - msgcheck := this.msgcheck[args.Method] + msghandle, ok := this.msghandles[method] this.mrlock.RUnlock() if ok { //封装用户会话 @@ -144,24 +113,27 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag //序列化用户消息对象 msg := reflect.New(msghandle.msgType.Elem()).Interface() if err := ptypes.UnmarshalAny(args.Message, msg.(proto.Message)); err != nil { - log.Errorf("UserMessage:%s Unmarshal err:%v", args.Method, err) + log.Errorf("UserMessage:%s Unmarshal err:%v", method, err) return err } + //序列化用户消息对象 + replymsg := reflect.New(msghandle.replyType.Elem()).Interface() + //调用校验接口 - checkreturn := msgcheck.fn.Func.Call([]reflect.Value{msgcheck.rcvr, reflect.ValueOf(session), reflect.ValueOf(msg)}) + checkreturn := msghandle.check.Func.Call([]reflect.Value{msghandle.rcvr, reflect.ValueOf(session), reflect.ValueOf(msg)}) //读取校验结果 有错误直接返回错误码给用户 code := checkreturn[1].Interface().(comm.ErrorCode) if code.Code != pb.ErrorCode_Success { - log.Errorf("HandleUserMsg:%s msg:%v code:%d", args.Method, msg, code) + log.Errorf("HandleUserMsg:%s msg:%v code:%d", method, msg, code) reply.Code = code.Code - reply.Message = pb.GetErrorCodeMsg(code.Code) + reply.ErrorMessage = pb.GetErrorCodeMsg(code.Code) if code.Data != nil { //处理错误附加数据 采用json 序列化为string if d, err := jsoniter.Marshal(code.Data); err != nil { - log.Errorf("HandleUserMsg:%s msg:%v code:%d err:%v", args.Method, msg, code, err) + log.Errorf("HandleUserMsg:%s msg:%v code:%d err:%v", method, msg, code, err) return nil } else { - reply.Data = codec.BytesToString(d) + reply.ErrorData = codec.BytesToString(d) } } return nil @@ -169,12 +141,12 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag //校验结果成功 处理临时数据转移 result := checkreturn[0].Interface().(map[string]interface{}) //调用用户处理函数 - handlereturn := msghandle.fn.Func.Call([]reflect.Value{msghandle.rcvr, reflect.ValueOf(session), reflect.ValueOf(result), reflect.ValueOf(msg)}) + handlereturn := msghandle.handle.Func.Call([]reflect.Value{msghandle.rcvr, reflect.ValueOf(session), reflect.ValueOf(result), reflect.ValueOf(msg), reflect.ValueOf(replymsg)}) errcode := pb.ErrorCode(handlereturn[0].Int()) if errcode != pb.ErrorCode_Success { //处理返货错误码 返回用户错误信息 - log.Errorf("HandleUserMsg:%s msg:%v code:%d", args.Method, msg, code) + log.Errorf("HandleUserMsg:%s msg:%v code:%d", method, msg, code) reply.Code = errcode - reply.Message = pb.GetErrorCodeMsg(errcode) + reply.ErrorMessage = pb.GetErrorCodeMsg(errcode) return nil } } else { //未找到消息处理函数 From 50bb5a92a8aace0c8c18ded9e924bc6acff0d6ab Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 28 Jun 2022 17:09:32 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E6=B6=88=E6=81=AF=E9=98=9F=E5=88=97=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/core.go | 2 +- comm/usersession.go | 2 ++ modules/comp_gate.go | 11 ++------ .../{comp_configure.go => compconfigure.go} | 0 modules/equipment/api_getlist.go | 15 +++++------ modules/gateway/agent.go | 16 +++++++---- pb/comm.pb.go | 12 ++++----- pb/proto/comm.proto | 2 +- services/comp_gateroute.go | 27 +++++++++---------- 9 files changed, 42 insertions(+), 45 deletions(-) rename modules/{comp_configure.go => compconfigure.go} (100%) diff --git a/comm/core.go b/comm/core.go index 45f6a3849..bc07dafa7 100644 --- a/comm/core.go +++ b/comm/core.go @@ -16,7 +16,7 @@ import ( type ISC_GateRouteComp interface { core.IServiceComp ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) error - RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, reply reflect.Type, check, handle reflect.Method) + RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, check, handle reflect.Method) } //游戏类资源类型 diff --git a/comm/usersession.go b/comm/usersession.go index ba5624adc..d8ff86e01 100644 --- a/comm/usersession.go +++ b/comm/usersession.go @@ -22,6 +22,7 @@ func NewUserSession(service base.IRPCXService, ip, sessionId, gatewayServiceId s SessionId: sessionId, GatewayServiceId: gatewayServiceId, UserId: uid, + msgqueue: make([]*pb.UserMessage, 0), service: service, } } @@ -32,6 +33,7 @@ type UserSession struct { GatewayServiceId string //用户所在网关服务 UserId string service base.IRPCXService + msgqueue []*pb.UserMessage } //获取用户的会话id diff --git a/modules/comp_gate.go b/modules/comp_gate.go index 883fdf33d..99c9fc565 100644 --- a/modules/comp_gate.go +++ b/modules/comp_gate.go @@ -77,7 +77,7 @@ func (this *MCompGate) reflectionRouteHandle(typ reflect.Type, method reflect.Me if method.PkgPath != "" { return } - if mtype.NumIn() != 5 { + if mtype.NumIn() != 4 { return } ctxType := mtype.In(1) @@ -95,13 +95,6 @@ func (this *MCompGate) reflectionRouteHandle(typ reflect.Type, method reflect.Me if !this.isExportedOrBuiltinType(agrType) { return } - replyType := mtype.In(4) - if replyType.Kind() != reflect.Ptr { - return - } - if !this.isExportedOrBuiltinType(replyType) { - return - } if mtype.NumOut() != 1 { return @@ -118,7 +111,7 @@ func (this *MCompGate) reflectionRouteHandle(typ reflect.Type, method reflect.Me return } if err := this.reflectionRouteCheck(check, agrType); err == nil { - this.scomp.RegisterRoute(fmt.Sprintf("%s.%s", this.module.GetType(), strings.ToLower(mname)), reflect.ValueOf(this.comp), agrType, replyType, check, method) + this.scomp.RegisterRoute(fmt.Sprintf("%s.%s", this.module.GetType(), strings.ToLower(mname)), reflect.ValueOf(this.comp), agrType, check, method) } else { log.Panicf("反射注册用户处理函数错误 [%s-%s]校验函数格式异常:%v", this.module.GetType(), mname, err) return diff --git a/modules/comp_configure.go b/modules/compconfigure.go similarity index 100% rename from modules/comp_configure.go rename to modules/compconfigure.go diff --git a/modules/equipment/api_getlist.go b/modules/equipment/api_getlist.go index 08496c491..85fee866b 100644 --- a/modules/equipment/api_getlist.go +++ b/modules/equipment/api_getlist.go @@ -13,21 +13,20 @@ func (this *apiComp) Getlist_Check(session comm.IUserSession, req *pb.Equipment_ } ///获取用户装备列表 -func (this *apiComp) Getlist(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_GetList_Req, resp *pb.Equipment_GetList_Resp) (code pb.ErrorCode) { +func (this *apiComp) Getlist(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_GetList_Req) (code pb.ErrorCode) { var ( err error items []*pb.DB_Equipment ) - // defer func() { - // if code == pb.ErrorCode_Success { - // session.SendMsg(string(this.module.GetType()), "", &pb.Equipment_GetList_Resp{Equipments: items}) - // } - // }() - if items, err = this.module.modelEquipment.QueryUserEquipments(session.GetUserId()); err != nil { + defer func() { + if code == pb.ErrorCode_Success { + session.SendMsg(string(this.module.GetType()), "", &pb.Equipment_GetList_Resp{Equipments: items}) + } + }() + if items, err = this.module.modelequipment.QueryUserEquipments(session.GetUserId()); err != nil { log.Errorf("QueryUserPackReq err:%v", err) code = pb.ErrorCode_CacheReadError return } - resp.Equipments = items return } diff --git a/modules/gateway/agent.go b/modules/gateway/agent.go index 854a6fd24..cc47f0a47 100644 --- a/modules/gateway/agent.go +++ b/modules/gateway/agent.go @@ -208,7 +208,7 @@ func (this *Agent) Close() { } //分发用户消息 -func (this *Agent) messageDistribution(msg *pb.UserMessage) error { +func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) { reply := &pb.RPCMessageReply{} log.Debugf("agent:%s uId:%s MessageDistribution msg:%s.%s", this.sessionId, this.uId, msg.MainType, msg.SubType) servicePath := comm.Service_Worker @@ -219,7 +219,7 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) error { servicePath = fmt.Sprintf("%s/%s", comm.Service_Worker, this.wId) } } - if err := this.gateway.Service().RpcCall(context.Background(), servicePath, string(comm.Rpc_GatewayRoute), &pb.AgentMessage{ + if err = this.gateway.Service().RpcCall(context.Background(), servicePath, string(comm.Rpc_GatewayRoute), &pb.AgentMessage{ Ip: this.IP(), UserSessionId: this.sessionId, UserId: this.uId, @@ -229,16 +229,22 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) error { Message: msg.Data, }, reply); err != nil { log.Errorf("agent:%s uId:%s MessageDistribution err:%v", this.sessionId, this.uId, err) - return err + return } if reply.Code != pb.ErrorCode_Success { data, _ := anypb.New(&pb.ErrorNotify{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: pb.ErrorCode(reply.Code.Number())}) - err := this.WriteMsg(&pb.UserMessage{ + err = this.WriteMsg(&pb.UserMessage{ MainType: comm.MainType_Notify, SubType: comm.SubType_ErrorNotify, Data: data, }) - return err + return + } else { + for _, v := range reply.Reply { + if err = this.WriteMsg(v); err != nil { + return + } + } } return nil } diff --git a/pb/comm.pb.go b/pb/comm.pb.go index 88b90b6a8..a21273297 100644 --- a/pb/comm.pb.go +++ b/pb/comm.pb.go @@ -252,10 +252,10 @@ type RPCMessageReply struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code"` - ErrorMessage string `protobuf:"bytes,2,opt,name=ErrorMessage,proto3" json:"ErrorMessage"` - ErrorData string `protobuf:"bytes,3,opt,name=ErrorData,proto3" json:"ErrorData"` - Reply *UserMessage `protobuf:"bytes,4,opt,name=Reply,proto3" json:"Reply"` + Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code"` + ErrorMessage string `protobuf:"bytes,2,opt,name=ErrorMessage,proto3" json:"ErrorMessage"` + ErrorData string `protobuf:"bytes,3,opt,name=ErrorData,proto3" json:"ErrorData"` + Reply []*UserMessage `protobuf:"bytes,4,rep,name=Reply,proto3" json:"Reply"` } func (x *RPCMessageReply) Reset() { @@ -311,7 +311,7 @@ func (x *RPCMessageReply) GetErrorData() string { return "" } -func (x *RPCMessageReply) GetReply() *UserMessage { +func (x *RPCMessageReply) GetReply() []*UserMessage { if x != nil { return x.Reply } @@ -771,7 +771,7 @@ var file_comm_proto_rawDesc = []byte{ 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x44, 0x61, 0x74, 0x61, - 0x12, 0x22, 0x0a, 0x05, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x12, 0x22, 0x0a, 0x05, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x05, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x69, 0x0a, 0x0d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, diff --git a/pb/proto/comm.proto b/pb/proto/comm.proto index 2e32a2ee0..69696ae52 100644 --- a/pb/proto/comm.proto +++ b/pb/proto/comm.proto @@ -28,7 +28,7 @@ message RPCMessageReply { ErrorCode Code = 1; string ErrorMessage = 2; string ErrorData = 3; - UserMessage Reply = 4; + repeated UserMessage Reply = 4; } //用户代理绑定Uid请求 diff --git a/services/comp_gateroute.go b/services/comp_gateroute.go index 6a761e498..566991e05 100644 --- a/services/comp_gateroute.go +++ b/services/comp_gateroute.go @@ -33,11 +33,10 @@ func NewGateRouteComp() comm.ISC_GateRouteComp { //用户协议处理函数注册的反射对象 type msghandle struct { - rcvr reflect.Value - msgType reflect.Type //消息请求类型 - replyType reflect.Type //消息回应类型 - check reflect.Method //校验函数 - handle reflect.Method //处理函数 + rcvr reflect.Value + msgType reflect.Type //消息请求类型 + check reflect.Method //校验函数 + handle reflect.Method //处理函数 } //服务网关组件 @@ -70,7 +69,7 @@ func (this *SCompGateRoute) Start() (err error) { } //业务模块注册用户消息处理路由 -func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, replyType reflect.Type, check, handele reflect.Method) { +func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, check, handele reflect.Method) { log.Debugf("注册用户路由【%s】", methodName) this.mrlock.RLock() _, ok := this.msghandles[methodName] @@ -81,11 +80,10 @@ func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value, } this.mrlock.Lock() this.msghandles[methodName] = &msghandle{ - rcvr: comp, - msgType: msg, - replyType: replyType, - check: check, - handle: handele, + rcvr: comp, + msgType: msg, + check: check, + handle: handele, } this.mrlock.Unlock() } @@ -117,9 +115,6 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag return err } - //序列化用户消息对象 - replymsg := reflect.New(msghandle.replyType.Elem()).Interface() - //调用校验接口 checkreturn := msghandle.check.Func.Call([]reflect.Value{msghandle.rcvr, reflect.ValueOf(session), reflect.ValueOf(msg)}) //读取校验结果 有错误直接返回错误码给用户 @@ -141,7 +136,7 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag //校验结果成功 处理临时数据转移 result := checkreturn[0].Interface().(map[string]interface{}) //调用用户处理函数 - handlereturn := msghandle.handle.Func.Call([]reflect.Value{msghandle.rcvr, reflect.ValueOf(session), reflect.ValueOf(result), reflect.ValueOf(msg), reflect.ValueOf(replymsg)}) + handlereturn := msghandle.handle.Func.Call([]reflect.Value{msghandle.rcvr, reflect.ValueOf(session), reflect.ValueOf(result), reflect.ValueOf(msg)}) errcode := pb.ErrorCode(handlereturn[0].Int()) if errcode != pb.ErrorCode_Success { //处理返货错误码 返回用户错误信息 log.Errorf("HandleUserMsg:%s msg:%v code:%d", method, msg, code) @@ -149,6 +144,7 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag reply.ErrorMessage = pb.GetErrorCodeMsg(errcode) return nil } + } else { //未找到消息处理函数 reply.Code = pb.ErrorCode_ReqParameterError } @@ -158,5 +154,6 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag //RPC_NoticeUserClose 接收用户离线通知 func (this *SCompGateRoute) NoticeUserClose(ctx context.Context, args *pb.NoticeUserCloseReq, reply *pb.RPCMessageReply) error { event.TriggerEvent(comm.Event_UserOffline, args.UserId) + return nil } From 09ecaa3207c29444916fe41d54e7c7f3d3891cb1 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 28 Jun 2022 17:11:00 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/core.go | 1 + comm/usersession.go | 34 ++++++++++++++++++++++++---------- modules/friend/api.go | 4 ++-- services/comp_gateroute.go | 3 ++- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/comm/core.go b/comm/core.go index bc07dafa7..7cbc4bf3d 100644 --- a/comm/core.go +++ b/comm/core.go @@ -54,6 +54,7 @@ type IUserSession interface { Bind(uid string, wokerId string) (err error) UnBind() (err error) SendMsg(mainType, subType string, msg proto.Message) (err error) + Polls() []*pb.UserMessage Close() (err error) ToString() string } diff --git a/comm/usersession.go b/comm/usersession.go index d8ff86e01..82fc50420 100644 --- a/comm/usersession.go +++ b/comm/usersession.go @@ -89,17 +89,24 @@ func (this *UserSession) UnBind() (err error) { //向用户发送消息 func (this *UserSession) SendMsg(mainType, subType string, msg proto.Message) (err error) { - reply := &pb.RPCMessageReply{} - data, _ := anypb.New(msg) log.Debugf("SendMsg to SessionId:[%s] UserId:[%s] Data: %v", this.UserId, msg) - if err := this.service.RpcCall(context.Background(), fmt.Sprintf("%s/%s", Service_Gateway, this.GatewayServiceId), string(Rpc_GatewayAgentSendMsg), &pb.AgentSendMessageReq{ - UserSessionId: this.SessionId, - MainType: mainType, - SubType: subType, - Data: data, - }, reply); err != nil { - log.Errorf("SendMsg:%s UserSession:%s UserId:%s err:%v", mainType, this.SessionId, this.UserId, err) - } + data, _ := anypb.New(msg) + this.msgqueue = append(this.msgqueue, &pb.UserMessage{ + MainType: mainType, + SubType: subType, + Data: data, + }) + // reply := &pb.RPCMessageReply{} + // data, _ := anypb.New(msg) + // log.Debugf("SendMsg to SessionId:[%s] UserId:[%s] Data: %v", this.UserId, msg) + // if err := this.service.RpcCall(context.Background(), fmt.Sprintf("%s/%s", Service_Gateway, this.GatewayServiceId), string(Rpc_GatewayAgentSendMsg), &pb.AgentSendMessageReq{ + // UserSessionId: this.SessionId, + // MainType: mainType, + // SubType: subType, + // Data: data, + // }, reply); err != nil { + // log.Errorf("SendMsg:%s UserSession:%s UserId:%s err:%v", mainType, this.SessionId, this.UserId, err) + // } return } @@ -114,6 +121,13 @@ func (this *UserSession) Close() (err error) { return } +//清空消息队列 +func (this *UserSession) Polls() []*pb.UserMessage { + msgs := this.msgqueue + this.msgqueue = this.msgqueue[:0] + return msgs +} + //打印日志需要 func (this *UserSession) ToString() string { return fmt.Sprintf("SessionId:%s UserId:%s GatewayServiceId:%s", this.SessionId, this.UserId, this.GatewayServiceId) diff --git a/modules/friend/api.go b/modules/friend/api.go index 9bb5c5785..b9e8176f6 100644 --- a/modules/friend/api.go +++ b/modules/friend/api.go @@ -18,12 +18,12 @@ const ( ) type apiComp struct { - modules.MComp_GateComp + modules.MCompGate module *Friend } func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - this.MComp_GateComp.Init(service, module, comp, options) + this.MCompGate.Init(service, module, comp, options) this.module = module.(*Friend) return } diff --git a/services/comp_gateroute.go b/services/comp_gateroute.go index 566991e05..170e64012 100644 --- a/services/comp_gateroute.go +++ b/services/comp_gateroute.go @@ -143,8 +143,9 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag reply.Code = errcode reply.ErrorMessage = pb.GetErrorCodeMsg(errcode) return nil + } else { + reply.Reply = session.Polls() } - } else { //未找到消息处理函数 reply.Code = pb.ErrorCode_ReqParameterError }