diff --git a/bin/json/game_global.json b/bin/json/game_global.json index 97dd4cae8..186fced7f 100644 --- a/bin/json/game_global.json +++ b/bin/json/game_global.json @@ -36,7 +36,7 @@ }, { "index": "init_hero", - "var": "15001, 25001", + "var": "15001,25001", "intr": "初始英雄" }, { @@ -46,7 +46,7 @@ }, { "index": "cameramax", - "var": "10.4,16.4,151.5", + "var": "0,1.54,-2.62", "intr": "镜头坐标最大值" }, { diff --git a/bin/json/game_hero.json b/bin/json/game_hero.json index 6da12b98c..5d1f0855d 100644 --- a/bin/json/game_hero.json +++ b/bin/json/game_hero.json @@ -25,7 +25,8 @@ "skill1": 110001, "skill2": 110002, "skill3": 110003, - "enteranivalue": 100 + "enteranivalue": 100, + "camerainterval": 0.5 }, { "id": 11002, @@ -53,7 +54,8 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 11003, @@ -72,7 +74,9 @@ "intr": "", "events": "EventDataSet/Hero_11003.asset", "cite": "", - "effectstay": [], + "effectstay": [ + "this,Skill/Role/11003/effect_11003_wuqitexiao" + ], "hpspace": { "x": 0, "y": -0.69, @@ -81,7 +85,8 @@ "skill1": 110004, "skill2": 110005, "skill3": 110012, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 11004, @@ -109,7 +114,8 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 11005, @@ -137,7 +143,8 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 11006, @@ -165,7 +172,8 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 11009, @@ -186,14 +194,15 @@ "cite": "", "effectstay": [], "hpspace": { - "x": 0.33, + "x": 0, "y": -0.1, - "z": 0.02 + "z": 0 }, "skill1": 110010, "skill2": 110011, "skill3": 110013, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 22002, @@ -221,7 +230,8 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 90001, @@ -249,7 +259,8 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 11011, @@ -277,7 +288,8 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 11008, @@ -305,7 +317,8 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 11017, @@ -324,7 +337,9 @@ "intr": "", "events": "EventDataSet/Hero_11017.asset", "cite": "", - "effectstay": [], + "effectstay": [ + "Bone001/Dummy001,Skill/Role/11017/effect_11017_weapon1" + ], "hpspace": { "x": 0, "y": 0, @@ -333,7 +348,8 @@ "skill1": 110006, "skill2": 110007, "skill3": 110014, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 11018, @@ -352,7 +368,10 @@ "intr": "", "events": "EventDataSet/Hero_11018.asset", "cite": "", - "effectstay": [], + "effectstay": [ + "Bip001,Skill/Role/11018/effect_11018_sleep", + "Bip001,Skill/Role/11018/effect_11018_fengsha" + ], "hpspace": { "x": 0, "y": -0.31, @@ -361,7 +380,8 @@ "skill1": 110008, "skill2": 110009, "skill3": 110015, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 11019, @@ -389,7 +409,8 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 11020, @@ -417,7 +438,8 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 11021, @@ -445,7 +467,8 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 11099, @@ -473,7 +496,8 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 12001, @@ -501,7 +525,8 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 12003, @@ -520,7 +545,9 @@ "intr": "", "events": "EventDataSet/Hero_11003.asset", "cite": "", - "effectstay": [], + "effectstay": [ + "this,Skill/Role/12003/effect_12003_wuqitexiao" + ], "hpspace": { "x": 0, "y": 0.154, @@ -529,7 +556,8 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 12009, @@ -557,7 +585,8 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 12017, @@ -576,7 +605,9 @@ "intr": "", "events": "EventDataSet/Hero_11017.asset", "cite": "", - "effectstay": [], + "effectstay": [ + "Bone001/Dummy001,Skill/Role/12017/effect_12017_weapon1_bad" + ], "hpspace": { "x": 0, "y": 0, @@ -585,7 +616,8 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 }, { "id": 12018, @@ -613,6 +645,7 @@ "skill1": 0, "skill2": 0, "skill3": 0, - "enteranivalue": 0 + "enteranivalue": 0, + "camerainterval": 0.6 } ] \ No newline at end of file diff --git a/bin/json/game_serverlist.json b/bin/json/game_serverlist.json new file mode 100644 index 000000000..1dc4001d8 --- /dev/null +++ b/bin/json/game_serverlist.json @@ -0,0 +1,30 @@ +[ + { + "id": 1, + "ip": "10.0.1.238", + "port": 7981, + "groupId": 0, + "name": "熊猫" + }, + { + "id": 2, + "ip": "10.0.1.239", + "port": 7982, + "groupId": 0, + "name": "野鸡" + }, + { + "id": 3, + "ip": "10.0.1.237", + "port": 7983, + "groupId": 0, + "name": "鸭子" + }, + { + "id": 4, + "ip": "10.0.0.9", + "port": 7984, + "groupId": 0, + "name": "乌龟" + } +] \ No newline at end of file diff --git a/bin/json/game_skillafteratk.json b/bin/json/game_skillafteratk.json index e4401add2..71e4f1b87 100644 --- a/bin/json/game_skillafteratk.json +++ b/bin/json/game_skillafteratk.json @@ -181,7 +181,7 @@ ], "EmitPR": 1000, "Type": "AddBuff", - "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001001,Round=2,Type=ProBuff,Pro1=Buff_Per_Atk,QuaType1=1,ParNum1=1,Val1=400", + "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001001,Round=2,Type=ProBuff,BufPro1=Buff_Per_Atk,BufQuaType1=1,BufParNum1=1,BufVal1=400", "AddEffect": true, "FollowSK": [], "FailFollowSK": [], @@ -199,7 +199,7 @@ ], "EmitPR": 1000, "Type": "AddBuff", - "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001002,Round=2,Type=ProBuff,Pro1=Buff_Per_Atk,QuaType1=0,ParNum1=1,Val1=400", + "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001002,Round=2,Type=ProBuff,BufPro1=Buff_Per_Atk,BufQuaType1=0,BufParNum1=1,BufVal1=400", "AddEffect": true, "FollowSK": [], "FailFollowSK": [], @@ -217,7 +217,7 @@ ], "EmitPR": 1000, "Type": "AddBuff", - "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001003,Round=2,Type=ProBuff,Pro1=Buff_Per_Def,QuaType1=1,ParNum1=1,Val1=600", + "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001003,Round=2,Type=ProBuff,BufPro1=Buff_Per_Def,BufQuaType1=1,BufParNum1=1,BufVal1=600", "AddEffect": true, "FollowSK": [], "FailFollowSK": [], @@ -235,7 +235,7 @@ ], "EmitPR": 1000, "Type": "AddBuff", - "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001004,Round=2,Type=ProBuff,Pro1=Buff_Per_Def,QuaType1=0,ParNum1=1,Val1=600", + "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001004,Round=2,Type=ProBuff,BufPro1=Buff_Per_Def,BufQuaType1=0,BufParNum1=1,BufVal1=600", "AddEffect": true, "FollowSK": [], "FailFollowSK": [], @@ -253,7 +253,7 @@ ], "EmitPR": 1000, "Type": "AddBuff", - "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001005,Round=2,Type=ProBuff,Pro1=Buff_Per_Agi,QuaType1=1,ParNum1=1,Val1=300", + "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001005,Round=2,Type=ProBuff,BufPro1=Buff_Per_Agi,BufQuaType1=1,BufParNum1=1,BufVal1=300", "AddEffect": true, "FollowSK": [], "FailFollowSK": [], @@ -271,7 +271,7 @@ ], "EmitPR": 1000, "Type": "AddBuff", - "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001006,Round=2,Type=ProBuff,Pro1=BBuff_Per_Agi,QuaType1=0,ParNum1=1,Val1=300", + "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001006,Round=2,Type=ProBuff,BufPro1=BBuff_Per_Agi,BufQuaType1=0,BufParNum1=1,BufVal1=300", "AddEffect": true, "FollowSK": [], "FailFollowSK": [], @@ -289,7 +289,7 @@ ], "EmitPR": 1000, "Type": "AddBuff", - "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001007,Round=2,Type=ProBuff,Pro1=Add_Cri,QuaType1=1,ParNum1=1,Val1=300", + "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001007,Round=2,Type=ProBuff,BufPro1=Add_Cri,BufQuaType1=1,BufParNum1=1,BufVal1=300", "AddEffect": true, "FollowSK": [], "FailFollowSK": [], @@ -307,7 +307,7 @@ ], "EmitPR": 1000, "Type": "AddBuff", - "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001008,Round=2,Type=ProBuff,Pro1=Add_Cri,QuaType1=0,ParNum1=1,Val1=300", + "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001008,Round=2,Type=ProBuff,BufPro1=Add_Cri,BufQuaType1=0,BufParNum1=1,BufVal1=300", "AddEffect": true, "FollowSK": [], "FailFollowSK": [], @@ -325,7 +325,7 @@ ], "EmitPR": 1000, "Type": "AddBuff", - "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001009,Round=2,Type=ProBuff,Pro1=SufferDam,QuaType1=1,ParNum1=1,Val1=25", + "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001009,Round=2,Type=ProBuff,BufPro1=SufferDam,BufQuaType1=1,BufParNum1=1,BufVal1=25", "AddEffect": true, "FollowSK": [], "FailFollowSK": [], @@ -343,7 +343,7 @@ ], "EmitPR": 1000, "Type": "AddBuff", - "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001010,Round=2,Type=ProBuff,Pro1=MissPr,QuaType1=1,ParNum1=1,Val1=50", + "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001010,Round=2,Type=ProBuff,BufPro1=MissPr,BufQuaType1=1,BufParNum1=1,BufVal1=50", "AddEffect": true, "FollowSK": [], "FailFollowSK": [], @@ -361,7 +361,7 @@ ], "EmitPR": 1000, "Type": "AddBuff", - "Argu": "DoVal=1,Pr=1000,NumVal=10,Id=390001011,Round=-1,Type=ProBuff,Pro1=Buff_Per_Atk,QuaType1=1,ParNum1=1,Val1=50,Pro2=SufferDam,QuaType2=0,ParNum2=10,Val2=30", + "Argu": "DoVal=1,Pr=1000,NumVal=10,Id=390001011,Round=-1,Type=ProBuff,BufPro1=Buff_Per_Atk,BufQuaType1=1,BufParNum1=1,BufVal1=50,BufPro2=SufferDam,BufQuaType2=0,BufParNum2=10,BufVal2=30", "AddEffect": false, "FollowSK": [], "FailFollowSK": [], @@ -379,7 +379,7 @@ ], "EmitPR": 1000, "Type": "AddBuff", - "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001012,Round=2,Type=ProBuff,Pro1=Add_SufCri,QuaType1=1,ParNum1=1,Val1=300", + "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001012,Round=2,Type=ProBuff,BufPro1=Add_SufCri,BufQuaType1=1,BufParNum1=1,BufVal1=300", "AddEffect": true, "FollowSK": [], "FailFollowSK": [], @@ -565,7 +565,9 @@ "Type": "Dmg", "Argu": "DoVal=1,Pr=1000,ProSou1=0,Pro1=Total_Atk,ProPar1=800", "AddEffect": false, - "FollowSK": [], + "FollowSK": [ + 290038002 + ], "FailFollowSK": [], "MustHit": false, "Tags": [ @@ -583,11 +585,9 @@ ], "EmitPR": 1000, "Type": "BuffAction", - "Argu": "DoVal=1,Pr=500,ActionType=0,BuffType=1,ID=202,ActionVal=1", + "Argu": "DoVal=1,Pr=500,ActionType=0,BuffType=1,RelyType1=1,ID1=201,ActionVal=1", "AddEffect": false, - "FollowSK": [ - 290038002 - ], + "FollowSK": [], "FailFollowSK": [], "MustHit": false, "Tags": [ @@ -705,7 +705,7 @@ ], "EmitPR": 1000, "Type": "FrontTre", - "Argu": "DoVal=1,Pr=1000,FrontSkId=290042001,Par=300", + "Argu": "DoVal=1,Pr=1000,Par=300", "AddEffect": false, "FollowSK": [], "FailFollowSK": [], @@ -785,7 +785,7 @@ ], "EmitPR": 1000, "Type": "BuffAction", - "Argu": "DoVal=1,Pr=1000,ActionType=0,BuffType=1,ID=202,ActionVal=-1", + "Argu": "DoVal=1,Pr=1000,ActionType=0,BuffType=1,RelyType1=1,ID1=201,ActionVal=-1", "AddEffect": false, "FollowSK": [ 290046002 @@ -807,7 +807,7 @@ ], "EmitPR": 1000, "Type": "Dmg", - "Argu": "DoVal=1,Pr=1000,ProSou1=0,Pro1=Total_Atk,ProPar1=800,TempProTarget=0,TempPro=CauseDam,TempFrontType=3,TempFrontID=201,TempFrontTpyeVal=1,TempFrontQuaType=1,TempFrontVal=30", + "Argu": "DoVal=1,Pr=1000,ProSou1=0,Pro1=Total_Atk,ProPar1=800,TempProTarget=0,TempPro=CauseDam,TempFrontSkId=290046001,TempFrontType=3,TempFrontID=201,TempFrontTpyeVal=1,TempFrontQuaType=1,TempFrontVal=30", "AddEffect": false, "FollowSK": [], "FailFollowSK": [], @@ -847,7 +847,7 @@ ], "EmitPR": 1000, "Type": "FrontDmg", - "Argu": "DoVal=1,Pr=1000,FrontSkId=290047001,DmgSourceType=0,DmgPar=400", + "Argu": "DoVal=1,Pr=1000,DmgSourceType=0,DmgPar=400", "AddEffect": false, "FollowSK": [], "FailFollowSK": [], @@ -961,7 +961,7 @@ ], "EmitPR": 1000, "Type": "BuffAction", - "Argu": "DoVal=1,Pr=1000,ActionType=0,BuffType1=1,ID1=202,RelyType1=1,BuffType2=0,ID2=390001004,RelyType2=0,ActionVal1=-1", + "Argu": "DoVal=1,Pr=1000,ActionType=0,BuffType1=1,RelyType1=1,ID1=202,BuffType2=0,RelyType2=0,ID2=390001004,ActionVal1=-1", "AddEffect": false, "FollowSK": [], "FailFollowSK": [], @@ -979,7 +979,7 @@ ], "EmitPR": 1000, "Type": "BuffAction", - "Argu": "DoVal=1,Pr=1000,ActionType=0,BuffType1=1,ID1=201,RelyType1=1,ActionVal=-1", + "Argu": "DoVal=1,Pr=1000,ActionType=0,BuffType1=1,RelyType1=1,ID1=201,ActionVal=-1", "AddEffect": true, "FollowSK": [], "FailFollowSK": [], @@ -997,7 +997,7 @@ ], "EmitPR": 1000, "Type": "BuffAction", - "Argu": "DoVal=1,Pr=1000,ActionType=1,BuffType1=1,ID1=201,RelyType1=1,ActionVal=-1,Tag=0", + "Argu": "DoVal=1,Pr=1000,ActionType=1,BuffType1=1,RelyType1=1,ID1=201,ActionVal=-1,Tag=0", "AddEffect": true, "FollowSK": [], "FailFollowSK": [], @@ -1015,7 +1015,7 @@ ], "EmitPR": 1000, "Type": "BuffAction", - "Argu": "DoVal=1,Pr=1000,ActionType=0,BuffType1=1,ID1=202,RelyType1=1,ActionVal=-1,Tag=1", + "Argu": "DoVal=1,Pr=1000,ActionType=0,BuffType1=1,RelyType1=1,ID1=202,ActionVal=-1,Tag=1", "AddEffect": true, "FollowSK": [], "FailFollowSK": [], @@ -1033,7 +1033,7 @@ ], "EmitPR": 1000, "Type": "BuffCD", - "Argu": "DoVal=1,Pr=1000,ActionType=0,BuffType1=1,ID1=201,RelyType1=1,QuaType=1,Val=1", + "Argu": "DoVal=1,Pr=1000,ActionType=0,BuffType1=1,RelyType1=1,ID1=201,QuaType=1,Val=1", "AddEffect": false, "FollowSK": [], "FailFollowSK": [], @@ -1051,7 +1051,7 @@ ], "EmitPR": 1000, "Type": "BuffCD", - "Argu": "DoVal=1,Pr=1000,ActionType=0,BuffType1=1,ID1=202,RelyType1=1,QuaType=1,Val=1", + "Argu": "DoVal=1,Pr=1000,ActionType=0,BuffType1=1,RelyType1=1,ID1=202,QuaType=1,Val=1", "AddEffect": true, "FollowSK": [], "FailFollowSK": [], @@ -1279,7 +1279,7 @@ ], "EmitPR": 1000, "Type": "AddBuff", - "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001001,Round=2,Type=ProBuff,Pro1=Buff_Per_Atk,QuaType1=1,ParNum1=1,Val1=400", + "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001001,Round=2,Type=ProBuff,BufPro1=Buff_Per_Atk,BufQuaType1=1,BufParNum1=1,BufVal1=400", "AddEffect": false, "FollowSK": [], "FailFollowSK": [], @@ -1297,7 +1297,7 @@ ], "EmitPR": 1000, "Type": "AddBuff", - "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001007,Round=2,Type=ProBuff,Pro1=Add_Cri,QuaType1=1,ParNum1=1,Val1=300", + "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001007,Round=2,Type=ProBuff,BufPro1=Add_Cri,BufQuaType1=1,BufParNum1=1,BufVal1=300", "AddEffect": false, "FollowSK": [], "FailFollowSK": [], @@ -1315,7 +1315,43 @@ ], "EmitPR": 1000, "Type": "AddBuff", - "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001003,Round=2,Type=ProBuff,Pro1=Buff_Per_Def,QuaType1=1,ParNum1=1,Val1=600", + "Argu": "DoVal=1,Pr=1000,NumVal=1,Id=390001003,Round=2,Type=ProBuff,BufPro1=Buff_Per_Def,BufQuaType1=1,BufParNum1=1,BufVal1=600", + "AddEffect": false, + "FollowSK": [], + "FailFollowSK": [], + "MustHit": false, + "Tags": [] + }, + { + "Id": 290066001, + "Desc": "对敌方随机目标造成80%攻击力伤害", + "From": 2, + "Limit": 1, + "Where": [], + "Order": [ + "Type=Rnd" + ], + "EmitPR": 1000, + "Type": "Dmg", + "Argu": "DoVal=1,Pr=1000,ProSou1=0,Pro1=Total_Atk,ProPar1=800", + "AddEffect": false, + "FollowSK": [ + 290066002 + ], + "FailFollowSK": [], + "MustHit": false, + "Tags": [] + }, + { + "Id": 290066002, + "Desc": "50%概率额外造成50%防御力伤害", + "From": 0, + "Limit": 0, + "Where": [], + "Order": [], + "EmitPR": 500, + "Type": "Dmg", + "Argu": "DoVal=1,Pr=1000,Id=290066001,ProSou1=0,Pro1=Total_Def,ProPar1=500", "AddEffect": false, "FollowSK": [], "FailFollowSK": [], diff --git a/bin/json/game_skillatk.json b/bin/json/game_skillatk.json index 51bd5f696..76c6852b5 100644 --- a/bin/json/game_skillatk.json +++ b/bin/json/game_skillatk.json @@ -2668,5 +2668,53 @@ ] } ] + }, + { + "Id": 190066000, + "Name": "", + "Type": 1, + "Desc": "对敌方随机目标造成80%攻击力伤害,50%概率额外造成50%防御力伤害", + "MaxLV": 6, + "CD": [ + 4, + 4, + 4, + 4, + 4, + 4 + ], + "Target": 1, + "ChildSkill": [ + { + "Id": [ + 290066001 + ] + }, + { + "Id": [ + 290066001 + ] + }, + { + "Id": [ + 290066001 + ] + }, + { + "Id": [ + 290066001 + ] + }, + { + "Id": [ + 290066001 + ] + }, + { + "Id": [ + 290066001 + ] + } + ] } ] \ No newline at end of file diff --git a/bin/json/game_taskround.json b/bin/json/game_taskround.json index 6c583df18..a5b446996 100644 --- a/bin/json/game_taskround.json +++ b/bin/json/game_taskround.json @@ -271,7 +271,7 @@ "condition_second": 1, "condition_condition": 5, "active": 0, - "id_after": 20003, + "id_after": 30102, "reword": [ { "a": "attr", @@ -294,7 +294,7 @@ "condition_second": 2, "condition_condition": 5, "active": 0, - "id_after": 20004, + "id_after": 30103, "reword": [ { "a": "attr", @@ -317,7 +317,7 @@ "condition_second": 3, "condition_condition": 5, "active": 0, - "id_after": 20005, + "id_after": 30104, "reword": [ { "a": "attr", @@ -340,7 +340,7 @@ "condition_second": 4, "condition_condition": 5, "active": 0, - "id_after": 20006, + "id_after": 30105, "reword": [ { "a": "attr", @@ -363,7 +363,7 @@ "condition_second": 5, "condition_condition": 5, "active": 0, - "id_after": 20007, + "id_after": 30106, "reword": [ { "a": "attr", @@ -386,7 +386,7 @@ "condition_second": 6, "condition_condition": 5, "active": 0, - "id_after": 20008, + "id_after": 30107, "reword": [ { "a": "attr", @@ -409,7 +409,7 @@ "condition_second": 7, "condition_condition": 5, "active": 0, - "id_after": 20009, + "id_after": 30108, "reword": [ { "a": "attr", @@ -432,7 +432,7 @@ "condition_second": 8, "condition_condition": 5, "active": 0, - "id_after": 20010, + "id_after": 30109, "reword": [ { "a": "attr", @@ -455,7 +455,7 @@ "condition_second": 9, "condition_condition": 5, "active": 0, - "id_after": 20011, + "id_after": 30110, "reword": [ { "a": "attr", @@ -478,7 +478,7 @@ "condition_second": 10, "condition_condition": 5, "active": 0, - "id_after": 20012, + "id_after": 30111, "reword": [ { "a": "attr", @@ -501,7 +501,7 @@ "condition_second": 11, "condition_condition": 5, "active": 0, - "id_after": 20013, + "id_after": 30112, "reword": [ { "a": "attr", @@ -524,7 +524,7 @@ "condition_second": 12, "condition_condition": 5, "active": 0, - "id_after": 20014, + "id_after": 30113, "reword": [ { "a": "attr", @@ -547,7 +547,7 @@ "condition_second": 13, "condition_condition": 5, "active": 0, - "id_after": 20015, + "id_after": 30114, "reword": [ { "a": "attr", @@ -570,7 +570,7 @@ "condition_second": 14, "condition_condition": 5, "active": 0, - "id_after": 20016, + "id_after": 30115, "reword": [ { "a": "attr", @@ -593,7 +593,7 @@ "condition_second": 15, "condition_condition": 5, "active": 0, - "id_after": 20017, + "id_after": 30116, "reword": [ { "a": "attr", @@ -616,7 +616,7 @@ "condition_second": 16, "condition_condition": 5, "active": 0, - "id_after": 20018, + "id_after": 30117, "reword": [ { "a": "attr", @@ -639,7 +639,7 @@ "condition_second": 17, "condition_condition": 5, "active": 0, - "id_after": 20019, + "id_after": 30118, "reword": [ { "a": "attr", @@ -662,7 +662,7 @@ "condition_second": 18, "condition_condition": 5, "active": 0, - "id_after": 20020, + "id_after": 30119, "reword": [ { "a": "attr", diff --git a/bin/json/game_ui.json b/bin/json/game_ui.json index c16149869..978cf680f 100644 --- a/bin/json/game_ui.json +++ b/bin/json/game_ui.json @@ -430,5 +430,17 @@ "packagename": "zhandou", "comname": "battlereadywindow2", "des": "战斗布阵界面" + }, + { + "id": "roledetail", + "file": "RoleDetailWindow", + "unloadpkg": 0, + "loadtype": 1, + "full": 1, + "blur": 0, + "package": "roledetails/roledetails", + "packagename": "roledetails", + "comname": "main", + "des": "英雄详细信息" } ] \ No newline at end of file diff --git a/cmd/bench/base.go b/cmd/bench/base.go new file mode 100644 index 000000000..37bd83a3c --- /dev/null +++ b/cmd/bench/base.go @@ -0,0 +1,72 @@ +package bench + +import ( + "fmt" + "testing" +) + +type Target struct { + //这里定义需要测试的方法 +} + +//测试基准 +type Benchmark struct { + Parallelism int //并行数目 + Data interface{} //bench 参数数据 + TargetBuilder TargetBuilder +} + +//构建基准目标 +type TargetBuilder struct { + Name string + Make func(bench Benchmark) (Target, error) +} + +func compose(parallelisms, dataSize []int, numKeys int, builders []TargetBuilder) []Benchmark { + benchmarks := make([]Benchmark, 0, len(parallelisms)*len(dataSize)*len(builders)) + + for _, p := range parallelisms { + for _, _ = range dataSize { + + for _, builder := range builders { + benchmarks = append(benchmarks, Benchmark{ + Parallelism: p, + // Data: d, + TargetBuilder: builder, + }) + } + + } + } + + return benchmarks +} + +func RunBenchmark(b *testing.B, benchmarks []Benchmark) { + for _, bench := range benchmarks { + bench := bench + b.Run(fmt.Sprintf("%s-parallelism(%d)- ", bench.TargetBuilder.Name, bench.Parallelism), func(b *testing.B) { + // target, err := bench.TargetBuilder.Make(bench) + // if err != nil { + // b.Fatalf("%s setup fail: %v", bench.TargetBuilder.Name, err) + // } + if bench.Parallelism == 0 { + b.ResetTimer() + for i := 0; i < b.N; i++ { + //执行测试方法 + + } + + } else { + b.SetParallelism(bench.Parallelism) //指定并行数目 + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { //并行执行 + for pb.Next() { + //执行测试方法 + } + }) + } + b.StopTimer() + }) + } +} diff --git a/cmd/bench/main_test.go b/cmd/bench/main_test.go new file mode 100644 index 000000000..076576295 --- /dev/null +++ b/cmd/bench/main_test.go @@ -0,0 +1,31 @@ +package bench + +import ( + "testing" +) + +func BenchmarkMarsh(b *testing.B) { + var ( + // ncpu = runtime.NumCPU() + parallelisms = []int{4, 16, 64} + dataSizes = []int{100, 1000, 10000} + numKeys = 1024 + builders = []TargetBuilder{ + { + Name: "测试名1", + Make: func(bench Benchmark) (Target, error) { + + return Target{}, nil + }, + }, + { + Name: "测试名2", + Make: func(bench Benchmark) (Target, error) { + return Target{}, nil + }, + }, + } + ) + + RunBenchmark(b, compose(parallelisms, dataSizes, numKeys, builders)) +} diff --git a/cmd/robot/hero.go b/cmd/robot/hero.go index 06bb8f1f0..ae2009830 100644 --- a/cmd/robot/hero.go +++ b/cmd/robot/hero.go @@ -26,14 +26,16 @@ var ( }, enabled: true, }, { + Desc: "英雄详情", mainType: string(comm.ModuleHero), subType: hero.HeroSubTypeInfo, req: &pb.HeroInfoReq{ - HeroId: "62baac19aa7c09b3679be57c", + HeroId: "62c676d57deea8b9af8884a5", }, rsp: &pb.HeroInfoResp{}, // enabled: true, }, { + Desc: "抽卡", mainType: string(comm.ModuleHero), subType: hero.HeroSubTypeChouka, req: &pb.HeroChoukaReq{ diff --git a/cmd/robot/task.go b/cmd/robot/task.go index 76be133cc..34f7d88f0 100644 --- a/cmd/robot/task.go +++ b/cmd/robot/task.go @@ -26,7 +26,7 @@ var ( fmt.Printf("%v \n", v) } }, - enabled: true, + // enabled: true, }, { Desc: "领取任务奖励", mainType: string(comm.ModuleTask), @@ -38,11 +38,24 @@ var ( rsp: &pb.TaskReceiveResp{}, // enabled: true, }, { + Desc: "活跃度", mainType: string(comm.ModuleTask), - subType: "active", - req: &pb.TaskActiveReq{}, - rsp: &pb.TaskActiveResp{}, - // enabled: true, + subType: task.TaskSubTypeActiveList, + req: &pb.TaskActiveListReq{ + TaskTag: int32(comm.TASK_DAILY), + }, + rsp: &pb.TaskActiveListResp{}, + // enabled: true, + }, { + Desc: "活跃度领取", + mainType: string(comm.ModuleTask), + subType: task.TaskSubTypeActiveReceive, + req: &pb.TaskActiveReceiveReq{ + Id: "62c676d57deea8b9af8884fb", + TaskTag: int32(comm.TASK_DAILY), + }, + rsp: &pb.TaskActiveReceiveResp{}, + // enabled: true, }, } ) diff --git a/cmd/robot/user.go b/cmd/robot/user.go index e74b74ab6..c714ec514 100644 --- a/cmd/robot/user.go +++ b/cmd/robot/user.go @@ -14,17 +14,20 @@ var user_builders = []*TestCase{ mainType: string(comm.ModuleUser), subType: user.UserSubTypeCreate, req: &pb.UserCreateReq{ //设置请求参数 - NickName: "乐谷70614", + NickName: "乐谷70616", }, - rsp: &pb.UserCreateResp{}, + rsp: &pb.UserCreateResp{}, // enabled: true, }, { Desc: "添加资源", mainType: string(comm.ModuleUser), subType: user.UserSubTypeAddRes, req: &pb.UserAddResReq{ //设置请求参数 - ResType: comm.ResGold, - Count: 100, + Res: &pb.UserAssets{ + A: comm.ResGold, + T:"", + N: 100, + }, }, rsp: &pb.UserAddResResp{}, // enabled: true, diff --git a/comm/imodule.go b/comm/imodule.go index bd95682cf..95b25e01f 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -35,8 +35,6 @@ type ( IHero interface { //查询用户卡片数量 QueryHeroAmount(uId string, heroCfgId int32) (amount uint32) - //消耗卡片 - ConsumeCard(uId string, heroCfgId int32, count int32) (code pb.ErrorCode) //创建新英雄 CreateHero(uid string, heroCfgId ...int32) error @@ -78,11 +76,11 @@ type ( //任务 ITask interface { //初始化用户任务 - InitTask(uid string, taskTag TaskTag) (code pb.ErrorCode) + InitTask(uid string, taskTag TaskTag) //初始化 日常/周常/成就 - InitTaskAll(uid string) (code pb.ErrorCode) + InitTaskAll(uid string) //清空任务 - ResetTask(uid string, taskTag TaskTag) (code pb.ErrorCode) + ResetTask(uid string, taskTag TaskTag) //任务通知 SendToTask(uid string, taskType TaskType, param *pb.TaskParam) (code pb.ErrorCode) } diff --git a/lego/sys/rpcx/service.go b/lego/sys/rpcx/service.go index af8ab64c3..b8ee128d3 100644 --- a/lego/sys/rpcx/service.go +++ b/lego/sys/rpcx/service.go @@ -62,7 +62,7 @@ type Service struct { func (this *Service) Start() (err error) { go func() { if err = this.server.Serve("tcp", this.options.ServiceAddr); err != nil { - this.Errorf("rpcx server exit!") + this.Warnf("rpcx server exit:%v", err) } }() return diff --git a/modules/hero/api_awaken.go b/modules/hero/api_awaken.go index e88cddf5b..9d95c0fd9 100644 --- a/modules/hero/api_awaken.go +++ b/modules/hero/api_awaken.go @@ -24,19 +24,13 @@ func (this *apiComp) AwakenCheck(session comm.IUserSession, req *pb.HeroAwakenRe func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (code pb.ErrorCode, data proto.Message) { var ( awakenData *cfg.Game_heroAwakenData + _hero *pb.DBHero ) - _hero, err := this.module.GetHero(session.GetUserId(), req.HeroObjID) - defer func() { - if code == pb.ErrorCode_Success { - session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroAwakenResp{Hero: _hero}) - } - }() - if err != pb.ErrorCode_Success { - code = pb.ErrorCode_HeroNoExist + code = this.AwakenCheck(session, req) // check + if code != pb.ErrorCode_Success { return } - - code = this.AwakenCheck(session, req) // check + _hero, code = this.module.GetHero(session.GetUserId(), req.HeroObjID) if code != pb.ErrorCode_Success { return } @@ -84,6 +78,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c if err1 != nil { code = pb.ErrorCode_DBError log.Errorf("update hero skill failed:%v", err1) + return } } else { // 加属性 property := make(map[string]int32, 0) @@ -98,6 +93,6 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c if err1 != nil { log.Errorf("PushHeroProperty err!") } - + session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroAwakenResp{Hero: _hero}) return } diff --git a/modules/hero/api_chouka.go b/modules/hero/api_chouka.go index 8746a36fb..a310f149b 100644 --- a/modules/hero/api_chouka.go +++ b/modules/hero/api_chouka.go @@ -2,7 +2,6 @@ package hero import ( "go_dreamfactory/comm" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "go_dreamfactory/utils" @@ -33,12 +32,7 @@ func (this *apiComp) Chouka(session comm.IUserSession, req *pb.HeroChoukaReq) (c return } - heroes, err := this.module.modelHero.getHeroList(session.GetUserId()) - if err != nil { - log.Errorf("%v", err) - code = pb.ErrorCode_DBError - return - } - rsp.Heroes = heroes + rsp.Heroes = this.module.modelHero.getHeroList(session.GetUserId()) + return } diff --git a/modules/hero/api_info.go b/modules/hero/api_info.go index 5e7024a30..f69a08521 100644 --- a/modules/hero/api_info.go +++ b/modules/hero/api_info.go @@ -10,7 +10,7 @@ import ( //参数校验 func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.HeroInfoReq) (code pb.ErrorCode) { - if req.HeroId != "" { + if req.HeroId == "" { code = pb.ErrorCode_ReqParameterError } return diff --git a/modules/hero/api_list.go b/modules/hero/api_list.go index 32c4928ab..57b1f5cf8 100644 --- a/modules/hero/api_list.go +++ b/modules/hero/api_list.go @@ -24,13 +24,6 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.HeroListReq) (code utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), HeroSubTypeList, req, rsp) }() - list, err := this.module.modelHero.getHeroList(session.GetUserId()) - if err != nil { - code = pb.ErrorCode_DBError - return - } - - rsp.List = list - + rsp.List = this.module.GetHeroList(session.GetUserId()) return } diff --git a/modules/hero/api_lock.go b/modules/hero/api_lock.go index 57ef87610..69dddb69c 100644 --- a/modules/hero/api_lock.go +++ b/modules/hero/api_lock.go @@ -20,18 +20,14 @@ func (this *apiComp) LockCheck(session comm.IUserSession, req *pb.HeroLockReq) ( /// 英雄锁定 func (this *apiComp) Lock(session comm.IUserSession, req *pb.HeroLockReq) (code pb.ErrorCode, data proto.Message) { - - _hero, err := this.module.GetHero(session.GetUserId(), req.Heroid) - defer func() { - if code == pb.ErrorCode_Success { - session.SendMsg(string(this.module.GetType()), HeroLock, &pb.HeroAwakenResp{Hero: _hero}) - } - }() - if err != pb.ErrorCode_Success { - code = pb.ErrorCode_HeroNoExist + var ( + _hero *pb.DBHero + ) + code = this.LockCheck(session, req) // check + if code != pb.ErrorCode_Success { return } - code = this.LockCheck(session, req) // check + _hero, code = this.module.GetHero(session.GetUserId(), req.Heroid) if code != pb.ErrorCode_Success { return } @@ -40,11 +36,12 @@ func (this *apiComp) Lock(session comm.IUserSession, req *pb.HeroLockReq) (code "block": _hero.Block, } // 保存数据 - err1 := this.module.modelHero.modifyHeroData(session.GetUserId(), _hero.Id, _heroMap) - if err1 != nil { + err := this.module.modelHero.modifyHeroData(session.GetUserId(), _hero.Id, _heroMap) + if err != nil { code = pb.ErrorCode_DBError - log.Errorf("update hero skill failed:%v", err1) + log.Errorf("update hero skill failed:%v", err) + return } - + session.SendMsg(string(this.module.GetType()), HeroLock, &pb.HeroAwakenResp{Hero: _hero}) return } diff --git a/modules/hero/api_resonance.go b/modules/hero/api_resonance.go index dcc5f2f1a..c318c9ce5 100644 --- a/modules/hero/api_resonance.go +++ b/modules/hero/api_resonance.go @@ -15,6 +15,7 @@ func (this *apiComp) ResonanceCheck(session comm.IUserSession, req *pb.HeroReson code = pb.ErrorCode_ReqParameterError return } + return } @@ -23,19 +24,16 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR var ( szCostHero map[string]int32 // k 消耗卡牌对象 v 数量 totalCostCard int32 //消耗卡总数量 + _hero *pb.DBHero + _costHero *pb.DBHero ) szCostHero = make(map[string]int32, 0) - _hero, code := this.module.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在 - defer func() { - if code == pb.ErrorCode_Success { - session.SendMsg(string(this.module.GetType()), Resonance, &pb.HeroResonanceResp{Hero: _hero}) - } - }() + code = this.ResonanceCheck(session, req) // check if code != pb.ErrorCode_Success { return } - code = this.ResonanceCheck(session, req) // check + _hero, code = this.module.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在 if code != pb.ErrorCode_Success { return } @@ -53,7 +51,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR code = pb.ErrorCode_HeroMaxResonate // 共鸣次数已满 return } - var _costHero *pb.DBHero + for k, v := range szCostHero { for _, v1 := range resonConfig.Heroneed { @@ -67,7 +65,6 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR } _costHero, code = this.module.GetHero(session.GetUserId(), k) // 查询消耗卡是否存在 if code != pb.ErrorCode_Success { // 英雄被锁不能消耗 - code = pb.ErrorCode_HeroNoEnough return } if _costHero.Block { @@ -87,7 +84,6 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR for _, v := range req.CostObjID { code = this.module.DelCard(session.GetUserId(), v, 1) // 删除材料卡 if code != pb.ErrorCode_Success { - code = pb.ErrorCode_DBError return } } @@ -110,6 +106,8 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 if err1 != nil { log.Errorf("update hero skill failed:%v", err1) + code = pb.ErrorCode_DBError + return } // 返还对应初始星级的卡 for _, v := range resonConfig.Prize { @@ -128,5 +126,6 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR if err1 != nil { log.Errorf("PushHeroProperty err!") } + session.SendMsg(string(this.module.GetType()), Resonance, &pb.HeroResonanceResp{Hero: _hero}) return } diff --git a/modules/hero/api_resonanceReset.go b/modules/hero/api_resonanceReset.go index 783d62116..073498a19 100644 --- a/modules/hero/api_resonanceReset.go +++ b/modules/hero/api_resonanceReset.go @@ -20,18 +20,20 @@ func (this *apiComp) ResonanceResetCheck(session comm.IUserSession, req *pb.Hero /// 英雄共鸣 func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroResonanceResetReq) (code pb.ErrorCode, data proto.Message) { - - _hero, code := this.module.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在 - defer func() { - if code == pb.ErrorCode_Success { - session.SendMsg(string(this.module.GetType()), ResonanceReset, &pb.HeroResonanceResetResp{Hero: _hero, Energy: _hero.ResonateNum}) - } - }() + var ( + _hero *pb.DBHero + ) code = this.ResonanceResetCheck(session, req) // check if code != pb.ErrorCode_Success { return } + _hero, code = this.module.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在 + if code != pb.ErrorCode_Success { + code = pb.ErrorCode_HeroNoExist + return + } + if _hero.ResonateNum <= 0 { // 没有共鸣 不允许重置 code = pb.ErrorCode_HeroNoResonate return @@ -75,11 +77,13 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 if err1 != nil { log.Errorf("update hero skill failed:%v", err1) + code = pb.ErrorCode_DBError + return } err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化 if err1 != nil { log.Errorf("PushHeroProperty err!") } - + session.SendMsg(string(this.module.GetType()), ResonanceReset, &pb.HeroResonanceResetResp{Hero: _hero, Energy: _hero.ResonateNum}) return } diff --git a/modules/hero/api_resonanceSelect.go b/modules/hero/api_resonanceSelect.go index 87d7c4875..a55a0fb23 100644 --- a/modules/hero/api_resonanceSelect.go +++ b/modules/hero/api_resonanceSelect.go @@ -14,22 +14,23 @@ func (this *apiComp) ResonanceUseEnergyCheck(session comm.IUserSession, req *pb. if len(req.HeroObjID) == 0 || req.UseEnergy <= 0 || req.UseType < 0 || req.UseType > 3 { code = pb.ErrorCode_ReqParameterError } + return } func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroResonanceUseEnergyReq) (code pb.ErrorCode, data proto.Message) { - - _hero, code := this.module.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在 - defer func() { - if code == pb.ErrorCode_Success { - session.SendMsg(string(this.module.GetType()), ResonanceUseEnergy, &pb.HeroResonanceUseEnergyResp{Hero: _hero}) - } - }() + var ( + _hero *pb.DBHero + ) code = this.ResonanceUseEnergyCheck(session, req) // check if code != pb.ErrorCode_Success { return } + _hero, code = this.module.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在 + if code != pb.ErrorCode_Success { + return + } if _hero.DistributionResonate < req.UseEnergy { // 能量点数不够 code = pb.ErrorCode_HeroNoEnergy return @@ -46,6 +47,7 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroR if err1 != nil { code = pb.ErrorCode_DBError log.Errorf("update hero skill failed:%v", err1) + return } // 计算属性 resonConfig, errr := this.module.configure.GetHeroResonanceConfig(_hero.HeroID) @@ -69,5 +71,6 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroR if err1 != nil { log.Errorf("PushHeroProperty err!") } + session.SendMsg(string(this.module.GetType()), ResonanceUseEnergy, &pb.HeroResonanceUseEnergyResp{Hero: _hero}) return } diff --git a/modules/hero/api_skillUp.go b/modules/hero/api_skillUp.go index c643e1e66..a82e91673 100644 --- a/modules/hero/api_skillUp.go +++ b/modules/hero/api_skillUp.go @@ -16,6 +16,7 @@ func (this *apiComp) StrengthenUpSkillCheck(session comm.IUserSession, req *pb.H code = pb.ErrorCode_ReqParameterError return } + return } @@ -29,27 +30,22 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt tmpValue int32 // 临时对象 存放累加权重 tagColor int32 // 目标卡品质 costColor int32 // 消耗卡品质 + _hero *pb.DBHero // 操作的英雄 + _costHero *pb.DBHero // 消耗的英雄 ) tmpUpSkillID = make(map[int32]*pb.SkillData, 0) probability = make(map[int32]int32, 0) - _hero, err := this.module.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在 - defer func() { - if code == pb.ErrorCode_Success { - session.SendMsg(string(this.module.GetType()), StrengthenUpSkill, &pb.HeroStrengthenUpSkillResp{Hero: _hero}) - } - }() code = this.StrengthenUpSkillCheck(session, req) // check if code != pb.ErrorCode_Success { return } - if err != pb.ErrorCode_Success { - code = pb.ErrorCode_HeroNoExist + + _hero, code = this.module.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在 + if code != pb.ErrorCode_Success { return } - - _costHero, err := this.module.GetHero(session.GetUserId(), req.CostCardObj) // 查询消耗卡是否存在 - if err != pb.ErrorCode_Success { - code = pb.ErrorCode_HeroNoExist + _costHero, code = this.module.GetHero(session.GetUserId(), req.CostCardObj) // 查询消耗卡是否存在 + if code != pb.ErrorCode_Success { return } if _costHero.Block { // 锁定的卡不允许被消耗 @@ -76,12 +72,9 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt config, err1 := this.module.configure.GetHeroSkillUpConfig() if err1 != nil { + code = pb.ErrorCode_ConfigNoFound return } - // 先随机一个没有升满 - for _, value := range config.GetDataList() { - log.Debugf("%d", value.Hid) - } for index, skill := range _hero.NormalSkill { skillMaxLv := this.module.configure.GetHeroSkillMaxLvConfig(uint32(skill.SkillID)) @@ -127,7 +120,9 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt } err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 if err1 != nil { - log.Errorf("update hero skill failed:%v", err) + log.Errorf("update hero skill failed:%v", err1) + code = pb.ErrorCode_DBError + return } // 扣除材料 code = this.module.DelCard(session.GetUserId(), req.CostCardObj, 1) @@ -139,5 +134,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt if err1 != nil { log.Errorf("PushHeroProperty err!") } + + session.SendMsg(string(this.module.GetType()), StrengthenUpSkill, &pb.HeroStrengthenUpSkillResp{Hero: _hero}) return } diff --git a/modules/hero/api_starUp.go b/modules/hero/api_starUp.go index c7ba7d441..4a100d04c 100644 --- a/modules/hero/api_starUp.go +++ b/modules/hero/api_starUp.go @@ -14,6 +14,7 @@ func (this *apiComp) StrengthenUpStarCheck(session comm.IUserSession, req *pb.He if req.HeroObjID == "" || len(req.Hero) == 0 || len(req.HeroRace) == 0 { code = pb.ErrorCode_ReqParameterError } + return } @@ -22,21 +23,19 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr var ( target *cfg.Game_heroStarupData // 配置表目标升星英雄信息 costRaceCount int32 + _hero *pb.DBHero // 目标英雄 + raceHero *pb.DBHero // 消耗阵容的英雄 + tagHero *pb.DBHero // 消耗指定英雄 ) - _hero, err := this.module.GetHero(session.GetUserId(), req.HeroObjID) - defer func() { - if code == pb.ErrorCode_Success { - session.SendMsg(string(this.module.GetType()), StrengthenUpStar, &pb.HeroStrengthenUpStarResp{Hero: _hero}) - } - }() code = this.StrengthenUpStarCheck(session, req) // check if code != pb.ErrorCode_Success { return } - if err != pb.ErrorCode_Success { - code = pb.ErrorCode_HeroNoExist + _hero, code = this.module.GetHero(session.GetUserId(), req.HeroObjID) + if code != pb.ErrorCode_Success { return } + // 校验指定英雄 tagHeroConfig, err1 := this.module.configure.GetHeroStarupConfig() if err1 != nil { @@ -56,8 +55,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr } // 指定英雄消耗校验 for _, v := range req.Hero { - if tagHero, err := this.module.GetHero(session.GetUserId(), v.CostCardObj); err != pb.ErrorCode_Success { - code = pb.ErrorCode_ReqParameterError + if tagHero, code = this.module.GetHero(session.GetUserId(), v.CostCardObj); code != pb.ErrorCode_Success { return } else { if tagHero.Block { // 锁定的卡不允许被消耗 @@ -77,8 +75,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr } // 校验阵容英雄消耗 for _, v := range req.HeroRace { - if raceHero, err := this.module.GetHero(session.GetUserId(), v.CostCardObj); err != pb.ErrorCode_Success { - code = pb.ErrorCode_ReqParameterError + if raceHero, code = this.module.GetHero(session.GetUserId(), v.CostCardObj); code != pb.ErrorCode_Success { return } else { if raceHero.Block { // 锁定的卡不允许被消耗 @@ -142,5 +139,9 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr } } code = this.module.modelHero.HeroStarUp(session, _hero) // 执行升星操作 + if code != pb.ErrorCode_Success { + return + } + session.SendMsg(string(this.module.GetType()), StrengthenUpStar, &pb.HeroStrengthenUpStarResp{Hero: _hero}) return } diff --git a/modules/hero/api_strengthen.go b/modules/hero/api_strengthen.go index 9e4acedf8..6d735d5f1 100644 --- a/modules/hero/api_strengthen.go +++ b/modules/hero/api_strengthen.go @@ -15,6 +15,7 @@ func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.Hero code = pb.ErrorCode_ReqParameterError return } + return } @@ -22,31 +23,25 @@ func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.Hero func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStrengthenUplvReq) (code pb.ErrorCode, data proto.Message) { var ( - curLv int32 - curExp int32 // 当前英雄的经验 - addExp int32 // 需要增加的经验 - costRes map[string][]*cfg.Game_atn // 需要消耗的资源 + curLv int32 + curExp int32 // 当前英雄的经验 + addExp int32 // 需要增加的经验 + costRes map[string][]*cfg.Game_atn // 需要消耗的资源 + _hero *pb.DBHero // 目标英雄 + _expHero *pb.DBHero // 消耗英雄 ) costRes = make(map[string][]*cfg.Game_atn, 0) - _hero, err := this.module.GetHero(session.GetUserId(), req.HeroObjID) // 校验升级的对象是否存在 - defer func() { - if code == pb.ErrorCode_Success { - session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{Hero: _hero}) - } - }() code = this.StrengthenUplvCheck(session, req) // check if code != pb.ErrorCode_Success { return } - if err != pb.ErrorCode_Success { - code = pb.ErrorCode_HeroNoExist + _hero, code = this.module.GetHero(session.GetUserId(), req.HeroObjID) + if code != pb.ErrorCode_Success { return } - _expHero, err := this.module.GetHero(session.GetUserId(), req.ExpCardID) // 校验需要消耗经验卡牌的对象是否存在 - - if err != pb.ErrorCode_Success { - code = pb.ErrorCode_HeroNoExist + _expHero, code = this.module.GetHero(session.GetUserId(), req.ExpCardID) // 校验需要消耗经验卡牌的对象是否存在 + if code != pb.ErrorCode_Success { return } if req.Amount <= 0 { // 消耗数量校验 @@ -144,7 +139,8 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren // 删除经验卡 err1 := this.module.modelHero.consumeOneHeroCard(session.GetUserId(), req.ExpCardID, req.Amount) if err1 != nil { - log.Errorf("delete err failed err:%T!", err) + code = pb.ErrorCode_HeroNoEnough + log.Errorf("delete err failed err:%T!", err1) return } @@ -152,5 +148,7 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren if err1 != nil { log.Errorf("PushHeroProperty err!") } + + session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{Hero: _hero}) return } diff --git a/modules/hero/hero_test.go b/modules/hero/hero_test.go index 6f2f760a1..648b96c6f 100644 --- a/modules/hero/hero_test.go +++ b/modules/hero/hero_test.go @@ -86,8 +86,8 @@ func TestPropertyCompute(t *testing.T) { } func TestHeroList(t *testing.T) { - heroes, err := module.modelHero.getHeroList("u1") - fmt.Printf("%v %v", heroes, err) + heroes := module.modelHero.getHeroList("u1") + fmt.Printf("%v", heroes,) } func TestModify(t *testing.T) { diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index d4e67e3c7..f184a2c72 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -93,10 +93,7 @@ func (this *ModelHero) createOneHero(uid string, heroCfgId int32) (err error) { //创建多个指定的英雄 heroCfgIds可填入多个英雄ID func (this *ModelHero) createMultiHero(uid string, heroCfgIds ...int32) error { - heroes, err := this.moduleHero.modelHero.getHeroList(uid) - if err != nil { - return err - } + heroes := this.moduleHero.modelHero.getHeroList(uid) if len(heroes) == 0 { for _, v := range heroCfgIds { @@ -161,13 +158,13 @@ func (this *ModelHero) modifyHeroData(uid, heroId string, data map[string]interf } //获取玩家的英雄列表 -func (this *ModelHero) getHeroList(uid string) ([]*pb.DBHero, error) { +func (this *ModelHero) getHeroList(uid string) []*pb.DBHero { heroes := make([]*pb.DBHero, 0) err := this.GetList(uid, &heroes) if err != nil { - return nil, err + return nil } - return heroes, nil + return heroes } //更新装备 @@ -285,6 +282,7 @@ func (this *ModelHero) PushHeroProperty(session comm.IUserSession, heroId string } if err = this.ChangeList(session.GetUserId(), heroId, update); err != nil { + log.Errorf("PushHeroProperty err:%v", err) return } return session.SendMsg("push", "property", &pb.HeroProperty{Property: m}) diff --git a/modules/hero/module.go b/modules/hero/module.go index f4803d3d6..83683f0dc 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -3,7 +3,6 @@ package hero import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" ) @@ -44,34 +43,6 @@ func (this *Hero) CreateHero(uid string, heroCfgId ...int32) error { return this.modelHero.createMultiHero(uid, heroCfgId...) } -//消耗英雄卡 -func (this *Hero) ConsumeCard(uId string, heroCfgId int32, count int32) (code pb.ErrorCode) { - if count <= 0 { - log.Errorf("attr no changed,uid: %s heroCfgId: %s count: %d", uId, heroCfgId, count) - code = pb.ErrorCode_ReqParameterError - return - } - heroes := this.GetHeroList(uId) - var curList []*pb.DBHero - for _, v := range heroes { - if heroCfgId == v.HeroID { - curList = append(curList, v) - } - } - if int32(len(curList)) < count { - return pb.ErrorCode_HeroNoEnough - } - - for _, v := range curList { - err := this.modelHero.consumeOneHeroCard(v.Uid, v.Id, count) - if err != nil { - return pb.ErrorCode_DBError - } - } - - return pb.ErrorCode_Success -} - //获取英雄 func (this *Hero) GetHero(uid, heroId string) (*pb.DBHero, pb.ErrorCode) { hero := this.modelHero.getOneHero(uid, heroId) @@ -110,11 +81,11 @@ func (this *Hero) UpdateEquipment(hero *pb.DBHero, equip []*pb.DB_Equipment) (co //英雄列表 func (this *Hero) GetHeroList(uid string) []*pb.DBHero { - list, err := this.modelHero.getHeroList(uid) - if err != nil { - return nil + heroes := this.modelHero.getHeroList(uid) + for _, h := range heroes { + h.Property = this.modelHero.PropertyCompute(uid, h.Id) } - return list + return heroes } //查询英雄数量 diff --git a/modules/modulebase.go b/modules/modulebase.go index f1f54d30d..21c5d6d87 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -158,16 +158,17 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p code = pb.ErrorCode_ResNoEnough return } - } else if v.A == comm.HeroType { //卡片资源 - if resID, err = strconv.Atoi(v.T); err != nil { - code = pb.ErrorCode_ConfigurationException - return - } - if amount = int32(this.ModuleHero.QueryHeroAmount(uid, int32(resID))); amount < v.N { - code = pb.ErrorCode_ResNoEnough - return - } } + // else if v.A == comm.HeroType { //卡片资源 + // if resID, err = strconv.Atoi(v.T); err != nil { + // code = pb.ErrorCode_ConfigurationException + // return + // } + // if amount = int32(this.ModuleHero.QueryHeroAmount(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 { @@ -187,10 +188,11 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p } else if v.A == comm.ItemType { //道具资源 resID, _ = strconv.Atoi(v.T) this.ModuleItems.AddItem(source, uid, int32(resID), -1*v.N) - } else if v.A == comm.HeroType { //卡片资源 - resID, _ = strconv.Atoi(v.T) - this.ModuleHero.ConsumeCard(uid, int32(resID), -1*v.N) } + // else if v.A == comm.HeroType { //卡片资源 + // resID, _ = strconv.Atoi(v.T) + // this.ModuleHero.ConsumeCard(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) @@ -218,7 +220,7 @@ func (this *ModuleBase) DispenseRes(uid string, res []*cfg.Game_atn) (code pb.Er this.ModuleItems.AddItem(source, uid, int32(resID), v.N) } else if v.A == comm.HeroType { //卡片资源 resID, _ = strconv.Atoi(v.T) - this.ModuleHero.ConsumeCard(uid, int32(resID), v.N) + this.ModuleHero.CreateHero(uid, int32(resID), v.N) } else if v.A == comm.EquipmentType { resID, _ = strconv.Atoi(v.T) this.ModuleEquipment.AddNewEquipments(source, uid, map[int32]uint32{int32(resID): uint32(v.N)}) diff --git a/modules/story/api.go b/modules/story/api.go index 3fa7da1f4..0e96c4e12 100644 --- a/modules/story/api.go +++ b/modules/story/api.go @@ -6,7 +6,8 @@ import ( ) const ( - StoryGetListResp = "getlist" + StoryGetListResp = "getlist" + StoryChallengeResp = "challenge" ) type apiComp struct { diff --git a/modules/story/api_challenge.go b/modules/story/api_challenge.go new file mode 100644 index 000000000..4623a129f --- /dev/null +++ b/modules/story/api_challenge.go @@ -0,0 +1,86 @@ +package story + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + "sort" + + "google.golang.org/protobuf/proto" +) + +//参数校验 +func (this *apiComp) ChallengeCheck(session comm.IUserSession, req *pb.StoryChallengeReq) (code pb.ErrorCode) { + if req.ChapterId == 0 || req.StoryId == 0 { + code = pb.ErrorCode_ReqParameterError + return + } + return +} + +///挑战主线关卡 +func (this *apiComp) Challenge(session comm.IUserSession, req *pb.StoryChallengeReq) (code pb.ErrorCode, data proto.Message) { + var ( + curChapter *pb.DBStory // 当前章节信息 + bBranch bool // 当前挑战关卡是不是分支 + ) + bBranch = false + defer func() { + session.SendMsg(string(this.module.GetType()), StoryChallengeResp, &pb.StoryChallengeResp{Data: curChapter}) + + }() + code = this.ChallengeCheck(session, req) + if code != pb.ErrorCode_Success { + return // 参数校验失败直接返回 + } + list, err := this.module.modelStory.getStoryList(session.GetUserId()) + if err != nil { + code = pb.ErrorCode_DBError + return + } + sort.SliceStable(list, func(i, j int) bool { // 倒序排序 + return list[i].ChapterId > list[j].ChapterId + }) + if len(list) > 0 { + curChapter = list[0] // 取第一条(第一条肯定是最新的) + } + if curChapter == nil { + code = pb.ErrorCode_StoryNotFindChapter // 没有找到主线关卡信息 + return + } + // 先校验是不是分支 + chaptConfig := this.module.configure.GetStoryChapter(int32(req.ChapterId)) // 根据配置文件找 + if chaptConfig == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + // 根据难度找对应的配置文件 + if chaptConfig.Intensity == "1" { // 这里安临时配置读取 后面会修改 + con := this.module.configure.GetStoryEasyChapter(int32(req.StoryId)) // 根据配置文件找 + if con != nil { + code = pb.ErrorCode_ConfigNoFound + return + } + if con.Area == 2 { //分支 + bBranch = true + // 只需要校验小关ID 是不是大于当前ID就可以 + if curChapter.StoryId < int32(req.StoryId) { //必须大于前置关卡才可以挑战 + code = pb.ErrorCode_StoryIDFailed + return + } + } + } + // TODO 调用战斗逻辑 + if bBranch { + curChapter.BranchID = append(curChapter.BranchID, int32(req.ChapterId)) // 记录分支关卡 + } + if curChapter.ChapterId == int32(req.ChapterId) && curChapter.StoryId == int32(req.StoryId) { + update := map[string]interface{}{ + "storyId": req.StoryId, + "branchID": curChapter.BranchID, + } + err = this.module.modelStory.modifyStoryData(session.GetUserId(), curChapter.Id, update) + } + // 发奖 (奖励数据还没配置,后续补充) + + return +} diff --git a/modules/story/comp_configure.go b/modules/story/comp_configure.go index 2e3b44daf..0f5a9fc78 100644 --- a/modules/story/comp_configure.go +++ b/modules/story/comp_configure.go @@ -60,7 +60,7 @@ func (this *configureComp) GetStoryChapter(id int32) (data *cfg.Game_storyChapte ok bool ) if configure, ok = v.(*cfg.Game_storyChapter); !ok { - log.Errorf("%T no is *cfg.Game_global", v) + log.Errorf("%T no is *cfg.Game_storyChapterData", v) return } @@ -82,7 +82,7 @@ func (this *configureComp) GetStoryEasyChapter(id int32) (data *cfg.Game_storyEa ok bool ) if configure, ok = v.(*cfg.Game_storyEasy); !ok { - log.Errorf("%T no is *cfg.Game_global", v) + log.Errorf("%T no is *cfg.Game_storyEasyData", v) return } @@ -104,7 +104,7 @@ func (this *configureComp) GetStoryPurgatoryChapter(id int32) (data *cfg.Game_st ok bool ) if configure, ok = v.(*cfg.Game_storyPurgatory); !ok { - log.Errorf("%T no is *cfg.Game_global", v) + log.Errorf("%T no is *cfg.Game_storyPurgatoryData", v) return } @@ -126,7 +126,7 @@ func (this *configureComp) GetStoryHardChapter(id int32) (data *cfg.Game_storyHa ok bool ) if configure, ok = v.(*cfg.Game_storyHard); !ok { - log.Errorf("%T no is *cfg.Game_global", v) + log.Errorf("%T no is *cfg.Game_storyHardData", v) return } diff --git a/modules/task/api.go b/modules/task/api.go index e715fd789..557faf09e 100644 --- a/modules/task/api.go +++ b/modules/task/api.go @@ -6,8 +6,10 @@ import ( ) const ( - TaskSubTypeList = "list" //任务列表 - TaskSubTypeReceive = "receive" //领取 + TaskSubTypeList = "list" //任务列表 + TaskSubTypeReceive = "receive" //领取 + TaskSubTypeActiveList = "activelist" //活跃度列表 + TaskSubTypeActiveReceive = "activereceive" //活跃度领取 ) type apiComp struct { diff --git a/modules/task/api_active.go b/modules/task/api_active.go deleted file mode 100644 index e90001311..000000000 --- a/modules/task/api_active.go +++ /dev/null @@ -1,19 +0,0 @@ -package task - -import ( - "go_dreamfactory/comm" - "go_dreamfactory/pb" - - "google.golang.org/protobuf/proto" -) - -//用于测试 - -func (this *apiComp) ActiveCheck(session comm.IUserSession, req *pb.TaskActiveReq) (code pb.ErrorCode) { - return -} - -func (this *apiComp) Active(session comm.IUserSession, req *pb.TaskActiveReq) (code pb.ErrorCode, data proto.Message) { - this.moduleTask.ModuleTask.SendToTask(session.GetUserId(), comm.TaskTypeGetHero, &pb.TaskParam{First: 5}) - return -} diff --git a/modules/task/api_activelist.go b/modules/task/api_activelist.go new file mode 100644 index 000000000..ea48c2d62 --- /dev/null +++ b/modules/task/api_activelist.go @@ -0,0 +1,38 @@ +package task + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + "go_dreamfactory/utils" + + "google.golang.org/protobuf/proto" +) + +//活跃度 +func (this *apiComp) ActiveListCheck(session comm.IUserSession, req *pb.TaskActiveListReq) (code pb.ErrorCode) { + if req.TaskTag == 0 { + code = pb.ErrorCode_ReqParameterError + } + return +} + +func (this *apiComp) ActiveList(session comm.IUserSession, req *pb.TaskActiveListReq) (code pb.ErrorCode, data proto.Message) { + // this.moduleTask.ModuleTask.SendToTask(session.GetUserId(), comm.TaskTypeGetHero, &pb.TaskParam{First: 5}) + if code = this.ActiveListCheck(session, req); code != pb.ErrorCode_Success { + return + } + + resp := &pb.TaskActiveListResp{} + defer func() { + err := session.SendMsg(string(this.moduleTask.GetType()), TaskSubTypeActiveList, resp) + if err != nil { + code = pb.ErrorCode_SystemError + } + utils.TraceFunc(session.GetUserId(), string(this.moduleTask.GetType()), TaskSubTypeActiveList, req, resp) + }() + + //遍历活跃度奖励表 + resp.List = this.moduleTask.modelTaskActive.getUserActiveList(session.GetUserId(), comm.TaskTag(req.TaskTag)) + + return +} diff --git a/modules/task/api_activereceive.go b/modules/task/api_activereceive.go new file mode 100644 index 000000000..b69603bc9 --- /dev/null +++ b/modules/task/api_activereceive.go @@ -0,0 +1,55 @@ +package task + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + "go_dreamfactory/utils" + + "google.golang.org/protobuf/proto" +) + +//活跃度领取 +func (this *apiComp) ActiveReceiveCheck(session comm.IUserSession, req *pb.TaskActiveReceiveReq) (code pb.ErrorCode) { + if req.Id == "" || req.TaskTag == 0 { + code = pb.ErrorCode_ReqParameterError + } + return +} + +func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActiveReceiveReq) (code pb.ErrorCode, data proto.Message) { + if code = this.ActiveReceiveCheck(session, req); code != pb.ErrorCode_Success { + return + } + resp := &pb.TaskActiveReceiveResp{ + TaskTag: req.TaskTag, + Id: req.Id, + } + defer func() { + err := session.SendMsg(string(this.moduleTask.GetType()), TaskSubTypeActiveReceive, resp) + if err != nil { + code = pb.ErrorCode_SystemError + } + utils.TraceFunc(session.GetUserId(), string(this.moduleTask.GetType()), TaskSubTypeActiveReceive, req, resp) + }() + + ua := this.moduleTask.modelTaskActive.getUserActive(session.GetUserId(), req.Id, comm.TaskTag(req.TaskTag)) + if ua == nil { + code = pb.ErrorCode_TaskActiveNofound + return + } + + conf := this.moduleTask.configure.getTaskActiveById(ua.RId) + if conf == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + + code = this.moduleTask.modelTaskActive.receiveHandle(session.GetUserId(), req.Id, conf, ua, comm.TaskTag(req.TaskTag)) + if code != pb.ErrorCode_Success { + return + } + + //派发奖励 + code = this.moduleTask.DispenseRes(session.GetUserId(), conf.Reword) + return +} diff --git a/modules/task/api_receive.go b/modules/task/api_receive.go index 47aea55e5..54247cfbf 100644 --- a/modules/task/api_receive.go +++ b/modules/task/api_receive.go @@ -18,6 +18,10 @@ func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.TaskReceive } func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq) (code pb.ErrorCode, data proto.Message) { + if code = this.ReceiveCheck(session, req); code != pb.ErrorCode_Success { + return + } + resp := &pb.TaskReceiveResp{} defer func() { err := session.SendMsg(string(this.moduleTask.GetType()), TaskSubTypeList, resp) diff --git a/modules/task/config.go b/modules/task/config.go index 80cfe9c66..1ad2bc349 100644 --- a/modules/task/config.go +++ b/modules/task/config.go @@ -129,3 +129,35 @@ func (this *configureComp) getTaskByTag(taskTag int32) (data []*cfg.Game_taskRou } return } + +//获取活跃度奖励 +func (this *configureComp) getTaskActiveByTag(taskTag int32) (data []*cfg.Game_activeRewardData, err error) { + conf, err := this.getActiveRewardCfg() + if err != nil { + log.Errorf("get conf err:%v", err) + return + } + + if conf != nil { + for _, v := range conf.GetDataList() { + if v.IdTag == taskTag { + data = append(data, v) + } + } + } + return +} + +func (this *configureComp) getTaskActiveById(id int32) (data *cfg.Game_activeRewardData) { + conf, err := this.getActiveRewardCfg() + if err != nil { + log.Errorf("get conf err:%v", err) + return + } + if conf != nil { + if v, ok := conf.GetDataMap()[id]; ok { + return v + } + } + return +} diff --git a/modules/task/const.go b/modules/task/const.go deleted file mode 100644 index 29512d9ba..000000000 --- a/modules/task/const.go +++ /dev/null @@ -1,2 +0,0 @@ -package task - diff --git a/modules/task/model_active.go b/modules/task/model_active.go new file mode 100644 index 000000000..a2a8bf780 --- /dev/null +++ b/modules/task/model_active.go @@ -0,0 +1,118 @@ +package task + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/log" + "go_dreamfactory/modules" + "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" + + "go.mongodb.org/mongo-driver/bson/primitive" +) + +const ( //Redis + TableTaskActive core.SqlTable = "taskactive" //活跃度表 +) + +type ModelTaskActive struct { + modules.MCompModel + moduleTask *ModuleTask +} + +func (this *ModelTaskActive) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + err = this.MCompModel.Init(service, module, comp, options) + this.moduleTask = module.(*ModuleTask) + this.TableName = string(TableTaskActive) + return +} + +//初始化活跃度 +func (this *ModelTaskActive) initActiveRewardByTag(uid string, taskTag comm.TaskTag) { + data, err := this.moduleTask.configure.getTaskActiveByTag(int32(taskTag)) + if err != nil { + log.Errorf("uid:%v tag:%v initActiveRewardByTag err %v", uid, taskTag, err) + return + } + + for _, conf := range data { + objId := primitive.NewObjectID().Hex() + ta := &pb.DBTaskActive{ + Id: objId, + Uid: uid, + RId: conf.Key, + } + if err := this.moduleTask.modelTaskActive.AddList(swapKey(uid, taskTag), ta.Id, ta); err != nil { + log.Errorf("uid:%v tag:%v initActiv add err %v", uid, taskTag, err) + return + } + } +} + +//获取玩家活跃度列表 +func (this *ModelTaskActive) getUserActiveList(uid string, taskTag comm.TaskTag) []*pb.DBTaskActive { + al := []*pb.DBTaskActive{} + if err := this.GetList(swapKey(uid, taskTag), &al); err != nil { + log.Errorf("getUserActiveList err:%v", err) + return al + } + return al +} + +//获取玩家活跃记录 id 唯一ID +func (this *ModelTaskActive) getUserActive(uid, id string, taskTag comm.TaskTag) *pb.DBTaskActive { + record := this.getUserActiveList(uid, taskTag) + for _, v := range record { + if v.Id == id { + return v + } + } + return nil +} + +func (this *ModelTaskActive) updateReceive(uid, id string, taskTag comm.TaskTag, data map[string]interface{}) error { + return this.moduleTask.modelTaskActive.ChangeList(swapKey(uid, taskTag), id, data) +} + +//领取处理 +func (this *ModelTaskActive) receiveHandle(uid, id string, conf *cfg.Game_activeRewardData, + ua *pb.DBTaskActive, taskTag comm.TaskTag) (code pb.ErrorCode) { + if conf == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + //玩家活跃度数 + userActiveTotal := this.moduleTask.modelTask.countActive(uid, taskTag) + + if ua.Received == 0 { //未领取 + if userActiveTotal >= conf.Active { + //更新玩家领取状态 + update := map[string]interface{}{ + "received": 1, //标识已领取 + } + if err := this.updateReceive(uid, ua.Id, taskTag, update); err != nil { + log.Errorf("updateReceive err %v", err) + code = pb.ErrorCode_DBError + return + } + } else { + code = pb.ErrorCode_TaskActiveNoenough + } + } else { + code = pb.ErrorCode_TaskReceived + } + return +} + +//清空任务 +func (this *ModelTaskActive) clearTask(uid string, taskTag comm.TaskTag) error { + data := this.getUserActiveList(uid, taskTag) + for _, v := range data { + if err := this.moduleTask.modelTask.DelListlds(swapKey(uid, taskTag), v.Id); err != nil { + log.Errorf("uid: %v taskTag:%v err:%v", uid, taskTag, err) + return err + } + } + + return nil +} diff --git a/modules/task/model_status.go b/modules/task/model_status.go deleted file mode 100644 index 29512d9ba..000000000 --- a/modules/task/model_status.go +++ /dev/null @@ -1,2 +0,0 @@ -package task - diff --git a/modules/task/model_task.go b/modules/task/model_task.go index 77b936ff3..b2a3724d1 100644 --- a/modules/task/model_task.go +++ b/modules/task/model_task.go @@ -28,13 +28,13 @@ func (this *ModelTask) Init(service core.IService, module core.IModule, comp cor return } -func (this *ModelTask) swapKey(uid string, tag comm.TaskTag) string { +func swapKey(uid string, tag comm.TaskTag) string { return fmt.Sprintf("%s_%v", uid, tag) } //获取玩家任务列表 func (this *ModelTask) getTaskList(uid string, taskTag comm.TaskTag) (list []*pb.DBTask) { - if err := this.GetList(this.swapKey(uid, taskTag), &list); err != nil { + if err := this.GetList(swapKey(uid, taskTag), &list); err != nil { log.Errorf("initTaskByTag err %v", err) return } @@ -48,15 +48,16 @@ func (this *ModelTask) initTaskByTag(uid string, taskTag comm.TaskTag) error { return fmt.Errorf("clear data before init task") } if data, err := this.moduleTask.configure.getTaskByTag(int32(taskTag)); err == nil { - for _, v := range data { + for _, cnf := range data { objId := primitive.NewObjectID().Hex() task := &pb.DBTask{ Id: objId, Uid: uid, - TaskId: v.Key, - Progress: v.ConditionSecond, + TaskId: cnf.Key, + Active: cnf.Active, + Progress: cnf.ConditionSecond, } - if err := this.AddList(this.swapKey(uid, taskTag), task.Id, task); err != nil { + if err := this.AddList(swapKey(uid, taskTag), task.Id, task); err != nil { log.Errorf("initTaskByTag addlists err %v", err) return err } @@ -68,18 +69,13 @@ func (this *ModelTask) initTaskByTag(uid string, taskTag comm.TaskTag) error { //查询用户任务 func (this *ModelTask) getUserTask(uid string, taskTag comm.TaskTag, taskId string) *pb.DBTask { userTask := &pb.DBTask{} - if err := this.moduleTask.modelTask.GetListObj(this.swapKey(uid, taskTag), taskId, userTask); err != nil { + if err := this.moduleTask.modelTask.GetListObj(swapKey(uid, taskTag), taskId, userTask); err != nil { log.Errorf("getUserTask err:%v", err) return nil } return userTask } -//检查活跃度 -func (this *ModelTask) checkActiveVal(uid string) error { - return nil -} - //获取未完成的任务列表 func (this *ModelTask) getUnFinishTaskList(uid string, taskTag comm.TaskTag) (list []*pb.DBTask) { taskList := this.getTaskList(uid, taskTag) @@ -91,6 +87,17 @@ func (this *ModelTask) getUnFinishTaskList(uid string, taskTag comm.TaskTag) (li return } +//活跃度统计 +func (this *ModelTask) countActive(uid string, taskTag comm.TaskTag) (total int32) { + taskList := this.getTaskList(uid, taskTag) + for _, v := range taskList { + if v.Status == 1 { + total += v.Active + } + } + return +} + //检查任务进度 返回未完成的 func (this *ModelTask) checkTaskProgress(uid string, config *cfg.Game_taskRoundData) (*pb.DBTask, bool) { taskList := this.getUnFinishTaskList(uid, comm.TaskTag(config.IdTag)) @@ -105,7 +112,7 @@ func (this *ModelTask) checkTaskProgress(uid string, config *cfg.Game_taskRoundD //更改用户任务 func (this *ModelTask) modifyUserTask(uid string, taskTag comm.TaskTag, taskId string, data map[string]interface{}) error { - if err := this.ChangeList(this.swapKey(uid, taskTag), taskId, data); err != nil { + if err := this.ChangeList(swapKey(uid, taskTag), taskId, data); err != nil { log.Errorf("err %v", err) return err } @@ -154,10 +161,6 @@ func (this *ModelTask) finishHandle(userTask *pb.DBTask, taskTag comm.TaskTag, c log.Errorf("err %v", err) return err } - //修改玩家任务活跃度 成就没有活跃度 - if config.IdTag != int32(comm.TASK_ACHIEVE) { - this.moduleTask.ModuleUser.AddAttributeValue(userTask.Uid, comm.ResTaskActive, config.Active) - } return nil } @@ -166,7 +169,7 @@ func (this *ModelTask) finishHandle(userTask *pb.DBTask, taskTag comm.TaskTag, c func (this *ModelTask) clearTask(uid string, taskTag comm.TaskTag) error { taskList := this.getTaskList(uid, taskTag) for _, v := range taskList { - if err := this.moduleTask.modelTask.DelListlds(this.swapKey(uid, taskTag), v.Id); err != nil { + if err := this.moduleTask.modelTask.DelListlds(swapKey(uid, taskTag), v.Id); err != nil { log.Errorf("uid: %v taskTag:%v err:%v", uid, taskTag, err) return err } diff --git a/modules/task/module.go b/modules/task/module.go index 699bb8c7a..30af4972b 100644 --- a/modules/task/module.go +++ b/modules/task/module.go @@ -3,18 +3,17 @@ package task import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" - "time" ) type ModuleTask struct { modules.ModuleBase - modelTask *ModelTask - api *apiComp - configure *configureComp - lastDayTime int64 //上次日任务执行时间戳 - lastWeekTime int64 //上次周任务执行时间戳 + modelTask *ModelTask + modelTaskActive *ModelTaskActive + api *apiComp + configure *configureComp } func NewModule() core.IModule { @@ -27,16 +26,6 @@ func (this *ModuleTask) GetType() core.M_Modules { func (this *ModuleTask) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { err = this.ModuleBase.Init(service, module, options) - - go func() { - tickC := time.NewTicker(time.Second * 1) - for { - select { - case tc := <-tickC.C: - this.update(tc) - } - } - }() return } @@ -44,6 +33,7 @@ func (this *ModuleTask) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.modelTask = this.RegisterComp(new(ModelTask)).(*ModelTask) + this.modelTaskActive = this.RegisterComp(new(ModelTaskActive)).(*ModelTaskActive) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } @@ -53,60 +43,40 @@ func (this *ModuleTask) Start() (err error) { return } -func (this *ModuleTask) update(t time.Time) { - this.taskEveryDay(t) - this.taskWeekDay(t) -} - -//日任务 -func (this *ModuleTask) taskEveryDay(t time.Time) { - n := time.Now().Unix() - if t.Hour() == 4 && t.Minute() == 0 { - this.lastDayTime = n - } else { - this.lastDayTime = 0 - } -} - -//周任务 -func (this *ModuleTask) taskWeekDay(t time.Time) { - n := time.Now().Unix() - if int(t.Weekday()) == 1 { //周一 - if t.Hour() == 0 && t.Minute() == 0 { - this.lastWeekTime = n - } else { - this.lastWeekTime = 0 - } - } -} - //初始化任务 -func (this *ModuleTask) InitTask(uid string, taskTag comm.TaskTag) (code pb.ErrorCode) { +func (this *ModuleTask) InitTask(uid string, taskTag comm.TaskTag) { if err := this.modelTask.initTaskByTag(uid, taskTag); err != nil { - code = pb.ErrorCode_TaskInit + log.Errorf("uid:%v tag:%v initTask err: %v", uid, taskTag, err) } - return } //初始化日常、周常、成就 -func (this *ModuleTask) InitTaskAll(uid string) (code pb.ErrorCode) { +func (this *ModuleTask) InitTaskAll(uid string) { this.InitTask(uid, comm.TASK_DAILY) this.InitTask(uid, comm.TASK_WEEKLY) this.InitTask(uid, comm.TASK_ACHIEVE) - return + + this.modelTaskActive.initActiveRewardByTag(uid, comm.TASK_DAILY) + this.modelTaskActive.initActiveRewardByTag(uid, comm.TASK_WEEKLY) } //重置任务 -func (this *ModuleTask) ResetTask(uid string, taskTag comm.TaskTag) (code pb.ErrorCode) { +func (this *ModuleTask) ResetTask(uid string, taskTag comm.TaskTag) { if err := this.modelTask.clearTask(uid, taskTag); err != nil { - code = pb.ErrorCode_TaskReset + log.Errorf("uid:%v tag:%v ResetTask err:%v", uid, taskTag, err) return } - return this.InitTask(uid, taskTag) + this.InitTask(uid, taskTag) + + if err := this.modelTaskActive.clearTask(uid, taskTag); err != nil { + log.Errorf("uid:%v tag:%v ResetTaskActive err:%v", uid, taskTag, err) + return + } + this.modelTaskActive.initActiveRewardByTag(uid, taskTag) } //任务处理 -func (this *ModuleTask) SendToTask(uid string, taskType comm.TaskType, taskPram *pb.TaskParam) (code pb.ErrorCode) { +func (this *ModuleTask) SendToTask(uid string, taskType comm.TaskType, taskPram *pb.TaskParam) (code pb.ErrorCode) { if err := this.modelTask.taskHandle(uid, taskType, taskPram); err != nil { code = pb.ErrorCode_TaskHandle } diff --git a/modules/user/api_login.go b/modules/user/api_login.go index 5fb1c59e0..b20becc60 100644 --- a/modules/user/api_login.go +++ b/modules/user/api_login.go @@ -104,19 +104,16 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod return } - if this.module.modelUser.isLoginFirst(user.Logintime) { - //清空日常 - if code = this.module.ModuleTask.ResetTask(user.Uid, comm.TASK_DAILY); code != pb.ErrorCode_Success { - return - } - //清周常 - if utils.IsAfterWeek(user.Logintime) { - if code = this.module.ModuleTask.ResetTask(user.Uid, comm.TASK_WEEKLY); code != pb.ErrorCode_Success { - return + go func() { + if this.module.modelUser.isLoginFirst(user.Logintime) { + //清空日常 + this.module.ModuleTask.ResetTask(user.Uid, comm.TASK_DAILY) + //清周常 + if utils.IsAfterWeek(user.Logintime) { + this.module.ModuleTask.ResetTask(user.Uid, comm.TASK_WEEKLY) } } - } - + }() } return diff --git a/modules/user/api_res.go b/modules/user/api_res.go index 88f7e5605..f11d64639 100644 --- a/modules/user/api_res.go +++ b/modules/user/api_res.go @@ -3,12 +3,13 @@ package user import ( "go_dreamfactory/comm" "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" "google.golang.org/protobuf/proto" ) func (this *apiComp) AddResCheck(session comm.IUserSession, req *pb.UserAddResReq) (code pb.ErrorCode) { - if req.ResType == "" || req.Count <= 0 { + if req.Res.A == "" || req.Res.T == "" || req.Res.N > 0 { code = pb.ErrorCode_ReqParameterError } return @@ -33,22 +34,14 @@ func (this *apiComp) AddRes(session comm.IUserSession, req *pb.UserAddResReq) (c code = pb.ErrorCode_UserSessionNobeing return } - - count := req.Count - - switch req.ResType { - case comm.ResGold: - count += user.Gold - case comm.ResExp: - count += user.Exp + res := make([]*cfg.Game_atn, 0) + atn := &cfg.Game_atn{ + A: req.Res.A, + T: req.Res.T, + N: req.Res.N, } - code = this.module.AddAttributeValue(session.GetUserId(), req.ResType, count) - if code != pb.ErrorCode_Success { - return - } - - rsp.ResType = req.ResType - rsp.Count = count - + res = append(res, atn) + code = this.module.DispenseRes(session.GetUserId(), res) + rsp.Res = req.Res return } diff --git a/modules/user/module.go b/modules/user/module.go index 134168a58..1f8f272ed 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -112,14 +112,6 @@ func (this *User) AddAttributeValue(uid string, attr string, add int32) (code pb } } update[comm.ResDiamond] = user.Diamond + add - case comm.ResTaskActive: - if add < 0 { - if user.TaskActive+add < 0 { - code = pb.ErrorCode_ResNoEnough - return - } - } - update[comm.ResTaskActive] = user.TaskActive + add } if err := this.modelUser.updateUserAttr(uid, update); err != nil { diff --git a/modules/web/api.go b/modules/web/api.go index df6449361..bf8cb3cd1 100644 --- a/modules/web/api.go +++ b/modules/web/api.go @@ -11,18 +11,18 @@ import ( */ type Api_Comp struct { cbase.ModuleCompBase - options *Options //模块参数 - module *Web //当前模块对象 - gin gin.ISys //gin 框架 web的热门框架 + options *Options //模块参数 + moduleWeb *Web //当前模块对象 + gin gin.ISys //gin 框架 web的热门框架 } //组件初始化接口 启动web服务 并注册api func (this *Api_Comp) 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.(*Web) + this.moduleWeb = module.(*Web) this.gin, err = gin.NewSys(gin.SetListenPort(this.options.Port)) this.gin.POST("/register", this.Register) - this.gin.POST("/serverlist", this.ServerList) + this.gin.GET("/serverlist", this.ServerList) return } diff --git a/modules/web/api_register.go b/modules/web/api_register.go index 14ca7d5ee..2e191c4c6 100644 --- a/modules/web/api_register.go +++ b/modules/web/api_register.go @@ -13,7 +13,7 @@ func (this *Api_Comp) Register(c *engine.Context) { rsp := &pb.UserRegisterResp{} err := c.BindJSON(&req) if err == nil { - err := this.module.modelUser.User_Create(&pb.DBUser{ + err := this.moduleWeb.modelUser.User_Create(&pb.DBUser{ Binduid: req.Account, Sid: req.Sid, }) diff --git a/modules/web/api_srvlist.go b/modules/web/api_srvlist.go index 0bddfaebb..96d2ed429 100644 --- a/modules/web/api_srvlist.go +++ b/modules/web/api_srvlist.go @@ -1,7 +1,13 @@ package web -import "go_dreamfactory/lego/sys/gin/engine" +import ( + "go_dreamfactory/lego/sys/gin/engine" + "net/http" +) //服务列表 func (this *Api_Comp) ServerList(c *engine.Context) { + conf := this.moduleWeb.configure.getServerListConf() + + c.JSON(http.StatusOK, conf) } diff --git a/modules/web/config.go b/modules/web/config.go new file mode 100644 index 000000000..b714579a9 --- /dev/null +++ b/modules/web/config.go @@ -0,0 +1,51 @@ +package web + +import ( + "fmt" + "go_dreamfactory/lego/core" + "go_dreamfactory/modules" + cfg "go_dreamfactory/sys/configure/structs" +) + +const ( + game_serverlist = "game_serverlist.json" +) + +type configureComp struct { + modules.MCompConfigure +} + +func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + err = this.MCompConfigure.Init(service, module, comp, options) + err = this.LoadConfigure(game_serverlist, cfg.NewGame_serverList) + return +} + +func (this *configureComp) getConfig() (data *cfg.Game_serverList, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(game_serverlist); err != nil { + return + } else { + if data, ok = v.(*cfg.Game_serverList); !ok { + err = fmt.Errorf("%T no is *cfg.Game_ActiveReward", v) + return + } + } + return +} + +func (this *configureComp) getServerListConf() (data []*cfg.Game_serverListData) { + conf, err := this.getConfig() + if err != nil { + return data + } + + if conf != nil { + return conf.GetDataList() + } + + return +} diff --git a/modules/web/module.go b/modules/web/module.go index 307d28bda..aff0f40df 100644 --- a/modules/web/module.go +++ b/modules/web/module.go @@ -23,6 +23,7 @@ type Web struct { options *Options api_comp *Api_Comp //提供weba pi服务的组件 modelUser *user.ModelUser + configure *configureComp } //模块名 @@ -45,4 +46,5 @@ func (this *Web) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp) this.modelUser = this.RegisterComp(new(user.ModelUser)).(*user.ModelUser) + this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index d5fbc8a13..de79ceab6 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -90,9 +90,13 @@ const ( ErrorCode_StoryNotFindChapter ErrorCode = 1500 // 没有找到主线关卡信息 ErrorCode_StoryIDFailed ErrorCode = 1501 // 关卡ID 错误 // task - ErrorCode_TaskInit ErrorCode = 1600 //初始化失败 - ErrorCode_TaskReset ErrorCode = 1601 //重置任务失败 - ErrorCode_TaskHandle ErrorCode = 1602 //任务处理失败 + ErrorCode_TaskInit ErrorCode = 1600 //初始化失败 + ErrorCode_TaskReset ErrorCode = 1601 //重置任务失败 + ErrorCode_TaskHandle ErrorCode = 1602 //任务处理失败 + ErrorCode_TaskReceived ErrorCode = 1603 //已领取 + ErrorCode_TaskActiveInit ErrorCode = 1606 //初始化活跃度失败 + ErrorCode_TaskActiveNofound ErrorCode = 1604 //未找到用户活跃度配置 + ErrorCode_TaskActiveNoenough ErrorCode = 1605 //活跃值未达标 ) // Enum value maps for ErrorCode. @@ -161,6 +165,10 @@ var ( 1600: "TaskInit", 1601: "TaskReset", 1602: "TaskHandle", + 1603: "TaskReceived", + 1606: "TaskActiveInit", + 1604: "TaskActiveNofound", + 1605: "TaskActiveNoenough", } ErrorCode_value = map[string]int32{ "Success": 0, @@ -226,6 +234,10 @@ var ( "TaskInit": 1600, "TaskReset": 1601, "TaskHandle": 1602, + "TaskReceived": 1603, + "TaskActiveInit": 1606, + "TaskActiveNofound": 1604, + "TaskActiveNoenough": 1605, } ) @@ -260,7 +272,7 @@ var File_errorcode_proto protoreflect.FileDescriptor var file_errorcode_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2a, 0x9b, 0x0a, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0xf4, 0x0a, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12, 0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, @@ -341,8 +353,14 @@ var file_errorcode_proto_rawDesc = []byte{ 0x74, 0x6f, 0x72, 0x79, 0x49, 0x44, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, 0xdd, 0x0b, 0x12, 0x0d, 0x0a, 0x08, 0x54, 0x61, 0x73, 0x6b, 0x49, 0x6e, 0x69, 0x74, 0x10, 0xc0, 0x0c, 0x12, 0x0e, 0x0a, 0x09, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x65, 0x74, 0x10, 0xc1, 0x0c, 0x12, 0x0f, - 0x0a, 0x0a, 0x54, 0x61, 0x73, 0x6b, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x10, 0xc2, 0x0c, 0x42, - 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0a, 0x0a, 0x54, 0x61, 0x73, 0x6b, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x10, 0xc2, 0x0c, 0x12, + 0x11, 0x0a, 0x0c, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x10, + 0xc3, 0x0c, 0x12, 0x13, 0x0a, 0x0e, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, + 0x49, 0x6e, 0x69, 0x74, 0x10, 0xc6, 0x0c, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x61, 0x73, 0x6b, 0x41, + 0x63, 0x74, 0x69, 0x76, 0x65, 0x4e, 0x6f, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x10, 0xc4, 0x0c, 0x12, + 0x17, 0x0a, 0x12, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x4e, 0x6f, 0x65, + 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xc5, 0x0c, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/proto/errorcode.proto b/pb/proto/errorcode.proto index ea47d9084..9f8b44fb9 100644 --- a/pb/proto/errorcode.proto +++ b/pb/proto/errorcode.proto @@ -65,17 +65,21 @@ enum ErrorCode { HeroCreate = 1310; // 创建卡失败 HeroEquipUpdate = 1311; // 更新装备失败 HeroMaxAwaken = 1312; // 达到最大觉醒等级 - HeroIsLock = 1313; // 英雄被锁定不能被消耗 + HeroIsLock = 1313; // 英雄被锁定不能被消耗 // equipment EquipmentOnFoundEquipment = 1400; // 未找到武器 EquipmentLvlimitReached = 1401; // 武器等级已达上限 // mainStory StoryNotFindChapter = 1500; // 没有找到主线关卡信息 - StoryIDFailed = 1501; // 关卡ID 错误 + StoryIDFailed = 1501; // 关卡ID 错误 // task - TaskInit = 1600; //初始化失败 - TaskReset = 1601; //重置任务失败 - TaskHandle = 1602; //任务处理失败 + TaskInit = 1600; //初始化失败 + TaskReset = 1601; //重置任务失败 + TaskHandle = 1602; //任务处理失败 + TaskReceived = 1603; //已领取 + TaskActiveInit = 1606; //初始化活跃度失败 + TaskActiveNofound = 1604; //未找到用户活跃度配置 + TaskActiveNoenough = 1605; //活跃值未达标 } \ No newline at end of file diff --git a/pb/proto/mail/mail_msg.proto b/pb/proto/mail/mail_msg.proto index 38908e36b..dedeba2aa 100644 --- a/pb/proto/mail/mail_msg.proto +++ b/pb/proto/mail/mail_msg.proto @@ -37,3 +37,8 @@ message MailDelMailReq { message MailDelMailResp { repeated DBMailData Mail = 1; } + +// 推送邮件 +message MailGetNewMailPush{ + DBMailData Mail = 1; // 推送新的邮件信息 +} \ No newline at end of file diff --git a/pb/proto/story/story_db.proto b/pb/proto/story/story_db.proto index bb86041b0..5e1bea84a 100644 --- a/pb/proto/story/story_db.proto +++ b/pb/proto/story/story_db.proto @@ -8,5 +8,7 @@ message DBStory { int32 storyId = 4; //@go_tags(`bson:"storyId"`) 主线关卡ID int32 intensity = 5; //@go_tags(`bson:"intensity"`) 难度类型 int32 awaredID = 6; //@go_tags(`bson:"awaredID"`) 领奖ID - int32 progress = 7; // @go_tags(`bson:"progress"`) 通关进度 + int32 progress = 7; // @go_tags(`bson:"progress"`) 通关进度(打了多少主关卡) + int32 totalBox = 8; // @go_tags(`bson:"totalBox"`) 总关卡数量 + repeated int32 branchID = 9; // @go_tags(`bson:"branchID"`) 记录分支通关的情况 } \ No newline at end of file diff --git a/pb/proto/story/story_msg.proto b/pb/proto/story/story_msg.proto index 15068fa06..9aef63b65 100644 --- a/pb/proto/story/story_msg.proto +++ b/pb/proto/story/story_msg.proto @@ -10,3 +10,23 @@ message StoryGetListReq { message StoryGetListResp { repeated DBStory data = 1; } + +// 领取关卡宝箱 +message StoryGetRewrdReq { + uint32 chapterId = 1; // 章节ID + uint32 boxId = 2; // 宝箱ID +} + +message StoryGetRewrdResp { + DBStory data = 1; //当前章节信息 +} + +// 挑战关卡 +message StoryChallengeReq { + uint32 chapterId = 1; // 章节ID + uint32 storyId = 2; // 小关ID +} + +message StoryChallengeResp { + DBStory data = 1; //当前章节信息 +} \ No newline at end of file diff --git a/pb/proto/task/task_db.proto b/pb/proto/task/task_db.proto index 76da8516d..7e44af921 100644 --- a/pb/proto/task/task_db.proto +++ b/pb/proto/task/task_db.proto @@ -6,6 +6,14 @@ message DBTask { string uid = 2; //@go_tags(`bson:"uid"`) 用户ID int32 taskId = 3; //@go_tags(`bson:"taskId"`) 任务Id int32 progress = 4; //@go_tags(`bson:"progress"`) 任务进度/完成次数 - int32 status = 5; //@go_tags(`bson:"status"`) 任务状态 默认0未完成 1已完成 - int32 received = 6; //@go_tags(`bson:"received"`) 领取状态 默认0未领取 1已领取 + int32 active = 5; //@go_tags(`bson:"active"`) 活跃度 + int32 status = 6; //@go_tags(`bson:"status"`) 任务状态 默认0未完成 1已完成 + int32 received = 7; //@go_tags(`bson:"received"`) 领取状态 默认0未领取 1已领取 +} + +message DBTaskActive { + string id = 1; //@go_tags(`bson:"_id"`) ID + string uid = 2; //@go_tags(`bson:"uid"`) 用户ID + int32 rId = 3; //@go_tags(`bson:"taskId"`) rewardId + int32 received = 4; //@go_tags(`bson:"received"`) 领取状态 默认0未领取 1已领取 } \ No newline at end of file diff --git a/pb/proto/task/task_msg.proto b/pb/proto/task/task_msg.proto index 03fb7cc9c..89c028280 100644 --- a/pb/proto/task/task_msg.proto +++ b/pb/proto/task/task_msg.proto @@ -4,7 +4,7 @@ import "task/task_db.proto"; //领取 message TaskReceiveReq { - int32 taskTag = 1; //日常/周常/成就 + int32 taskTag = 1; // 1日常/2周常/3成就 string id = 2; //任务唯一ID } @@ -19,6 +19,16 @@ message TaskListReq { message TaskListResp { repeated DBTask list = 1; } -//激活测试 -message TaskActiveReq {} -message TaskActiveResp {} \ No newline at end of file +//活跃度 +message TaskActiveListReq { int32 taskTag = 1; } +message TaskActiveListResp { repeated DBTaskActive list = 1; } + +//活跃度领取 +message TaskActiveReceiveReq { + int32 taskTag = 1; // 1日常/2周常 + string id = 2; //唯一id +} +message TaskActiveReceiveResp { + int32 taskTag = 1; + string id = 2; +} \ No newline at end of file diff --git a/pb/proto/user/user_db.proto b/pb/proto/user/user_db.proto index ddc46f98e..17fadb160 100644 --- a/pb/proto/user/user_db.proto +++ b/pb/proto/user/user_db.proto @@ -27,6 +27,5 @@ message DBUser { bool created = 15; //@go_tags(`bson:"created"`) 创角 int32 lv = 16; //@go_tags(`bson:"lv"`) 等级 int32 vip = 17; //@go_tags(`bson:"vip"`) vip - int32 taskActive = 18; //@go_tags(`bson:"taskActive"`) 任务活跃度 - int32 diamond = 19; //@go_tags(`bson:"diamond"`) 钻石 + int32 diamond = 18; //@go_tags(`bson:"diamond"`) 钻石 } \ No newline at end of file diff --git a/pb/proto/user/user_msg.proto b/pb/proto/user/user_msg.proto index cd8642b23..221e358e0 100644 --- a/pb/proto/user/user_msg.proto +++ b/pb/proto/user/user_msg.proto @@ -2,7 +2,7 @@ syntax = "proto3"; option go_package = ".;pb"; import "errorcode.proto"; import "user/user_db.proto"; - +import "comm.proto"; //用户登录 message UserLoginReq { string account = 1; //账号 @@ -32,11 +32,10 @@ message UserCreateResp {} //添加用户资源 message UserAddResReq { - string resType = 1; //资源类型 - int32 count = 2; //资源数量 + UserAssets res = 1; //资源类型 } message UserAddResResp { - string resType = 1; //资源类型 - int32 count = 2; //资源数量 + UserAssets res = 1; //资源类型 } + diff --git a/pb/story_db.pb.go b/pb/story_db.pb.go index f52479363..85eaea8ed 100644 --- a/pb/story_db.pb.go +++ b/pb/story_db.pb.go @@ -25,13 +25,15 @@ type DBStory struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID - ChapterId int32 `protobuf:"varint,3,opt,name=chapterId,proto3" json:"chapterId" bson:"chapterId"` //章节ID - StoryId int32 `protobuf:"varint,4,opt,name=storyId,proto3" json:"storyId" bson:"storyId"` //主线关卡ID - Intensity int32 `protobuf:"varint,5,opt,name=intensity,proto3" json:"intensity" bson:"intensity"` //难度类型 - AwaredID int32 `protobuf:"varint,6,opt,name=awaredID,proto3" json:"awaredID" bson:"awaredID"` //领奖ID - Progress int32 `protobuf:"varint,7,opt,name=progress,proto3" json:"progress" bson:"progress"` // 通关进度 + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID + ChapterId int32 `protobuf:"varint,3,opt,name=chapterId,proto3" json:"chapterId" bson:"chapterId"` //章节ID + StoryId int32 `protobuf:"varint,4,opt,name=storyId,proto3" json:"storyId" bson:"storyId"` //主线关卡ID + Intensity int32 `protobuf:"varint,5,opt,name=intensity,proto3" json:"intensity" bson:"intensity"` //难度类型 + AwaredID int32 `protobuf:"varint,6,opt,name=awaredID,proto3" json:"awaredID" bson:"awaredID"` //领奖ID + Progress int32 `protobuf:"varint,7,opt,name=progress,proto3" json:"progress" bson:"progress"` // 通关进度(打了多少主关卡) + TotalBox int32 `protobuf:"varint,8,opt,name=totalBox,proto3" json:"totalBox" bson:"totalBox"` // 总关卡数量 + BranchID []int32 `protobuf:"varint,9,rep,packed,name=branchID,proto3" json:"branchID" bson:"branchID"` // 记录分支通关的情况 } func (x *DBStory) Reset() { @@ -115,11 +117,25 @@ func (x *DBStory) GetProgress() int32 { return 0 } +func (x *DBStory) GetTotalBox() int32 { + if x != nil { + return x.TotalBox + } + return 0 +} + +func (x *DBStory) GetBranchID() []int32 { + if x != nil { + return x.BranchID + } + return nil +} + var File_story_story_db_proto protoreflect.FileDescriptor var file_story_story_db_proto_rawDesc = []byte{ 0x0a, 0x14, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x64, 0x62, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb9, 0x01, 0x0a, 0x07, 0x44, 0x42, 0x53, 0x74, 0x6f, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf1, 0x01, 0x0a, 0x07, 0x44, 0x42, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x49, @@ -131,8 +147,11 @@ var file_story_story_db_proto_rawDesc = []byte{ 0x61, 0x72, 0x65, 0x64, 0x49, 0x44, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x77, 0x61, 0x72, 0x65, 0x64, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, - 0x73, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x42, 0x6f, 0x78, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x42, 0x6f, 0x78, 0x12, 0x1a, + 0x0a, 0x08, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x49, 0x44, 0x18, 0x09, 0x20, 0x03, 0x28, 0x05, + 0x52, 0x08, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x49, 0x44, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, + 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/story_msg.pb.go b/pb/story_msg.pb.go index 699cad87d..21147db3d 100644 --- a/pb/story_msg.pb.go +++ b/pb/story_msg.pb.go @@ -107,6 +107,212 @@ func (x *StoryGetListResp) GetData() []*DBStory { return nil } +// 领取关卡宝箱 +type StoryGetRewrdReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ChapterId uint32 `protobuf:"varint,1,opt,name=chapterId,proto3" json:"chapterId"` // 章节ID + BoxId uint32 `protobuf:"varint,2,opt,name=boxId,proto3" json:"boxId"` // 宝箱ID +} + +func (x *StoryGetRewrdReq) Reset() { + *x = StoryGetRewrdReq{} + if protoimpl.UnsafeEnabled { + mi := &file_story_story_msg_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StoryGetRewrdReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StoryGetRewrdReq) ProtoMessage() {} + +func (x *StoryGetRewrdReq) ProtoReflect() protoreflect.Message { + mi := &file_story_story_msg_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StoryGetRewrdReq.ProtoReflect.Descriptor instead. +func (*StoryGetRewrdReq) Descriptor() ([]byte, []int) { + return file_story_story_msg_proto_rawDescGZIP(), []int{2} +} + +func (x *StoryGetRewrdReq) GetChapterId() uint32 { + if x != nil { + return x.ChapterId + } + return 0 +} + +func (x *StoryGetRewrdReq) GetBoxId() uint32 { + if x != nil { + return x.BoxId + } + return 0 +} + +type StoryGetRewrdResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Data *DBStory `protobuf:"bytes,1,opt,name=data,proto3" json:"data"` //当前章节信息 +} + +func (x *StoryGetRewrdResp) Reset() { + *x = StoryGetRewrdResp{} + if protoimpl.UnsafeEnabled { + mi := &file_story_story_msg_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StoryGetRewrdResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StoryGetRewrdResp) ProtoMessage() {} + +func (x *StoryGetRewrdResp) ProtoReflect() protoreflect.Message { + mi := &file_story_story_msg_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StoryGetRewrdResp.ProtoReflect.Descriptor instead. +func (*StoryGetRewrdResp) Descriptor() ([]byte, []int) { + return file_story_story_msg_proto_rawDescGZIP(), []int{3} +} + +func (x *StoryGetRewrdResp) GetData() *DBStory { + if x != nil { + return x.Data + } + return nil +} + +// 挑战关卡 +type StoryChallengeReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ChapterId uint32 `protobuf:"varint,1,opt,name=chapterId,proto3" json:"chapterId"` // 章节ID + StoryId uint32 `protobuf:"varint,2,opt,name=storyId,proto3" json:"storyId"` // 小关ID +} + +func (x *StoryChallengeReq) Reset() { + *x = StoryChallengeReq{} + if protoimpl.UnsafeEnabled { + mi := &file_story_story_msg_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StoryChallengeReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StoryChallengeReq) ProtoMessage() {} + +func (x *StoryChallengeReq) ProtoReflect() protoreflect.Message { + mi := &file_story_story_msg_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StoryChallengeReq.ProtoReflect.Descriptor instead. +func (*StoryChallengeReq) Descriptor() ([]byte, []int) { + return file_story_story_msg_proto_rawDescGZIP(), []int{4} +} + +func (x *StoryChallengeReq) GetChapterId() uint32 { + if x != nil { + return x.ChapterId + } + return 0 +} + +func (x *StoryChallengeReq) GetStoryId() uint32 { + if x != nil { + return x.StoryId + } + return 0 +} + +type StoryChallengeResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Data *DBStory `protobuf:"bytes,1,opt,name=data,proto3" json:"data"` //当前章节信息 +} + +func (x *StoryChallengeResp) Reset() { + *x = StoryChallengeResp{} + if protoimpl.UnsafeEnabled { + mi := &file_story_story_msg_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StoryChallengeResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StoryChallengeResp) ProtoMessage() {} + +func (x *StoryChallengeResp) ProtoReflect() protoreflect.Message { + mi := &file_story_story_msg_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StoryChallengeResp.ProtoReflect.Descriptor instead. +func (*StoryChallengeResp) Descriptor() ([]byte, []int) { + return file_story_story_msg_proto_rawDescGZIP(), []int{5} +} + +func (x *StoryChallengeResp) GetData() *DBStory { + if x != nil { + return x.Data + } + return nil +} + var File_story_story_msg_proto protoreflect.FileDescriptor var file_story_story_msg_proto_rawDesc = []byte{ @@ -117,8 +323,23 @@ var file_story_story_msg_proto_rawDesc = []byte{ 0x22, 0x30, 0x0a, 0x10, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x44, 0x42, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x04, 0x64, 0x61, - 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x74, 0x61, 0x22, 0x46, 0x0a, 0x10, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x47, 0x65, 0x74, 0x52, 0x65, + 0x77, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x70, 0x74, 0x65, + 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x63, 0x68, 0x61, 0x70, 0x74, + 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x6f, 0x78, 0x49, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x05, 0x62, 0x6f, 0x78, 0x49, 0x64, 0x22, 0x31, 0x0a, 0x11, 0x53, 0x74, + 0x6f, 0x72, 0x79, 0x47, 0x65, 0x74, 0x52, 0x65, 0x77, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, + 0x1c, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, + 0x44, 0x42, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x4b, 0x0a, + 0x11, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x52, + 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x63, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x49, 0x64, + 0x12, 0x18, 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x22, 0x32, 0x0a, 0x12, 0x53, 0x74, + 0x6f, 0x72, 0x79, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x12, 0x1c, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, + 0x2e, 0x44, 0x42, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, + 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -133,19 +354,25 @@ func file_story_story_msg_proto_rawDescGZIP() []byte { return file_story_story_msg_proto_rawDescData } -var file_story_story_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_story_story_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_story_story_msg_proto_goTypes = []interface{}{ - (*StoryGetListReq)(nil), // 0: StoryGetListReq - (*StoryGetListResp)(nil), // 1: StoryGetListResp - (*DBStory)(nil), // 2: DBStory + (*StoryGetListReq)(nil), // 0: StoryGetListReq + (*StoryGetListResp)(nil), // 1: StoryGetListResp + (*StoryGetRewrdReq)(nil), // 2: StoryGetRewrdReq + (*StoryGetRewrdResp)(nil), // 3: StoryGetRewrdResp + (*StoryChallengeReq)(nil), // 4: StoryChallengeReq + (*StoryChallengeResp)(nil), // 5: StoryChallengeResp + (*DBStory)(nil), // 6: DBStory } var file_story_story_msg_proto_depIdxs = []int32{ - 2, // 0: StoryGetListResp.data:type_name -> DBStory - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 6, // 0: StoryGetListResp.data:type_name -> DBStory + 6, // 1: StoryGetRewrdResp.data:type_name -> DBStory + 6, // 2: StoryChallengeResp.data:type_name -> DBStory + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_story_story_msg_proto_init() } @@ -179,6 +406,54 @@ func file_story_story_msg_proto_init() { return nil } } + file_story_story_msg_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StoryGetRewrdReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_story_story_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StoryGetRewrdResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_story_story_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StoryChallengeReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_story_story_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StoryChallengeResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -186,7 +461,7 @@ func file_story_story_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_story_story_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/task_db.pb.go b/pb/task_db.pb.go index be257bb50..2866b456a 100644 --- a/pb/task_db.pb.go +++ b/pb/task_db.pb.go @@ -29,8 +29,9 @@ type DBTask struct { Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID TaskId int32 `protobuf:"varint,3,opt,name=taskId,proto3" json:"taskId" bson:"taskId"` //任务Id Progress int32 `protobuf:"varint,4,opt,name=progress,proto3" json:"progress" bson:"progress"` //任务进度/完成次数 - Status int32 `protobuf:"varint,5,opt,name=status,proto3" json:"status" bson:"status"` // 任务状态 默认0未完成 1已完成 - Received int32 `protobuf:"varint,6,opt,name=received,proto3" json:"received" bson:"received"` //领取状态 默认0未领取 1已领取 + Active int32 `protobuf:"varint,5,opt,name=active,proto3" json:"active" bson:"active"` //活跃度 + Status int32 `protobuf:"varint,6,opt,name=status,proto3" json:"status" bson:"status"` // 任务状态 默认0未完成 1已完成 + Received int32 `protobuf:"varint,7,opt,name=received,proto3" json:"received" bson:"received"` //领取状态 默认0未领取 1已领取 } func (x *DBTask) Reset() { @@ -93,6 +94,13 @@ func (x *DBTask) GetProgress() int32 { return 0 } +func (x *DBTask) GetActive() int32 { + if x != nil { + return x.Active + } + return 0 +} + func (x *DBTask) GetStatus() int32 { if x != nil { return x.Status @@ -107,21 +115,100 @@ func (x *DBTask) GetReceived() int32 { return 0 } +type DBTaskActive struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID + RId int32 `protobuf:"varint,3,opt,name=rId,proto3" json:"rId" bson:"taskId"` //rewardId + Received int32 `protobuf:"varint,4,opt,name=received,proto3" json:"received" bson:"received"` //领取状态 默认0未领取 1已领取 +} + +func (x *DBTaskActive) Reset() { + *x = DBTaskActive{} + if protoimpl.UnsafeEnabled { + mi := &file_task_task_db_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DBTaskActive) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DBTaskActive) ProtoMessage() {} + +func (x *DBTaskActive) ProtoReflect() protoreflect.Message { + mi := &file_task_task_db_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DBTaskActive.ProtoReflect.Descriptor instead. +func (*DBTaskActive) Descriptor() ([]byte, []int) { + return file_task_task_db_proto_rawDescGZIP(), []int{1} +} + +func (x *DBTaskActive) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *DBTaskActive) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *DBTaskActive) GetRId() int32 { + if x != nil { + return x.RId + } + return 0 +} + +func (x *DBTaskActive) GetReceived() int32 { + if x != nil { + return x.Received + } + return 0 +} + var File_task_task_db_proto protoreflect.FileDescriptor var file_task_task_db_proto_rawDesc = []byte{ 0x0a, 0x12, 0x74, 0x61, 0x73, 0x6b, 0x2f, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x92, 0x01, 0x0a, 0x06, 0x44, 0x42, 0x54, 0x61, 0x73, 0x6b, 0x12, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xaa, 0x01, 0x0a, 0x06, 0x44, 0x42, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x72, 0x6f, - 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, - 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, - 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, 0x16, 0x0a, + 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, + 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, + 0x64, 0x22, 0x5e, 0x0a, 0x0c, 0x44, 0x42, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, + 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x75, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x03, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, + 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, + 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -136,9 +223,10 @@ func file_task_task_db_proto_rawDescGZIP() []byte { return file_task_task_db_proto_rawDescData } -var file_task_task_db_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_task_task_db_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_task_task_db_proto_goTypes = []interface{}{ - (*DBTask)(nil), // 0: DBTask + (*DBTask)(nil), // 0: DBTask + (*DBTaskActive)(nil), // 1: DBTaskActive } var file_task_task_db_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type @@ -166,6 +254,18 @@ func file_task_task_db_proto_init() { return nil } } + file_task_task_db_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DBTaskActive); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -173,7 +273,7 @@ func file_task_task_db_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_task_task_db_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 2, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/task_msg.pb.go b/pb/task_msg.pb.go index e97ee1efe..878ca2750 100644 --- a/pb/task_msg.pb.go +++ b/pb/task_msg.pb.go @@ -26,7 +26,7 @@ type TaskReceiveReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TaskTag int32 `protobuf:"varint,1,opt,name=taskTag,proto3" json:"taskTag"` //日常/周常/成就 + TaskTag int32 `protobuf:"varint,1,opt,name=taskTag,proto3" json:"taskTag"` // 1日常/2周常/3成就 Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id"` //任务唯一ID } @@ -218,15 +218,17 @@ func (x *TaskListResp) GetList() []*DBTask { return nil } -//激活测试 -type TaskActiveReq struct { +//活跃度 +type TaskActiveListReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + TaskTag int32 `protobuf:"varint,1,opt,name=taskTag,proto3" json:"taskTag"` } -func (x *TaskActiveReq) Reset() { - *x = TaskActiveReq{} +func (x *TaskActiveListReq) Reset() { + *x = TaskActiveListReq{} if protoimpl.UnsafeEnabled { mi := &file_task_task_msg_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -234,13 +236,13 @@ func (x *TaskActiveReq) Reset() { } } -func (x *TaskActiveReq) String() string { +func (x *TaskActiveListReq) String() string { return protoimpl.X.MessageStringOf(x) } -func (*TaskActiveReq) ProtoMessage() {} +func (*TaskActiveListReq) ProtoMessage() {} -func (x *TaskActiveReq) ProtoReflect() protoreflect.Message { +func (x *TaskActiveListReq) ProtoReflect() protoreflect.Message { mi := &file_task_task_msg_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -252,19 +254,28 @@ func (x *TaskActiveReq) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use TaskActiveReq.ProtoReflect.Descriptor instead. -func (*TaskActiveReq) Descriptor() ([]byte, []int) { +// Deprecated: Use TaskActiveListReq.ProtoReflect.Descriptor instead. +func (*TaskActiveListReq) Descriptor() ([]byte, []int) { return file_task_task_msg_proto_rawDescGZIP(), []int{4} } -type TaskActiveResp struct { +func (x *TaskActiveListReq) GetTaskTag() int32 { + if x != nil { + return x.TaskTag + } + return 0 +} + +type TaskActiveListResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + List []*DBTaskActive `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` } -func (x *TaskActiveResp) Reset() { - *x = TaskActiveResp{} +func (x *TaskActiveListResp) Reset() { + *x = TaskActiveListResp{} if protoimpl.UnsafeEnabled { mi := &file_task_task_msg_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -272,13 +283,13 @@ func (x *TaskActiveResp) Reset() { } } -func (x *TaskActiveResp) String() string { +func (x *TaskActiveListResp) String() string { return protoimpl.X.MessageStringOf(x) } -func (*TaskActiveResp) ProtoMessage() {} +func (*TaskActiveListResp) ProtoMessage() {} -func (x *TaskActiveResp) ProtoReflect() protoreflect.Message { +func (x *TaskActiveListResp) ProtoReflect() protoreflect.Message { mi := &file_task_task_msg_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -290,11 +301,129 @@ func (x *TaskActiveResp) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use TaskActiveResp.ProtoReflect.Descriptor instead. -func (*TaskActiveResp) Descriptor() ([]byte, []int) { +// Deprecated: Use TaskActiveListResp.ProtoReflect.Descriptor instead. +func (*TaskActiveListResp) Descriptor() ([]byte, []int) { return file_task_task_msg_proto_rawDescGZIP(), []int{5} } +func (x *TaskActiveListResp) GetList() []*DBTaskActive { + if x != nil { + return x.List + } + return nil +} + +//活跃度领取 +type TaskActiveReceiveReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TaskTag int32 `protobuf:"varint,1,opt,name=taskTag,proto3" json:"taskTag"` // 1日常/2周常 + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id"` //唯一id +} + +func (x *TaskActiveReceiveReq) Reset() { + *x = TaskActiveReceiveReq{} + if protoimpl.UnsafeEnabled { + mi := &file_task_task_msg_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TaskActiveReceiveReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TaskActiveReceiveReq) ProtoMessage() {} + +func (x *TaskActiveReceiveReq) ProtoReflect() protoreflect.Message { + mi := &file_task_task_msg_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TaskActiveReceiveReq.ProtoReflect.Descriptor instead. +func (*TaskActiveReceiveReq) Descriptor() ([]byte, []int) { + return file_task_task_msg_proto_rawDescGZIP(), []int{6} +} + +func (x *TaskActiveReceiveReq) GetTaskTag() int32 { + if x != nil { + return x.TaskTag + } + return 0 +} + +func (x *TaskActiveReceiveReq) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type TaskActiveReceiveResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TaskTag int32 `protobuf:"varint,1,opt,name=taskTag,proto3" json:"taskTag"` + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id"` +} + +func (x *TaskActiveReceiveResp) Reset() { + *x = TaskActiveReceiveResp{} + if protoimpl.UnsafeEnabled { + mi := &file_task_task_msg_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TaskActiveReceiveResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TaskActiveReceiveResp) ProtoMessage() {} + +func (x *TaskActiveReceiveResp) ProtoReflect() protoreflect.Message { + mi := &file_task_task_msg_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TaskActiveReceiveResp.ProtoReflect.Descriptor instead. +func (*TaskActiveReceiveResp) Descriptor() ([]byte, []int) { + return file_task_task_msg_proto_rawDescGZIP(), []int{7} +} + +func (x *TaskActiveReceiveResp) GetTaskTag() int32 { + if x != nil { + return x.TaskTag + } + return 0 +} + +func (x *TaskActiveReceiveResp) GetId() string { + if x != nil { + return x.Id + } + return "" +} + var File_task_task_msg_proto protoreflect.FileDescriptor var file_task_task_msg_proto_rawDesc = []byte{ @@ -312,10 +441,23 @@ var file_task_task_msg_proto_rawDesc = []byte{ 0x52, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x22, 0x2b, 0x0a, 0x0c, 0x54, 0x61, 0x73, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1b, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x54, 0x61, 0x73, 0x6b, - 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x0f, 0x0a, 0x0d, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, - 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x22, 0x10, 0x0a, 0x0e, 0x54, 0x61, 0x73, 0x6b, 0x41, - 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, - 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x2d, 0x0a, 0x11, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, + 0x74, 0x69, 0x76, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x74, + 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, + 0x73, 0x6b, 0x54, 0x61, 0x67, 0x22, 0x37, 0x0a, 0x12, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, + 0x69, 0x76, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, 0x6c, + 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x54, 0x61, + 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x40, + 0x0a, 0x14, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x63, 0x65, + 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, + 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, + 0x22, 0x41, 0x0a, 0x15, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, + 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x73, + 0x6b, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, 0x73, 0x6b, + 0x54, 0x61, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x02, 0x69, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -330,23 +472,27 @@ func file_task_task_msg_proto_rawDescGZIP() []byte { return file_task_task_msg_proto_rawDescData } -var file_task_task_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_task_task_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_task_task_msg_proto_goTypes = []interface{}{ - (*TaskReceiveReq)(nil), // 0: TaskReceiveReq - (*TaskReceiveResp)(nil), // 1: TaskReceiveResp - (*TaskListReq)(nil), // 2: TaskListReq - (*TaskListResp)(nil), // 3: TaskListResp - (*TaskActiveReq)(nil), // 4: TaskActiveReq - (*TaskActiveResp)(nil), // 5: TaskActiveResp - (*DBTask)(nil), // 6: DBTask + (*TaskReceiveReq)(nil), // 0: TaskReceiveReq + (*TaskReceiveResp)(nil), // 1: TaskReceiveResp + (*TaskListReq)(nil), // 2: TaskListReq + (*TaskListResp)(nil), // 3: TaskListResp + (*TaskActiveListReq)(nil), // 4: TaskActiveListReq + (*TaskActiveListResp)(nil), // 5: TaskActiveListResp + (*TaskActiveReceiveReq)(nil), // 6: TaskActiveReceiveReq + (*TaskActiveReceiveResp)(nil), // 7: TaskActiveReceiveResp + (*DBTask)(nil), // 8: DBTask + (*DBTaskActive)(nil), // 9: DBTaskActive } var file_task_task_msg_proto_depIdxs = []int32{ - 6, // 0: TaskListResp.list:type_name -> DBTask - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 8, // 0: TaskListResp.list:type_name -> DBTask + 9, // 1: TaskActiveListResp.list:type_name -> DBTaskActive + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_task_task_msg_proto_init() } @@ -405,7 +551,7 @@ func file_task_task_msg_proto_init() { } } file_task_task_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TaskActiveReq); i { + switch v := v.(*TaskActiveListReq); i { case 0: return &v.state case 1: @@ -417,7 +563,31 @@ func file_task_task_msg_proto_init() { } } file_task_task_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TaskActiveResp); i { + switch v := v.(*TaskActiveListResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_task_task_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TaskActiveReceiveReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_task_task_msg_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TaskActiveReceiveResp); i { case 0: return &v.state case 1: @@ -435,7 +605,7 @@ func file_task_task_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_task_task_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 8, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/user_db.pb.go b/pb/user_db.pb.go index a9a260f1d..e9badda16 100644 --- a/pb/user_db.pb.go +++ b/pb/user_db.pb.go @@ -113,8 +113,7 @@ type DBUser struct { Created bool `protobuf:"varint,15,opt,name=created,proto3" json:"created" bson:"created"` //创角 Lv int32 `protobuf:"varint,16,opt,name=lv,proto3" json:"lv" bson:"lv"` //等级 Vip int32 `protobuf:"varint,17,opt,name=vip,proto3" json:"vip" bson:"vip"` // vip - TaskActive int32 `protobuf:"varint,18,opt,name=taskActive,proto3" json:"taskActive" bson:"taskActive"` //任务活跃度 - Diamond int32 `protobuf:"varint,19,opt,name=diamond,proto3" json:"diamond" bson:"diamond"` // 钻石 + Diamond int32 `protobuf:"varint,18,opt,name=diamond,proto3" json:"diamond" bson:"diamond"` // 钻石 } func (x *DBUser) Reset() { @@ -268,13 +267,6 @@ func (x *DBUser) GetVip() int32 { return 0 } -func (x *DBUser) GetTaskActive() int32 { - if x != nil { - return x.TaskActive - } - return 0 -} - func (x *DBUser) GetDiamond() int32 { if x != nil { return x.Diamond @@ -293,7 +285,7 @@ var file_user_user_db_proto_rawDesc = []byte{ 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x22, 0xc6, 0x03, + 0x02, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x22, 0xa6, 0x03, 0x0a, 0x06, 0x44, 0x42, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, @@ -318,10 +310,8 @@ var file_user_user_db_proto_rawDesc = []byte{ 0x12, 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x10, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x69, - 0x70, 0x18, 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x76, 0x69, 0x70, 0x12, 0x1e, 0x0a, 0x0a, - 0x74, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x12, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, 0x18, 0x0a, 0x07, - 0x64, 0x69, 0x61, 0x6d, 0x6f, 0x6e, 0x64, 0x18, 0x13, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x64, + 0x70, 0x18, 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x76, 0x69, 0x70, 0x12, 0x18, 0x0a, 0x07, + 0x64, 0x69, 0x61, 0x6d, 0x6f, 0x6e, 0x64, 0x18, 0x12, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x64, 0x69, 0x61, 0x6d, 0x6f, 0x6e, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } diff --git a/pb/user_msg.pb.go b/pb/user_msg.pb.go index a40aff39d..4115f7259 100644 --- a/pb/user_msg.pb.go +++ b/pb/user_msg.pb.go @@ -372,8 +372,7 @@ type UserAddResReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ResType string `protobuf:"bytes,1,opt,name=resType,proto3" json:"resType"` //资源类型 - Count int32 `protobuf:"varint,2,opt,name=count,proto3" json:"count"` //资源数量 + Res *UserAssets `protobuf:"bytes,1,opt,name=res,proto3" json:"res"` //资源类型 } func (x *UserAddResReq) Reset() { @@ -408,18 +407,11 @@ func (*UserAddResReq) Descriptor() ([]byte, []int) { return file_user_user_msg_proto_rawDescGZIP(), []int{7} } -func (x *UserAddResReq) GetResType() string { +func (x *UserAddResReq) GetRes() *UserAssets { if x != nil { - return x.ResType + return x.Res } - return "" -} - -func (x *UserAddResReq) GetCount() int32 { - if x != nil { - return x.Count - } - return 0 + return nil } type UserAddResResp struct { @@ -427,8 +419,7 @@ type UserAddResResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ResType string `protobuf:"bytes,1,opt,name=resType,proto3" json:"resType"` //资源类型 - Count int32 `protobuf:"varint,2,opt,name=count,proto3" json:"count"` //资源数量 + Res *UserAssets `protobuf:"bytes,1,opt,name=res,proto3" json:"res"` //资源类型 } func (x *UserAddResResp) Reset() { @@ -463,18 +454,11 @@ func (*UserAddResResp) Descriptor() ([]byte, []int) { return file_user_user_msg_proto_rawDescGZIP(), []int{8} } -func (x *UserAddResResp) GetResType() string { +func (x *UserAddResResp) GetRes() *UserAssets { if x != nil { - return x.ResType + return x.Res } - return "" -} - -func (x *UserAddResResp) GetCount() int32 { - if x != nil { - return x.Count - } - return 0 + return nil } var File_user_user_msg_proto protoreflect.FileDescriptor @@ -483,39 +467,37 @@ var file_user_user_msg_proto_rawDesc = []byte{ 0x0a, 0x13, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x73, 0x65, - 0x72, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3a, 0x0a, 0x0c, 0x55, 0x73, - 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x03, 0x73, 0x69, 0x64, 0x22, 0x2c, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, - 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x22, 0x3d, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, - 0x73, 0x69, 0x64, 0x22, 0x4c, 0x0a, 0x10, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 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, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x22, 0x2e, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x73, - 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0a, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x64, 0x61, 0x74, - 0x61, 0x22, 0x2b, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, - 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x10, - 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x22, 0x3f, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x52, 0x65, - 0x71, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x22, 0x40, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, - 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x72, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3a, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, + 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x73, + 0x69, 0x64, 0x22, 0x2c, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, + 0x65, 0x73, 0x70, 0x12, 0x1b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x22, 0x3d, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, + 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, + 0x03, 0x73, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x73, 0x69, 0x64, 0x22, + 0x4c, 0x0a, 0x10, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, + 0x65, 0x73, 0x70, 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, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2e, 0x0a, + 0x0c, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x43, 0x61, + 0x63, 0x68, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, + 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, + 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x10, 0x0a, 0x0e, 0x55, 0x73, + 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x2e, 0x0a, 0x0d, + 0x55, 0x73, 0x65, 0x72, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x52, 0x65, 0x71, 0x12, 0x1d, 0x0a, + 0x03, 0x72, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65, + 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x03, 0x72, 0x65, 0x73, 0x22, 0x2f, 0x0a, 0x0e, + 0x55, 0x73, 0x65, 0x72, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, + 0x0a, 0x03, 0x72, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, + 0x65, 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x03, 0x72, 0x65, 0x73, 0x42, 0x06, 0x5a, + 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -544,16 +526,19 @@ var file_user_user_msg_proto_goTypes = []interface{}{ (*DBUser)(nil), // 9: DBUser (ErrorCode)(0), // 10: ErrorCode (*CacheUser)(nil), // 11: CacheUser + (*UserAssets)(nil), // 12: UserAssets } var file_user_user_msg_proto_depIdxs = []int32{ 9, // 0: UserLoginResp.data:type_name -> DBUser 10, // 1: UserRegisterResp.Code:type_name -> ErrorCode 11, // 2: UserLoadResp.data:type_name -> CacheUser - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 12, // 3: UserAddResReq.res:type_name -> UserAssets + 12, // 4: UserAddResResp.res:type_name -> UserAssets + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_user_user_msg_proto_init() } @@ -563,6 +548,7 @@ func file_user_user_msg_proto_init() { } file_errorcode_proto_init() file_user_user_db_proto_init() + file_comm_proto_init() if !protoimpl.UnsafeEnabled { file_user_user_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UserLoginReq); i { diff --git a/sys/configure/structs/Tables.go b/sys/configure/structs/Tables.go index 5c1c029cf..d689c13ab 100644 --- a/sys/configure/structs/Tables.go +++ b/sys/configure/structs/Tables.go @@ -42,6 +42,11 @@ type Tables struct { shopitem *Game_shopitem taskRound *Game_taskRound activeReward *Game_activeReward + storyChapter *Game_storyChapter + storyEasy *Game_storyEasy + storyHard *Game_storyHard + storyPurgatory *Game_storyPurgatory + serverList *Game_serverList } func NewTables(loader JsonLoader) (*Tables, error) { @@ -229,5 +234,35 @@ func NewTables(loader JsonLoader) (*Tables, error) { if tables.activeReward, err = NewGame_activeReward(buf) ; err != nil { return nil, err } + if buf, err = loader("game_storychapter") ; err != nil { + return nil, err + } + if tables.storyChapter, err = NewGame_storyChapter(buf) ; err != nil { + return nil, err + } + if buf, err = loader("game_storyeasy") ; err != nil { + return nil, err + } + if tables.storyEasy, err = NewGame_storyEasy(buf) ; err != nil { + return nil, err + } + if buf, err = loader("game_storyhard") ; err != nil { + return nil, err + } + if tables.storyHard, err = NewGame_storyHard(buf) ; err != nil { + return nil, err + } + if buf, err = loader("game_storypurgatory") ; err != nil { + return nil, err + } + if tables.storyPurgatory, err = NewGame_storyPurgatory(buf) ; err != nil { + return nil, err + } + if buf, err = loader("game_serverlist") ; err != nil { + return nil, err + } + if tables.serverList, err = NewGame_serverList(buf) ; err != nil { + return nil, err + } return tables, nil } diff --git a/sys/configure/structs/game.comData.go b/sys/configure/structs/game.comData.go new file mode 100644 index 000000000..90e4d0dbd --- /dev/null +++ b/sys/configure/structs/game.comData.go @@ -0,0 +1,29 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +package cfg + +import "errors" + +type Game_comData struct { + Index string + Var string + Intr string +} + +func (Game_comData) GetTypeId() int { + return -395344177 +} + +func NewGame_comData(_buf map[string]interface{}) (_v *Game_comData, err error) { + _v = &Game_comData{} + { var _ok_ bool; if _v.Index, _ok_ = _buf["index"].(string); !_ok_ { err = errors.New("index error"); return } } + { var _ok_ bool; if _v.Var, _ok_ = _buf["var"].(string); !_ok_ { err = errors.New("var error"); return } } + { var _ok_ bool; if _v.Intr, _ok_ = _buf["intr"].(string); !_ok_ { err = errors.New("intr error"); return } } + return +} diff --git a/sys/configure/structs/game.serverList.go b/sys/configure/structs/game.serverList.go new file mode 100644 index 000000000..3b5f79227 --- /dev/null +++ b/sys/configure/structs/game.serverList.go @@ -0,0 +1,42 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +package cfg + +type Game_serverList struct { + _dataMap map[int32]*Game_serverListData + _dataList []*Game_serverListData +} + +func NewGame_serverList(_buf []map[string]interface{}) (*Game_serverList, error) { + _dataList := make([]*Game_serverListData, 0, len(_buf)) + dataMap := make(map[int32]*Game_serverListData) + for _, _ele_ := range _buf { + if _v, err2 := NewGame_serverListData(_ele_); err2 != nil { + return nil, err2 + } else { + _dataList = append(_dataList, _v) + dataMap[_v.Id] = _v + } + } + return &Game_serverList{_dataList:_dataList, _dataMap:dataMap}, nil +} + +func (table *Game_serverList) GetDataMap() map[int32]*Game_serverListData { + return table._dataMap +} + +func (table *Game_serverList) GetDataList() []*Game_serverListData { + return table._dataList +} + +func (table *Game_serverList) Get(key int32) *Game_serverListData { + return table._dataMap[key] +} + + diff --git a/sys/configure/structs/game.serverListData.go b/sys/configure/structs/game.serverListData.go new file mode 100644 index 000000000..d220bfbd7 --- /dev/null +++ b/sys/configure/structs/game.serverListData.go @@ -0,0 +1,33 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +package cfg + +import "errors" + +type Game_serverListData struct { + Id int32 + Ip string + Port int32 + GroupId int32 + Name string +} + +func (Game_serverListData) GetTypeId() int { + return 292904775 +} + +func NewGame_serverListData(_buf map[string]interface{}) (_v *Game_serverListData, err error) { + _v = &Game_serverListData{} + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) } + { var _ok_ bool; if _v.Ip, _ok_ = _buf["ip"].(string); !_ok_ { err = errors.New("ip error"); return } } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["port"].(float64); !_ok_ { err = errors.New("port error"); return }; _v.Port = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["groupId"].(float64); !_ok_ { err = errors.New("groupId error"); return }; _v.GroupId = int32(_tempNum_) } + { var _ok_ bool; if _v.Name, _ok_ = _buf["name"].(string); !_ok_ { err = errors.New("name error"); return } } + return +} diff --git a/sys/db/benchmark/hero_db.pb.go b/sys/db/benchmark/hero_db.pb.go new file mode 100644 index 000000000..57168f8c9 --- /dev/null +++ b/sys/db/benchmark/hero_db.pb.go @@ -0,0 +1,460 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.20.0 +// source: hero/hero_db.proto + +package bench + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type SkillData struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SkillID int32 `protobuf:"varint,1,opt,name=skillID,proto3" json:"skillID"` + SkillLv int32 `protobuf:"varint,2,opt,name=skillLv,proto3" json:"skillLv"` +} + +func (x *SkillData) Reset() { + *x = SkillData{} + if protoimpl.UnsafeEnabled { + mi := &file_hero_hero_db_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SkillData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SkillData) ProtoMessage() {} + +func (x *SkillData) ProtoReflect() protoreflect.Message { + mi := &file_hero_hero_db_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SkillData.ProtoReflect.Descriptor instead. +func (*SkillData) Descriptor() ([]byte, []int) { + return file_hero_hero_db_proto_rawDescGZIP(), []int{0} +} + +func (x *SkillData) GetSkillID() int32 { + if x != nil { + return x.SkillID + } + return 0 +} + +func (x *SkillData) GetSkillLv() int32 { + if x != nil { + return x.SkillLv + } + return 0 +} + +type DBHero struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` + HeroID int32 `protobuf:"varint,3,opt,name=heroID,proto3" json:"heroID" bson:"heroID"` // 英雄的配置表ID + Star int32 `protobuf:"varint,4,opt,name=star,proto3" json:"star"` // 英雄星级 + Lv int32 `protobuf:"varint,5,opt,name=lv,proto3" json:"lv"` // 英雄等级 + Exp int32 `protobuf:"varint,6,opt,name=exp,proto3" json:"exp"` // 英雄经验 + JuexingLv int32 `protobuf:"varint,7,opt,name=juexingLv,proto3" json:"juexingLv" bson:"juexingLv"` //觉醒等级 + CaptainSkill int32 `protobuf:"varint,8,opt,name=captainSkill,proto3" json:"captainSkill" bson:"captainSkill"` //队长技能 + NormalSkill []*SkillData `protobuf:"bytes,9,rep,name=normalSkill,proto3" json:"normalSkill" bson:"normalSkill"` //普通技能 + Property map[string]int32 `protobuf:"bytes,10,rep,name=property,proto3" json:"property" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 属性相关 + AddProperty map[string]int32 `protobuf:"bytes,11,rep,name=addProperty,proto3" json:"addProperty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"addProperty"` //附加属性相关 + Formation int32 `protobuf:"varint,12,opt,name=formation,proto3" json:"formation"` // 阵型类型 + CardType int32 `protobuf:"varint,13,opt,name=cardType,proto3" json:"cardType" bson:"cardType"` //卡片类型(升星卡、经验卡、技能升级卡) + CurSkin int32 `protobuf:"varint,14,opt,name=curSkin,proto3" json:"curSkin" bson:"curSkin"` //当前装备的皮肤ID + Skins []int32 `protobuf:"varint,15,rep,packed,name=skins,proto3" json:"skins"` // 所有皮肤ID + Block bool `protobuf:"varint,16,opt,name=block,proto3" json:"block"` // 锁定 + EquipID []string `protobuf:"bytes,17,rep,name=equipID,proto3" json:"equipID" bson:"equipID"` //装备 objID + ResonateNum int32 `protobuf:"varint,18,opt,name=resonateNum,proto3" json:"resonateNum" bson:"resonateNum"` //共鸣次数 + DistributionResonate int32 `protobuf:"varint,19,opt,name=distributionResonate,proto3" json:"distributionResonate" bson:"distributionResonate"` //分配的共鸣能量 + Energy map[int32]int32 `protobuf:"bytes,20,rep,name=energy,proto3" json:"energy" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // @go_tags(`bson:"energy"`)能量分配到哪里[1,0] + SameCount int32 `protobuf:"varint,21,opt,name=sameCount,proto3" json:"sameCount" bson:"sameCount"` // 卡片叠加数量 + SuiteId int32 `protobuf:"varint,22,opt,name=suiteId,proto3" json:"suiteId" bson:"suiteId"` // 套装Id + SuiteExtId int32 `protobuf:"varint,23,opt,name=suiteExtId,proto3" json:"suiteExtId"` // go_tags(`bson:"suiteExtId"`) 扩展套装Id + IsOverlying bool `protobuf:"varint,24,opt,name=isOverlying,proto3" json:"isOverlying"` // go_tags(`bson:"isOverlying"`) 是否允许叠加 默认true +} + +func (x *DBHero) Reset() { + *x = DBHero{} + if protoimpl.UnsafeEnabled { + mi := &file_hero_hero_db_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DBHero) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DBHero) ProtoMessage() {} + +func (x *DBHero) ProtoReflect() protoreflect.Message { + mi := &file_hero_hero_db_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DBHero.ProtoReflect.Descriptor instead. +func (*DBHero) Descriptor() ([]byte, []int) { + return file_hero_hero_db_proto_rawDescGZIP(), []int{1} +} + +func (x *DBHero) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *DBHero) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *DBHero) GetHeroID() int32 { + if x != nil { + return x.HeroID + } + return 0 +} + +func (x *DBHero) GetStar() int32 { + if x != nil { + return x.Star + } + return 0 +} + +func (x *DBHero) GetLv() int32 { + if x != nil { + return x.Lv + } + return 0 +} + +func (x *DBHero) GetExp() int32 { + if x != nil { + return x.Exp + } + return 0 +} + +func (x *DBHero) GetJuexingLv() int32 { + if x != nil { + return x.JuexingLv + } + return 0 +} + +func (x *DBHero) GetCaptainSkill() int32 { + if x != nil { + return x.CaptainSkill + } + return 0 +} + +func (x *DBHero) GetNormalSkill() []*SkillData { + if x != nil { + return x.NormalSkill + } + return nil +} + +func (x *DBHero) GetProperty() map[string]int32 { + if x != nil { + return x.Property + } + return nil +} + +func (x *DBHero) GetAddProperty() map[string]int32 { + if x != nil { + return x.AddProperty + } + return nil +} + +func (x *DBHero) GetFormation() int32 { + if x != nil { + return x.Formation + } + return 0 +} + +func (x *DBHero) GetCardType() int32 { + if x != nil { + return x.CardType + } + return 0 +} + +func (x *DBHero) GetCurSkin() int32 { + if x != nil { + return x.CurSkin + } + return 0 +} + +func (x *DBHero) GetSkins() []int32 { + if x != nil { + return x.Skins + } + return nil +} + +func (x *DBHero) GetBlock() bool { + if x != nil { + return x.Block + } + return false +} + +func (x *DBHero) GetEquipID() []string { + if x != nil { + return x.EquipID + } + return nil +} + +func (x *DBHero) GetResonateNum() int32 { + if x != nil { + return x.ResonateNum + } + return 0 +} + +func (x *DBHero) GetDistributionResonate() int32 { + if x != nil { + return x.DistributionResonate + } + return 0 +} + +func (x *DBHero) GetEnergy() map[int32]int32 { + if x != nil { + return x.Energy + } + return nil +} + +func (x *DBHero) GetSameCount() int32 { + if x != nil { + return x.SameCount + } + return 0 +} + +func (x *DBHero) GetSuiteId() int32 { + if x != nil { + return x.SuiteId + } + return 0 +} + +func (x *DBHero) GetSuiteExtId() int32 { + if x != nil { + return x.SuiteExtId + } + return 0 +} + +func (x *DBHero) GetIsOverlying() bool { + if x != nil { + return x.IsOverlying + } + return false +} + +var File_hero_hero_db_proto protoreflect.FileDescriptor + +var file_hero_hero_db_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x68, 0x65, 0x72, 0x6f, 0x2f, 0x68, 0x65, 0x72, 0x6f, 0x5f, 0x64, 0x62, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3f, 0x0a, 0x09, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x44, 0x61, 0x74, + 0x61, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x6b, 0x69, 0x6c, 0x6c, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x07, 0x73, 0x6b, 0x69, 0x6c, 0x6c, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x73, + 0x6b, 0x69, 0x6c, 0x6c, 0x4c, 0x76, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x73, 0x6b, + 0x69, 0x6c, 0x6c, 0x4c, 0x76, 0x22, 0xa6, 0x07, 0x0a, 0x06, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, + 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x44, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, + 0x61, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x74, 0x61, 0x72, 0x12, 0x0e, + 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x12, 0x10, + 0x0a, 0x03, 0x65, 0x78, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x65, 0x78, 0x70, + 0x12, 0x1c, 0x0a, 0x09, 0x6a, 0x75, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x4c, 0x76, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x09, 0x6a, 0x75, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x4c, 0x76, 0x12, 0x22, + 0x0a, 0x0c, 0x63, 0x61, 0x70, 0x74, 0x61, 0x69, 0x6e, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x63, 0x61, 0x70, 0x74, 0x61, 0x69, 0x6e, 0x53, 0x6b, 0x69, + 0x6c, 0x6c, 0x12, 0x2c, 0x0a, 0x0b, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x53, 0x6b, 0x69, 0x6c, + 0x6c, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x44, + 0x61, 0x74, 0x61, 0x52, 0x0b, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x53, 0x6b, 0x69, 0x6c, 0x6c, + 0x12, 0x31, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x18, 0x0a, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x70, + 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x70, 0x65, + 0x72, 0x74, 0x79, 0x12, 0x3a, 0x0a, 0x0b, 0x61, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, + 0x74, 0x79, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, + 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x52, 0x0b, 0x61, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x12, + 0x1c, 0x0a, 0x09, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0c, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x09, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, + 0x08, 0x63, 0x61, 0x72, 0x64, 0x54, 0x79, 0x70, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x08, 0x63, 0x61, 0x72, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, + 0x53, 0x6b, 0x69, 0x6e, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, 0x53, + 0x6b, 0x69, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x6b, 0x69, 0x6e, 0x73, 0x18, 0x0f, 0x20, 0x03, + 0x28, 0x05, 0x52, 0x05, 0x73, 0x6b, 0x69, 0x6e, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x12, + 0x18, 0x0a, 0x07, 0x65, 0x71, 0x75, 0x69, 0x70, 0x49, 0x44, 0x18, 0x11, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x07, 0x65, 0x71, 0x75, 0x69, 0x70, 0x49, 0x44, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x73, + 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x12, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, + 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x32, 0x0a, 0x14, 0x64, + 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x6f, 0x6e, + 0x61, 0x74, 0x65, 0x18, 0x13, 0x20, 0x01, 0x28, 0x05, 0x52, 0x14, 0x64, 0x69, 0x73, 0x74, 0x72, + 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x12, + 0x2b, 0x0a, 0x06, 0x65, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x18, 0x14, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x13, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x2e, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x65, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x12, 0x1c, 0x0a, 0x09, + 0x73, 0x61, 0x6d, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x15, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x09, 0x73, 0x61, 0x6d, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, + 0x69, 0x74, 0x65, 0x49, 0x64, 0x18, 0x16, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x73, 0x75, 0x69, + 0x74, 0x65, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x75, 0x69, 0x74, 0x65, 0x45, 0x78, 0x74, + 0x49, 0x64, 0x18, 0x17, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x75, 0x69, 0x74, 0x65, 0x45, + 0x78, 0x74, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x69, 0x73, 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x79, + 0x69, 0x6e, 0x67, 0x18, 0x18, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x4f, 0x76, 0x65, + 0x72, 0x6c, 0x79, 0x69, 0x6e, 0x67, 0x1a, 0x3b, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, + 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, + 0x02, 0x38, 0x01, 0x1a, 0x3e, 0x0a, 0x10, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, + 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, + 0x02, 0x38, 0x01, 0x1a, 0x39, 0x0a, 0x0b, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, + 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_hero_hero_db_proto_rawDescOnce sync.Once + file_hero_hero_db_proto_rawDescData = file_hero_hero_db_proto_rawDesc +) + +func file_hero_hero_db_proto_rawDescGZIP() []byte { + file_hero_hero_db_proto_rawDescOnce.Do(func() { + file_hero_hero_db_proto_rawDescData = protoimpl.X.CompressGZIP(file_hero_hero_db_proto_rawDescData) + }) + return file_hero_hero_db_proto_rawDescData +} + +var file_hero_hero_db_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_hero_hero_db_proto_goTypes = []interface{}{ + (*SkillData)(nil), // 0: SkillData + (*DBHero)(nil), // 1: DBHero + nil, // 2: DBHero.PropertyEntry + nil, // 3: DBHero.AddPropertyEntry + nil, // 4: DBHero.EnergyEntry +} +var file_hero_hero_db_proto_depIdxs = []int32{ + 0, // 0: DBHero.normalSkill:type_name -> SkillData + 2, // 1: DBHero.property:type_name -> DBHero.PropertyEntry + 3, // 2: DBHero.addProperty:type_name -> DBHero.AddPropertyEntry + 4, // 3: DBHero.energy:type_name -> DBHero.EnergyEntry + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_hero_hero_db_proto_init() } +func file_hero_hero_db_proto_init() { + if File_hero_hero_db_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_hero_hero_db_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SkillData); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_hero_hero_db_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DBHero); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_hero_hero_db_proto_rawDesc, + NumEnums: 0, + NumMessages: 5, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_hero_hero_db_proto_goTypes, + DependencyIndexes: file_hero_hero_db_proto_depIdxs, + MessageInfos: file_hero_hero_db_proto_msgTypes, + }.Build() + File_hero_hero_db_proto = out.File + file_hero_hero_db_proto_rawDesc = nil + file_hero_hero_db_proto_goTypes = nil + file_hero_hero_db_proto_depIdxs = nil +} diff --git a/sys/db/benchmark/main_test.go b/sys/db/benchmark/main_test.go new file mode 100644 index 000000000..e5cca839c --- /dev/null +++ b/sys/db/benchmark/main_test.go @@ -0,0 +1,83 @@ +package bench + +import ( + "fmt" + "testing" +) + +type Benchmark struct { + Parallelism int + Data interface{} + TargetBuilder TargetBuilder +} + +type Target struct { + GetHeroList func() (interface{}, error) +} + +type TargetBuilder struct { + Name string + Make func(bench Benchmark) (Target, error) +} + +// func genData(n int) []*DBHero { +// heroes := []*DBHero{} + +// GetList(&heroes) + +// return heroes +// } + +func compose(parallelisms, dataSize []int, builders []TargetBuilder) []Benchmark { + benchmarks := make([]Benchmark, 0, len(parallelisms)*len(dataSize)*len(builders)) + for _, p := range parallelisms { + for _, _ = range dataSize { + // d := genData(k) + for _, builder := range builders { + benchmarks = append(benchmarks, Benchmark{ + Parallelism: p, + // Data: d, + TargetBuilder: builder, + }) + } + + } + } + + return benchmarks +} + +func RunBenchmark(b *testing.B, benchmarks []Benchmark) { + // f, _ := os.Create("c://pprof") + // pprof.WriteHeapProfile(f) + // defer f.Close() + for _, bench := range benchmarks { + b.Run(fmt.Sprintf("%s-parallelism(%d)-", bench.TargetBuilder.Name, bench.Parallelism), func(b *testing.B) { + target, err := bench.TargetBuilder.Make(bench) + if err != nil { + b.Fatalf("%s setup fail: %v", bench.TargetBuilder.Name, err) + } + if bench.Parallelism == 0 { + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := target.GetHeroList() + if err != nil { + b.Errorf("%s error during benchmark: %v", bench.TargetBuilder.Name, err) + } + } + } else { + b.SetParallelism(bench.Parallelism) //指定并行数目 + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { //并行执行 + for pb.Next() { + _, err := target.GetHeroList() + if err != nil { + b.Errorf("%s error during benchmark: %v", bench.TargetBuilder.Name, err) + } + } + }) + } + b.StopTimer() + }) + } +} diff --git a/sys/db/benchmark/query_test.go b/sys/db/benchmark/query_test.go new file mode 100644 index 000000000..b9cb055a6 --- /dev/null +++ b/sys/db/benchmark/query_test.go @@ -0,0 +1,276 @@ +package bench + +import ( + "context" + "fmt" + "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/mgo" + "go_dreamfactory/sys/db" + "log" + "os" + reflect "reflect" + "testing" + + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" +) + +var mdb *db.DB + +// func TestMain(m *testing.M) { +// imgo, err := mgo.NewSys(mgo.SetMongodbUrl("mongodb://admin:123456@10.0.0.9:27018"), mgo.SetMongodbDatabase("dreamfactory")) +// if err != nil { +// log.Fatal(err) +// } +// mdb = &db.DB{} +// mdb.SetMgo(imgo) + +// defer os.Exit(m.Run()) +// } + +var mgoDb *mongo.Database + +func TestMain(m *testing.M) { + option := options.Client().ApplyURI("mongodb://admin:123456@10.0.0.9:27018") + client, err := mongo.Connect(context.TODO(), option) + if err != nil { + log.Fatal(err) + } + log.Print("connect mongo success") + mgoDb = client.Database("dreamfactory") + + // + imgo, err := mgo.NewSys(mgo.SetMongodbUrl("mongodb://admin:123456@10.0.0.9:27018"), mgo.SetMongodbDatabase("dreamfactory")) + if err != nil { + log.Fatal(err) + } + mdb = &db.DB{} + mdb.SetMgo(imgo) + defer os.Exit(m.Run()) +} + +func BenchmarkMarsh(b *testing.B) { + + var ( + // ncpu = runtime.NumCPU() + parallelisms = []int{2} //平行数 + dataSizes = []int{10, 100, 1000} //测试次数 + builders = []TargetBuilder{ + { + Name: "gen", + Make: func(bench Benchmark) (Target, error) { + return Target{ + GetHeroList: func() (any, error) { + // heroes := GetList3(new(DBHero)) + heroes := []*DBHero{} + GetList(&heroes) + return heroes, nil + }, + }, nil + }, + }, + { + Name: "reflect", + Make: func(bench Benchmark) (Target, error) { + return Target{ + GetHeroList: func() (interface{}, error) { + heroes := []*DBHero{} + GetListO(&heroes) + return heroes, nil + }, + }, nil + }, + }, + } + ) + + RunBenchmark(b, compose(parallelisms, dataSizes, builders)) +} + +func GetList(data interface{}) (err error) { + var c *mongo.Cursor + t := reflect.TypeOf(data) + if t.Kind() == reflect.Ptr { + t = t.Elem() + } + + if t.Kind() == reflect.Slice { + t = t.Elem() + } else { + err = fmt.Errorf("Input param is not a slice") + } + sl := reflect.ValueOf(data) + if t.Kind() == reflect.Ptr { + sl = sl.Elem() + } + st := sl.Type() + sliceType := st.Elem() + if sliceType.Kind() == reflect.Ptr { + sliceType = sliceType.Elem() + } + + //query from mgo + // if c, err = mdb.Mgo().Find(core.SqlTable("hero"), bson.M{}); err != nil { + if c, err = mgoDb.Collection("hreo").Find(context.Background(), bson.M{}); err != nil { + return err + } else { + var temp map[string]interface{} = make(map[string]interface{}) + + for c.Next(context.Background()) { + _id := c.Current.Lookup("_id").StringValue() + if sl.Len() < sl.Cap() { + sl.Set(sl.Slice(0, sl.Len()+1)) + elem := sl.Index(sl.Len() - 1) + if elem.IsNil() { + elem.Set(reflect.New(sliceType)) + } + if err = c.Decode(elem.Elem().Addr().Interface()); err != nil { + return + } + temp[_id] = elem.Elem().Addr().Interface() + continue + } + elem := reflect.New(sliceType) + sl.Set(reflect.Append(sl, elem)) + if err = c.Decode(elem.Elem().Addr().Interface()); err != nil { + return + } + temp[_id] = elem.Elem().Addr().Interface() + } + if len(temp) == 0 { //没有数据自己返回 + return + } + } + + return err +} + +func GetListO(data interface{}) (err error) { + var c *mongo.Cursor + t := reflect.TypeOf(data) + if t.Kind() == reflect.Ptr { + t = t.Elem() + } + + if t.Kind() == reflect.Slice { + t = t.Elem() + } else { + err = fmt.Errorf("Input param is not a slice") + } + sl := reflect.ValueOf(data) + if t.Kind() == reflect.Ptr { + sl = sl.Elem() + } + st := sl.Type() + sliceType := st.Elem() + if sliceType.Kind() == reflect.Ptr { + sliceType = sliceType.Elem() + } + + //query from mgo + if c, err = mdb.Mgo().Find(core.SqlTable("hero"), bson.M{}); err != nil { + // if c, err = mgoDb.Collection("hreo").Find(context.Background(), bson.M{}); err != nil { + return err + } else { + var temp map[string]interface{} = make(map[string]interface{}) + + for c.Next(context.Background()) { + _id := c.Current.Lookup("_id").StringValue() + if sl.Len() < sl.Cap() { + sl.Set(sl.Slice(0, sl.Len()+1)) + elem := sl.Index(sl.Len() - 1) + if elem.IsNil() { + elem.Set(reflect.New(sliceType)) + } + if err = c.Decode(elem.Elem().Addr().Interface()); err != nil { + return + } + temp[_id] = elem.Elem().Addr().Interface() + continue + } + elem := reflect.New(sliceType) + sl.Set(reflect.Append(sl, elem)) + if err = c.Decode(elem.Elem().Addr().Interface()); err != nil { + return + } + temp[_id] = elem.Elem().Addr().Interface() + } + if len(temp) == 0 { //没有数据自己返回 + return + } + } + + return err +} + +func GetList2(data interface{}) (err error) { + // c, err := mdb.Mgo().Find(core.SqlTable("hero"), bson.M{}) + c, err := mgoDb.Collection("hero").Find(context.Background(), bson.M{}) + if err != nil { + fmt.Println(err) + return + } + // defer c.Close(context.Background()) + + list := make([]interface{}, 0) + for c.Next(context.Background()) { + val := reflect.ValueOf(data).Interface() + if err = c.Decode(val); err != nil { + continue + } + + list = append(list, val) + } + return +} + +func GetList3(data any) []any { + // c, err := mdb.Mgo().Collection("hero").Find(context.Background(), bson.M{}) + c, err := mgoDb.Collection("hero").Find(context.Background(), bson.M{}) + if err != nil { + fmt.Println(err) + } + defer c.Close(context.Background()) + + list := make([]any, 0) + + for c.Next(context.Background()) { + _val := reflect.ValueOf(data).Interface() + err2 := c.Decode(_val) + if err2 != nil { + continue + } + + list = append(list, _val) + } + return list +} + +func GetList4(data *DBHero) []any { + // c, err := mdb.Mgo().Find(core.SqlTable("hero"), bson.M{}) + c, err := mgoDb.Collection("hero").Find(context.Background(), bson.M{}) + if err != nil { + fmt.Println(err) + } + defer c.Close(context.Background()) + + list := make([]any, 0) + for c.Next(context.Background()) { + err2 := c.Decode(data) + if err2 != nil { + continue + } + + list = append(list, data) + } + return list +} +func BenchmarkSimple(b *testing.B) { + // f, _ := os.Create("c://pprof2") + // pprof.WriteHeapProfile(f) + // defer f.Close() + for i := 0; i < b.N; i++ { + GetList4(new(DBHero)) + } +} diff --git a/sys/db/db.go b/sys/db/db.go index 0736b4457..0a3fb4372 100644 --- a/sys/db/db.go +++ b/sys/db/db.go @@ -30,6 +30,10 @@ func (this *DB) Mgo() mgo.ISys { return this.mgo } +func (this *DB) SetMgo(mgo mgo.ISys) { + this.mgo = mgo +} + func (this *DB) Table(tableName string) *DB { this.mgo.Collection(core.SqlTable(tableName)).Database() return this diff --git a/utils/time_test.go b/utils/time_test.go index a7d801e05..ea0708f6c 100644 --- a/utils/time_test.go +++ b/utils/time_test.go @@ -7,8 +7,8 @@ import ( ) func TestIsToday(t *testing.T) { - // tt := time.Unix(1657163870, 0) - // fmt.Println(utils.IsToday(tt)) + fmt.Println(utils.IsToday(1657163870)) + } func TestSubTime(t *testing.T) {