From b3e9f53ff7321525c517232fef326a0d287a6d1b Mon Sep 17 00:00:00 2001 From: zhaocy Date: Wed, 29 Jun 2022 11:23:39 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_global.json | 32 +++ bin/json/game_hero.json | 70 ++++--- bin/json/game_skillafteratk.json | 129 +++++++++++- bin/json/game_skillatk.json | 192 ++++++++++++++++++ sys/configure/structs/Tables.go | 21 ++ sys/configure/structs/game.atn.go | 39 +--- .../structs/game.equipAttrlibraryData.go | 102 +++------- sys/configure/structs/game.equipData.go | 163 ++++----------- sys/configure/structs/game.global.go | 42 ++++ sys/configure/structs/game.globalData.go | 29 +++ sys/configure/structs/game.heroData.go | 2 + 11 files changed, 565 insertions(+), 256 deletions(-) create mode 100644 bin/json/game_global.json create mode 100644 sys/configure/structs/game.global.go create mode 100644 sys/configure/structs/game.globalData.go diff --git a/bin/json/game_global.json b/bin/json/game_global.json new file mode 100644 index 000000000..75bc5b99e --- /dev/null +++ b/bin/json/game_global.json @@ -0,0 +1,32 @@ +[ + { + "index": "max_hy", + "var": "30", + "intr": "最大好友数" + }, + { + "index": "max_getreward", + "var": "10002,99", + "intr": "领取/赠送奖励" + }, + { + "index": "max_get", + "var": "30", + "intr": "每日领取/赠送次数" + }, + { + "index": "max_char", + "var": "100", + "intr": "聊天最大输入字符数量" + }, + { + "index": "max_hmd", + "var": "30", + "intr": "最大黑名单数" + }, + { + "index": "task_reset", + "var": "8", + "intr": "日/周常任务刷新时间,8点" + } +] \ No newline at end of file diff --git a/bin/json/game_hero.json b/bin/json/game_hero.json index 093b0cb74..79b2f0c67 100644 --- a/bin/json/game_hero.json +++ b/bin/json/game_hero.json @@ -24,7 +24,8 @@ }, "skill1": 110001, "skill2": 110002, - "skill3": 110003 + "skill3": 110003, + "enteranivalue": 100 }, { "id": 11002, @@ -51,7 +52,8 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 }, { "id": 11003, @@ -78,7 +80,8 @@ }, "skill1": 110004, "skill2": 110005, - "skill3": 110012 + "skill3": 110012, + "enteranivalue": 0 }, { "id": 11004, @@ -105,7 +108,8 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 }, { "id": 11005, @@ -132,7 +136,8 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 }, { "id": 11006, @@ -159,7 +164,8 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 }, { "id": 11009, @@ -186,7 +192,8 @@ }, "skill1": 110010, "skill2": 110011, - "skill3": 110013 + "skill3": 110013, + "enteranivalue": 0 }, { "id": 22002, @@ -213,7 +220,8 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 }, { "id": 90001, @@ -240,7 +248,8 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 }, { "id": 11011, @@ -267,7 +276,8 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 }, { "id": 11008, @@ -294,7 +304,8 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 }, { "id": 11017, @@ -321,7 +332,8 @@ }, "skill1": 110006, "skill2": 110007, - "skill3": 110014 + "skill3": 110014, + "enteranivalue": 0 }, { "id": 11018, @@ -348,7 +360,8 @@ }, "skill1": 110008, "skill2": 110009, - "skill3": 110015 + "skill3": 110015, + "enteranivalue": 0 }, { "id": 11019, @@ -375,7 +388,8 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 }, { "id": 11020, @@ -402,7 +416,8 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 }, { "id": 11021, @@ -429,7 +444,8 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 }, { "id": 11099, @@ -456,7 +472,8 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 }, { "id": 12001, @@ -483,7 +500,8 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 }, { "id": 12003, @@ -501,7 +519,7 @@ ], "intr": "", "events": "EventDataSet/Hero_11003.asset", - "cite": "11003", + "cite": "", "effectstay": [], "hpspace": { "x": 0, @@ -510,7 +528,8 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 }, { "id": 12009, @@ -537,7 +556,8 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 }, { "id": 12017, @@ -564,7 +584,8 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 }, { "id": 12018, @@ -582,7 +603,7 @@ ], "intr": "", "events": "EventDataSet/Hero_11018.asset", - "cite": "11018", + "cite": "", "effectstay": [], "hpspace": { "x": 0, @@ -591,6 +612,7 @@ }, "skill1": 0, "skill2": 0, - "skill3": 0 + "skill3": 0, + "enteranivalue": 0 } ] \ No newline at end of file diff --git a/bin/json/game_skillafteratk.json b/bin/json/game_skillafteratk.json index 88acf186b..262daed53 100644 --- a/bin/json/game_skillafteratk.json +++ b/bin/json/game_skillafteratk.json @@ -6,10 +6,10 @@ "Limit": 1, "Where": [], "Order": [ - "Type=rand" + "Type=Rnd" ], "EmitPR": 1000, - "Type": "tongyongshanghai", + "Type": "Dmg", "Argu": [ "DoVal=1,ProSou1=0,Pro1=Total_Atk,ProPar1=800" ], @@ -21,15 +21,15 @@ }, { "Id": 200012101, - "Desc": "对敌方全体造成攻击力80%以及防御力120%的伤害", + "Desc": "对全体目标造成攻击力80%以及防御力120%的伤害", "From": 2, "Limit": 5, "Where": [], "Order": [ - "Type=rand" + "Type=Rnd" ], "EmitPR": 1000, - "Type": "tongyongshanghai", + "Type": "Dmg", "Argu": [ "DoVal=1,ProSou1=0,Pro1=Total_Atk,ProPar1=800,ProSou2=0,Pro2=Total_Def,ProPar2=1200" ], @@ -41,15 +41,17 @@ }, { "Id": 200013101, - "Desc": "对敌方全体攻击小于自身的目标造成攻击力80%的伤害", + "Desc": "对全体攻击小于自身的目标造成攻击力80%的伤害", "From": 2, "Limit": 5, "Where": [ - "Type=ProJudge,JudgeType=0,Key=Total_Atk,Op=1" + "Type=ProJudge,JudgeType=0,Key=Total_Atk,Op=0" + ], + "Order": [ + "Type=Rnd" ], - "Order": [], "EmitPR": 1000, - "Type": "tongyongshanghai", + "Type": "Dmg", "Argu": [ "DoVal=1,ProSou1=0,Pro1=Total_Atk,ProPar1=800" ], @@ -58,5 +60,114 @@ "FailFollowSK": [], "MustHit": false, "Tags": [] + }, + { + "Id": 200014101, + "Desc": "随机对敌方3个目标造成80%攻击力伤害,优先选择防御力小于自身的目标", + "From": 2, + "Limit": 3, + "Where": [], + "Order": [ + "Type=Sort,SortType=0,Key=Total_Def,SortMet=0", + "Type=Rnd,SortType=ProJudge,RelyType=0,Key=Total_Def,Op=0", + "Type=Rnd,SortType=ProJudge,RelyType=0,Key=Total_Def,Op=5" + ], + "EmitPR": 1000, + "Type": "Dmg", + "Argu": [ + "DoVal=1,ProSou1=0,Pro1=Total_Atk,ProPar1=800" + ], + "AddEffect": false, + "FollowSK": [], + "FailFollowSK": [], + "MustHit": false, + "Tags": [] + }, + { + "Id": 200015101, + "Desc": "随机对敌方防御最低的3个目标造成80%攻击力伤害", + "From": 2, + "Limit": 3, + "Where": [], + "Order": [ + "Type=Sort,SortType=0,Key=Total_Def,SortMet=0" + ], + "EmitPR": 1000, + "Type": "Dmg", + "Argu": [ + "DoVal=1,ProSou1=0,Pro1=Total_Atk,ProPar1=800" + ], + "AddEffect": false, + "FollowSK": [], + "FailFollowSK": [], + "MustHit": false, + "Tags": [] + }, + { + "Id": 200016101, + "Desc": "对敌方全体防御力小于100的敌方造成80%攻击力伤害", + "From": 2, + "Limit": 5, + "Where": [ + "Type=ProJudge,JudgeType=1,Target=1,Key=Total_Def,Op=1,Val=100" + ], + "Order": [ + "Type=Rnd" + ], + "EmitPR": 1000, + "Type": "Dmg", + "Argu": [ + "DoVal=1,ProSou1=0,Pro1=Total_Atk,ProPar1=800" + ], + "AddEffect": false, + "FollowSK": [], + "FailFollowSK": [], + "MustHit": false, + "Tags": [] + }, + { + "Id": 200017101, + "Desc": "对敌方全体的敌方造成攻击力110%伤害,", + "From": 2, + "Limit": 5, + "Where": [], + "Order": [ + "Type=Rnd" + ], + "EmitPR": 1000, + "Type": "Dmg", + "Argu": [ + "DoVal=1,ProSou1=0,Pro1=Total_Atk,ProPar1=1100" + ], + "AddEffect": false, + "FollowSK": [ + 200017102 + ], + "FailFollowSK": [], + "MustHit": false, + "Tags": [] + }, + { + "Id": 200017102, + "Desc": "若自身攻击力大于100,则额外对全体敌方攻击力小于自身的目标造成攻击力50%伤害", + "From": 2, + "Limit": 5, + "Where": [ + "Type=ProJudge,JudgeType=1,Target=0,Key=Total_Atk,Op=0,Val=100", + "Type=ProJudge,JudgeType=0,Key=Total_Atk,Op=0" + ], + "Order": [ + "Type=Rnd" + ], + "EmitPR": 1000, + "Type": "Dmg", + "Argu": [ + "DoVal=1,ProSou1=0,Pro1=Total_Atk,ProPar1=50" + ], + "AddEffect": false, + "FollowSK": [], + "FailFollowSK": [], + "MustHit": false, + "Tags": [] } ] \ No newline at end of file diff --git a/bin/json/game_skillatk.json b/bin/json/game_skillatk.json index c5b86e138..944e8106a 100644 --- a/bin/json/game_skillatk.json +++ b/bin/json/game_skillatk.json @@ -142,5 +142,197 @@ ] } ] + }, + { + "Id": 100014000, + "Name": "", + "Type": 1, + "Desc": "随机对敌方3个目标造成80%攻击力伤害,优先选择防御力小于自身的目标", + "MaxLV": 6, + "CD": [ + 4, + 4, + 4, + 4, + 4, + 4 + ], + "Target": 2, + "ChildSkill": [ + { + "Id": [ + 200014101 + ] + }, + { + "Id": [ + 200014101 + ] + }, + { + "Id": [ + 200014101 + ] + }, + { + "Id": [ + 200014101 + ] + }, + { + "Id": [ + 200014101 + ] + }, + { + "Id": [ + 200014101 + ] + } + ] + }, + { + "Id": 100015000, + "Name": "", + "Type": 1, + "Desc": "随机对敌方防御最低的3个目标造成80%攻击力伤害", + "MaxLV": 6, + "CD": [ + 4, + 4, + 4, + 4, + 4, + 4 + ], + "Target": 2, + "ChildSkill": [ + { + "Id": [ + 200015101 + ] + }, + { + "Id": [ + 200015101 + ] + }, + { + "Id": [ + 200015101 + ] + }, + { + "Id": [ + 200015101 + ] + }, + { + "Id": [ + 200015101 + ] + }, + { + "Id": [ + 200015101 + ] + } + ] + }, + { + "Id": 100016000, + "Name": "", + "Type": 1, + "Desc": "对敌方全体防御力小于100的敌方造成80%攻击力伤害", + "MaxLV": 6, + "CD": [ + 4, + 4, + 4, + 4, + 4, + 4 + ], + "Target": 2, + "ChildSkill": [ + { + "Id": [ + 200016101 + ] + }, + { + "Id": [ + 200016101 + ] + }, + { + "Id": [ + 200016101 + ] + }, + { + "Id": [ + 200016101 + ] + }, + { + "Id": [ + 200016101 + ] + }, + { + "Id": [ + 200016101 + ] + } + ] + }, + { + "Id": 100017000, + "Name": "", + "Type": 1, + "Desc": "对敌方全体的敌方造成攻击力110%伤害,若自身攻击力大于100,则额外对全体敌方攻击力小于自身的目标造成攻击力50%伤害", + "MaxLV": 6, + "CD": [ + 4, + 4, + 4, + 4, + 4, + 4 + ], + "Target": 2, + "ChildSkill": [ + { + "Id": [ + 200017101 + ] + }, + { + "Id": [ + 200017101 + ] + }, + { + "Id": [ + 200017101 + ] + }, + { + "Id": [ + 200017101 + ] + }, + { + "Id": [ + 200017101 + ] + }, + { + "Id": [ + 200017101 + ] + } + ] } ] \ No newline at end of file diff --git a/sys/configure/structs/Tables.go b/sys/configure/structs/Tables.go index fc2b47427..8cc314d0b 100644 --- a/sys/configure/structs/Tables.go +++ b/sys/configure/structs/Tables.go @@ -12,6 +12,7 @@ package cfg type JsonLoader func(string) ([]map[string]interface{}, error) type Tables struct { + global *Game_global hero *Game_hero ui *Game_ui skill *Game_skill @@ -26,12 +27,14 @@ type Tables struct { heroStargrow *Game_heroStargrow heroLevelgrow *Game_heroLevelgrow heroStarup *Game_heroStarup + heroExp *Game_heroExp heroLevelup *Game_heroLevelup equip *Game_equip equipAttrlibrary *Game_equipAttrlibrary equipSuit *Game_equipSuit equipIntensify *Game_equipIntensify item *Game_item + heroSkillLevel *Game_heroSkillLevel } func NewTables(loader JsonLoader) (*Tables, error) { @@ -39,6 +42,12 @@ func NewTables(loader JsonLoader) (*Tables, error) { var buf []map[string]interface{} tables := &Tables{} + if buf, err = loader("game_global") ; err != nil { + return nil, err + } + if tables.global, err = NewGame_global(buf) ; err != nil { + return nil, err + } if buf, err = loader("game_hero") ; err != nil { return nil, err } @@ -123,6 +132,12 @@ func NewTables(loader JsonLoader) (*Tables, error) { if tables.heroStarup, err = NewGame_heroStarup(buf) ; err != nil { return nil, err } + if buf, err = loader("game_heroexp") ; err != nil { + return nil, err + } + if tables.heroExp, err = NewGame_heroExp(buf) ; err != nil { + return nil, err + } if buf, err = loader("game_herolevelup") ; err != nil { return nil, err } @@ -159,5 +174,11 @@ func NewTables(loader JsonLoader) (*Tables, error) { if tables.item, err = NewGame_item(buf) ; err != nil { return nil, err } + if buf, err = loader("game_heroskilllevel") ; err != nil { + return nil, err + } + if tables.heroSkillLevel, err = NewGame_heroSkillLevel(buf) ; err != nil { + return nil, err + } return tables, nil } diff --git a/sys/configure/structs/game.atn.go b/sys/configure/structs/game.atn.go index 2a9b45be8..67a89b5b5 100644 --- a/sys/configure/structs/game.atn.go +++ b/sys/configure/structs/game.atn.go @@ -1,3 +1,4 @@ + //------------------------------------------------------------------------------ // // This code was generated by a tool. @@ -10,39 +11,19 @@ package cfg import "errors" type Game_atn struct { - A string //资源类型 - T string //资源名称 - N int32 //数量 + A string + T string + N int32 } func (Game_atn) GetTypeId() int { - return -1770297697 + return -1770297697 } func NewGame_atn(_buf map[string]interface{}) (_v *Game_atn, err error) { - _v = &Game_atn{} - { - var _ok_ bool - if _v.A, _ok_ = _buf["a"].(string); !_ok_ { - err = errors.New("a error") - return - } - } - { - var _ok_ bool - if _v.T, _ok_ = _buf["t"].(string); !_ok_ { - err = errors.New("t error") - return - } - } - { - var _ok_ bool - var _tempNum_ float64 - if _tempNum_, _ok_ = _buf["n"].(float64); !_ok_ { - err = errors.New("n error") - return - } - _v.N = int32(_tempNum_) - } - return + _v = &Game_atn{} + { var _ok_ bool; if _v.A, _ok_ = _buf["a"].(string); !_ok_ { err = errors.New("a error"); return } } + { var _ok_ bool; if _v.T, _ok_ = _buf["t"].(string); !_ok_ { err = errors.New("t error"); return } } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["n"].(float64); !_ok_ { err = errors.New("n error"); return }; _v.N = int32(_tempNum_) } + return } diff --git a/sys/configure/structs/game.equipAttrlibraryData.go b/sys/configure/structs/game.equipAttrlibraryData.go index b3c9988dd..bd4de379e 100644 --- a/sys/configure/structs/game.equipAttrlibraryData.go +++ b/sys/configure/structs/game.equipAttrlibraryData.go @@ -1,3 +1,4 @@ + //------------------------------------------------------------------------------ // // This code was generated by a tool. @@ -10,87 +11,38 @@ package cfg import "errors" type Game_equipAttrlibraryData struct { - Key int32 - Libraryid int32 - Attrkey string - Attrvar int32 - Probability int32 - Addition []int32 + Key int32 + Libraryid int32 + Attrkey string + Attrvar int32 + Probability int32 + Addition []int32 } func (Game_equipAttrlibraryData) GetTypeId() int { - return -437457248 + return -437457248 } func NewGame_equipAttrlibraryData(_buf map[string]interface{}) (_v *Game_equipAttrlibraryData, err error) { - _v = &Game_equipAttrlibraryData{} - { - var _ok_ bool - var _tempNum_ float64 - if _tempNum_, _ok_ = _buf["key"].(float64); !_ok_ { - err = errors.New("key error") - return - } - _v.Key = int32(_tempNum_) - } - { - var _ok_ bool - var _tempNum_ float64 - if _tempNum_, _ok_ = _buf["libraryid"].(float64); !_ok_ { - err = errors.New("libraryid error") - return - } - _v.Libraryid = int32(_tempNum_) - } - { - var _ok_ bool - if _v.Attrkey, _ok_ = _buf["attrkey"].(string); !_ok_ { - err = errors.New("attrkey error") - return - } - } - { - var _ok_ bool - var _tempNum_ float64 - if _tempNum_, _ok_ = _buf["attrvar"].(float64); !_ok_ { - err = errors.New("attrvar error") - return - } - _v.Attrvar = int32(_tempNum_) - } - { - var _ok_ bool - var _tempNum_ float64 - if _tempNum_, _ok_ = _buf["probability"].(float64); !_ok_ { - err = errors.New("probability error") - return - } - _v.Probability = int32(_tempNum_) - } - { - var _arr_ []interface{} - var _ok_ bool - if _arr_, _ok_ = _buf["Addition"].([]interface{}); !_ok_ { - err = errors.New("Addition error") - return - } + _v = &Game_equipAttrlibraryData{} + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["key"].(float64); !_ok_ { err = errors.New("key error"); return }; _v.Key = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["libraryid"].(float64); !_ok_ { err = errors.New("libraryid error"); return }; _v.Libraryid = int32(_tempNum_) } + { var _ok_ bool; if _v.Attrkey, _ok_ = _buf["attrkey"].(string); !_ok_ { err = errors.New("attrkey error"); return } } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["attrvar"].(float64); !_ok_ { err = errors.New("attrvar error"); return }; _v.Attrvar = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["probability"].(float64); !_ok_ { err = errors.New("probability error"); return }; _v.Probability = int32(_tempNum_) } + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["Addition"].([]interface{}); !_ok_ { err = errors.New("Addition error"); return } - _v.Addition = make([]int32, 0, len(_arr_)) + _v.Addition = make([]int32, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ int32 + { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } + _v.Addition = append(_v.Addition, _list_v_) + } + } - for _, _e_ := range _arr_ { - var _list_v_ int32 - { - var _ok_ bool - var _x_ float64 - if _x_, _ok_ = _e_.(float64); !_ok_ { - err = errors.New("_list_v_ error") - return - } - _list_v_ = int32(_x_) - } - _v.Addition = append(_v.Addition, _list_v_) - } - } - - return + return } diff --git a/sys/configure/structs/game.equipData.go b/sys/configure/structs/game.equipData.go index 2f2644dde..df17d74b1 100644 --- a/sys/configure/structs/game.equipData.go +++ b/sys/configure/structs/game.equipData.go @@ -1,3 +1,4 @@ + //------------------------------------------------------------------------------ // // This code was generated by a tool. @@ -10,133 +11,57 @@ package cfg import "errors" type Game_equipData struct { - Id int32 - Suittype int32 - Suitintr string - Pos int32 - Star int32 - Leadlibrary int32 - Addattrnum []int32 - Addattrnump []int32 - Addlibrary int32 + Id int32 + Suittype int32 + Suitintr string + Pos int32 + Star int32 + Leadlibrary int32 + Addattrnum []int32 + Addattrnump []int32 + Addlibrary int32 } func (Game_equipData) GetTypeId() int { - return 1778846974 + return 1778846974 } func NewGame_equipData(_buf map[string]interface{}) (_v *Game_equipData, err error) { - _v = &Game_equipData{} - { - 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 - var _tempNum_ float64 - if _tempNum_, _ok_ = _buf["suittype"].(float64); !_ok_ { - err = errors.New("suittype error") - return - } - _v.Suittype = int32(_tempNum_) - } - { - var _ok_ bool - if _v.Suitintr, _ok_ = _buf["suitintr"].(string); !_ok_ { - err = errors.New("suitintr error") - return - } - } - { - var _ok_ bool - var _tempNum_ float64 - if _tempNum_, _ok_ = _buf["pos"].(float64); !_ok_ { - err = errors.New("pos error") - return - } - _v.Pos = int32(_tempNum_) - } - { - var _ok_ bool - var _tempNum_ float64 - if _tempNum_, _ok_ = _buf["star"].(float64); !_ok_ { - err = errors.New("star error") - return - } - _v.Star = int32(_tempNum_) - } - { - var _ok_ bool - var _tempNum_ float64 - if _tempNum_, _ok_ = _buf["leadlibrary"].(float64); !_ok_ { - err = errors.New("leadlibrary error") - return - } - _v.Leadlibrary = int32(_tempNum_) - } - { - var _arr_ []interface{} - var _ok_ bool - if _arr_, _ok_ = _buf["addattrnum"].([]interface{}); !_ok_ { - err = errors.New("addattrnum error") - return - } + _v = &Game_equipData{} + { 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; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["suittype"].(float64); !_ok_ { err = errors.New("suittype error"); return }; _v.Suittype = int32(_tempNum_) } + { var _ok_ bool; if _v.Suitintr, _ok_ = _buf["suitintr"].(string); !_ok_ { err = errors.New("suitintr error"); return } } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["pos"].(float64); !_ok_ { err = errors.New("pos error"); return }; _v.Pos = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["star"].(float64); !_ok_ { err = errors.New("star error"); return }; _v.Star = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["leadlibrary"].(float64); !_ok_ { err = errors.New("leadlibrary error"); return }; _v.Leadlibrary = int32(_tempNum_) } + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["addattrnum"].([]interface{}); !_ok_ { err = errors.New("addattrnum error"); return } - _v.Addattrnum = make([]int32, 0, len(_arr_)) + _v.Addattrnum = make([]int32, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ int32 + { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } + _v.Addattrnum = append(_v.Addattrnum, _list_v_) + } + } - for _, _e_ := range _arr_ { - var _list_v_ int32 - { - var _ok_ bool - var _x_ float64 - if _x_, _ok_ = _e_.(float64); !_ok_ { - err = errors.New("_list_v_ error") - return - } - _list_v_ = int32(_x_) - } - _v.Addattrnum = append(_v.Addattrnum, _list_v_) - } - } + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["addattrnump"].([]interface{}); !_ok_ { err = errors.New("addattrnump error"); return } - { - var _arr_ []interface{} - var _ok_ bool - if _arr_, _ok_ = _buf["addattrnump"].([]interface{}); !_ok_ { - err = errors.New("addattrnump error") - return - } + _v.Addattrnump = make([]int32, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ int32 + { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } + _v.Addattrnump = append(_v.Addattrnump, _list_v_) + } + } - _v.Addattrnump = make([]int32, 0, len(_arr_)) - - for _, _e_ := range _arr_ { - var _list_v_ int32 - { - var _ok_ bool - var _x_ float64 - if _x_, _ok_ = _e_.(float64); !_ok_ { - err = errors.New("_list_v_ error") - return - } - _list_v_ = int32(_x_) - } - _v.Addattrnump = append(_v.Addattrnump, _list_v_) - } - } - - { - var _ok_ bool - var _tempNum_ float64 - if _tempNum_, _ok_ = _buf["addlibrary"].(float64); !_ok_ { - err = errors.New("addlibrary error") - return - } - _v.Addlibrary = int32(_tempNum_) - } - return + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["addlibrary"].(float64); !_ok_ { err = errors.New("addlibrary error"); return }; _v.Addlibrary = int32(_tempNum_) } + return } diff --git a/sys/configure/structs/game.global.go b/sys/configure/structs/game.global.go new file mode 100644 index 000000000..16bfe0898 --- /dev/null +++ b/sys/configure/structs/game.global.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_global struct { + _dataMap map[string]*Game_globalData + _dataList []*Game_globalData +} + +func NewGame_global(_buf []map[string]interface{}) (*Game_global, error) { + _dataList := make([]*Game_globalData, 0, len(_buf)) + dataMap := make(map[string]*Game_globalData) + for _, _ele_ := range _buf { + if _v, err2 := NewGame_globalData(_ele_); err2 != nil { + return nil, err2 + } else { + _dataList = append(_dataList, _v) + dataMap[_v.Index] = _v + } + } + return &Game_global{_dataList:_dataList, _dataMap:dataMap}, nil +} + +func (table *Game_global) GetDataMap() map[string]*Game_globalData { + return table._dataMap +} + +func (table *Game_global) GetDataList() []*Game_globalData { + return table._dataList +} + +func (table *Game_global) Get(key string) *Game_globalData { + return table._dataMap[key] +} + + diff --git a/sys/configure/structs/game.globalData.go b/sys/configure/structs/game.globalData.go new file mode 100644 index 000000000..0645b8bad --- /dev/null +++ b/sys/configure/structs/game.globalData.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_globalData struct { + Index string + Var string + Intr string +} + +func (Game_globalData) GetTypeId() int { + return -518904471 +} + +func NewGame_globalData(_buf map[string]interface{}) (_v *Game_globalData, err error) { + _v = &Game_globalData{} + { 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.heroData.go b/sys/configure/structs/game.heroData.go index c68fa15ad..e054bcb13 100644 --- a/sys/configure/structs/game.heroData.go +++ b/sys/configure/structs/game.heroData.go @@ -31,6 +31,7 @@ type Game_heroData struct { Skill1 int32 Skill2 int32 Skill3 int32 + Enteranivalue int32 } func (Game_heroData) GetTypeId() int { @@ -91,5 +92,6 @@ func NewGame_heroData(_buf map[string]interface{}) (_v *Game_heroData, err error { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["skill1"].(float64); !_ok_ { err = errors.New("skill1 error"); return }; _v.Skill1 = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["skill2"].(float64); !_ok_ { err = errors.New("skill2 error"); return }; _v.Skill2 = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["skill3"].(float64); !_ok_ { err = errors.New("skill3 error"); return }; _v.Skill3 = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["enteranivalue"].(float64); !_ok_ { err = errors.New("enteranivalue error"); return }; _v.Enteranivalue = int32(_tempNum_) } return } From 19a1ef270f8bce406df2d554098c2894d3f4a0a1 Mon Sep 17 00:00:00 2001 From: zhaocy Date: Wed, 29 Jun 2022 11:24:18 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E6=9B=B4=E6=94=B9pb=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/robot/robot.go | 2 +- modules/core.go | 4 +- modules/friend/model_friend.go | 4 +- modules/hero/api_chouka.go | 14 ++++ modules/hero/api_info.go | 2 + modules/hero/api_list.go | 2 + modules/hero/model_hero.go | 29 ++++--- modules/modulebase.go | 4 +- modules/user/api_create.go | 10 ++- modules/user/api_login.go | 2 +- modules/user/model_user.go | 10 +-- modules/web/api_comp.go | 2 +- pb/errorcode.pb.go | 74 +++++++++--------- pb/proto/errorcode.proto | 11 +-- pb/proto/user/user_db.proto | 4 +- pb/proto/user/user_msg.proto | 4 +- pb/user_db.pb.go | 133 ++++++++++++++++----------------- pb/user_msg.pb.go | 57 +++++++------- 18 files changed, 202 insertions(+), 166 deletions(-) create mode 100644 modules/hero/api_chouka.go diff --git a/cmd/robot/robot.go b/cmd/robot/robot.go index 9117b0384..8f6ca73ce 100644 --- a/cmd/robot/robot.go +++ b/cmd/robot/robot.go @@ -19,7 +19,7 @@ import ( type Robot struct { ws *websocket.Conn opts *Options - user *pb.DB_UserData + user *pb.DBUser builders []*builder } diff --git a/modules/core.go b/modules/core.go index 66ce4edab..4f1e11612 100644 --- a/modules/core.go +++ b/modules/core.go @@ -13,9 +13,9 @@ type ( IModule interface { core.IModule //向指定用户发送消息 - SendMsgToUser(mainType, subType string, msg proto.Message, user *pb.Cache_UserData) (err error) + SendMsgToUser(mainType, subType string, msg proto.Message, user *pb.CacheUser) (err error) //向多个用户发送消息 - SendMsgToUsers(mainType, subType string, msg proto.Message, user ...*pb.Cache_UserData) (err error) + SendMsgToUsers(mainType, subType string, msg proto.Message, user ...*pb.CacheUser) (err error) //校验消耗资源 CheckConsumeRes(uid string, res []*cfg.Game_atn) (code pb.ErrorCode) } diff --git a/modules/friend/model_friend.go b/modules/friend/model_friend.go index e9044472d..250648b24 100644 --- a/modules/friend/model_friend.go +++ b/modules/friend/model_friend.go @@ -24,8 +24,8 @@ func (this *ModelFriend) Init(service core.IService, module core.IModule, comp c return } -func (this *ModelFriend) Frined_FindCond(nickName string) *pb.DB_UserData { - var user *pb.DB_UserData +func (this *ModelFriend) Frined_FindCond(nickName string) *pb.DBUser { + var user *pb.DBUser err := this.DB.FindOne(TableUser, bson.M{ "name": nickName, }).Decode(&user) diff --git a/modules/hero/api_chouka.go b/modules/hero/api_chouka.go new file mode 100644 index 000000000..af895aab6 --- /dev/null +++ b/modules/hero/api_chouka.go @@ -0,0 +1,14 @@ +package hero + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" +) + +func (this *apiComp) ChoukaCheck() (result map[string]interface{}, code comm.ErrorCode) { + return +} + +func (this *apiComp) Chouka(session comm.IUserSession, result map[string]interface{}, req *pb.HeroInfoReq) { + +} diff --git a/modules/hero/api_info.go b/modules/hero/api_info.go index 23cb4e8a5..d8e7c16f3 100644 --- a/modules/hero/api_info.go +++ b/modules/hero/api_info.go @@ -3,6 +3,7 @@ package hero import ( "go_dreamfactory/comm" "go_dreamfactory/pb" + "go_dreamfactory/utils" ) //参数校验 @@ -24,6 +25,7 @@ func (this *apiComp) Info(session comm.IUserSession, result map[string]interface code = pb.ErrorCode_SystemError return } + utils.TraceFunc(session.GetUserId(), string(this.moduleHero.GetType()), HeroSubTypeList, req, rsp) }() if v, ok := result["hero"]; ok { diff --git a/modules/hero/api_list.go b/modules/hero/api_list.go index 67188aa93..048de9cb5 100644 --- a/modules/hero/api_list.go +++ b/modules/hero/api_list.go @@ -3,6 +3,7 @@ package hero import ( "go_dreamfactory/comm" "go_dreamfactory/pb" + "go_dreamfactory/utils" ) //参数校验 @@ -18,6 +19,7 @@ func (this *apiComp) List(session comm.IUserSession, result map[string]interface if err != nil { code = pb.ErrorCode_SystemError } + utils.TraceFunc(session.GetUserId(), string(this.moduleHero.GetType()), HeroSubTypeList, req, rsp) }() list, err := this.moduleHero.modelHero.getHeroList(session.GetUserId()) diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 47932713b..8dbfd4a72 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -53,28 +53,36 @@ func (this *ModelHero) initHero(uid string, heroCfgId int32) *pb.DBHero { //创建一个指定的英雄 func (this *ModelHero) createOneHero(uid string, heroCfgId int32) error { - hero := this.initHero(uid, heroCfgId) - if hero != nil { - return this.moduleHero.modelHero.AddList(uid, hero.Id, hero) + heroes, err := this.getHeroList(uid) + if err != nil { + log.Errorf("%v", err) + return err + } + for _, v := range heroes { + if v.HeroID == heroCfgId { + v.SameCount++ + data := map[string]interface{}{ + "sameCount": v.SameCount, //叠加数 + } + return this.moduleHero.modelHero.Change(uid, data) + } else { + hero := this.initHero(uid, heroCfgId) + if hero != nil { + return this.moduleHero.modelHero.AddList(uid, hero.Id, hero) + } + } } return nil } //创建多个指定的英雄 heroCfgIds可填入多个英雄ID func (this *ModelHero) createMultiHero(uid string, heroCfgIds ...int32) error { - // data := make(map[string]interface{}) for _, v := range heroCfgIds { if err := this.createOneHero(uid, v); err != nil { return err } - // hero := this.initHero(uid, v) - // if hero != nil { - // data[hero.Id] = hero - // } } - return nil - // return this.moduleHero.model_hero.AddLists(uid, data) } //获取一个英雄 @@ -104,7 +112,6 @@ func (this *ModelHero) getHeroList(uid string) ([]*pb.DBHero, error) { if err != nil { return nil, err } - return heroes, nil } diff --git a/modules/modulebase.go b/modules/modulebase.go index 573d36081..7662c0e43 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -34,7 +34,7 @@ func (this *ModuleBase) Init(service core.IService, module core.IModule, options } //向指定用户发送消息 -func (this *ModuleBase) SendMsgToUser(mainType, subType string, msg proto.Message, user *pb.Cache_UserData) (err error) { +func (this *ModuleBase) SendMsgToUser(mainType, subType string, msg proto.Message, user *pb.CacheUser) (err error) { reply := &pb.RPCMessageReply{} data, _ := ptypes.MarshalAny(msg) if _, err = this.service.RpcGo(context.Background(), fmt.Sprintf("%s/%s", comm.Service_Gateway, user.GatewayServiceId), string(comm.Rpc_GatewayAgentSendMsg), &pb.AgentSendMessageReq{ @@ -49,7 +49,7 @@ func (this *ModuleBase) SendMsgToUser(mainType, subType string, msg proto.Messag } //向多个用户发送消息 -func (this *ModuleBase) SendMsgToUsers(mainType, subType string, msg proto.Message, user ...*pb.Cache_UserData) (err error) { +func (this *ModuleBase) SendMsgToUsers(mainType, subType string, msg proto.Message, user ...*pb.CacheUser) (err error) { var ( gateways map[string][]string = make(map[string][]string) gateway []string diff --git a/modules/user/api_create.go b/modules/user/api_create.go index a7715c854..73ab8f5b8 100644 --- a/modules/user/api_create.go +++ b/modules/user/api_create.go @@ -8,7 +8,7 @@ import ( func (this *apiComp) CreateCheck(session comm.IUserSession, req *pb.UserCreateReq) (result map[string]interface{}, code comm.ErrorCode) { result = make(map[string]interface{}) - self := &pb.DB_UserData{} + self := &pb.DBUser{} err := this.module.modelUser.Get(session.GetUserId(), self) if err != nil { code = comm.ErrorCode{Code: pb.ErrorCode_DBError} @@ -29,6 +29,14 @@ func (this *apiComp) Create(session comm.IUserSession, result map[string]interfa } }() + if self, ok := result["self"]; ok { + v := self.(*pb.DBUser) + if v.Name != "" { + code = pb.ErrorCode_RoleCreated + return + } + } + update := map[string]interface{}{ "name": req.NickName, } diff --git a/modules/user/api_login.go b/modules/user/api_login.go index 04f04a81e..fe0055b9f 100644 --- a/modules/user/api_login.go +++ b/modules/user/api_login.go @@ -21,7 +21,7 @@ func (this *apiComp) LoginCheck(session comm.IUserSession, req *pb.UserLoginReq) func (this *apiComp) Login(session comm.IUserSession, result map[string]interface{}, req *pb.UserLoginReq) (code pb.ErrorCode) { var ( err error - user *pb.DB_UserData + user *pb.DBUser ) defer func() { diff --git a/modules/user/model_user.go b/modules/user/model_user.go index 87969a2cc..4bcf6f68f 100644 --- a/modules/user/model_user.go +++ b/modules/user/model_user.go @@ -27,18 +27,18 @@ func (this *ModelUser) Init(service core.IService, module core.IModule, comp cor return } -func (this *ModelUser) User_FindByAccount(sid int32, account string) (*pb.DB_UserData, error) { +func (this *ModelUser) User_FindByAccount(sid int32, account string) (*pb.DBUser, error) { filter := bson.M{ "sid": sid, "binduid": account, } sr := this.DB.FindOne(TableUser, filter) - var nd *pb.DB_UserData + var nd *pb.DBUser err := sr.Decode(&nd) return nd, err } -func (this *ModelUser) User_Create(user *pb.DB_UserData) (err error) { +func (this *ModelUser) User_Create(user *pb.DBUser) (err error) { _id := primitive.NewObjectID().Hex() user.Id = _id user.Uid = fmt.Sprintf("%d_%s", user.Sid, _id) @@ -49,8 +49,8 @@ func (this *ModelUser) User_Create(user *pb.DB_UserData) (err error) { } //获取用户 -func (this *ModelUser) getUser(uid string) *pb.DB_UserData { - dbUser := &pb.DB_UserData{} +func (this *ModelUser) getUser(uid string) *pb.DBUser { + dbUser := &pb.DBUser{} if err := this.Get(uid, dbUser); err != nil { log.Errorf("getUser err:%v", err) return nil diff --git a/modules/web/api_comp.go b/modules/web/api_comp.go index c0dd8d6f0..f208480fe 100644 --- a/modules/web/api_comp.go +++ b/modules/web/api_comp.go @@ -37,7 +37,7 @@ func (this *Api_Comp) Register(c *engine.Context) { rsp := &pb.UserRegisterRsp{} err := c.BindJSON(&req) if err == nil { - err := this.module.modelUser.User_Create(&pb.DB_UserData{ + err := this.module.modelUser.User_Create(&pb.DBUser{ Binduid: req.Account, Sid: req.Sid, }) diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index 4281af514..bdbcb25c6 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -48,6 +48,7 @@ const ( ErrorCode_BindUser ErrorCode = 1002 //用户绑定错误 ErrorCode_GoldNoEnough ErrorCode = 1003 // 金币不足 ErrorCode_DiamondNoEnough ErrorCode = 1004 // 钻石不足 + ErrorCode_RoleCreated ErrorCode = 1005 //已创角 // friend ErrorCode_FriendNotSelf ErrorCode = 1100 //不能是自己 ErrorCode_FriendSelfMax ErrorCode = 1101 //超出好友最大数量 @@ -104,6 +105,7 @@ var ( 1002: "BindUser", 1003: "GoldNoEnough", 1004: "DiamondNoEnough", + 1005: "RoleCreated", 1100: "FriendNotSelf", 1101: "FriendSelfMax", 1102: "FriendTargetMax", @@ -153,6 +155,7 @@ var ( "BindUser": 1002, "GoldNoEnough": 1003, "DiamondNoEnough": 1004, + "RoleCreated": 1005, "FriendNotSelf": 1100, "FriendSelfMax": 1101, "FriendTargetMax": 1102, @@ -210,7 +213,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, 0xe2, 0x07, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0xf4, 0x07, 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, @@ -240,40 +243,41 @@ var file_errorcode_proto_rawDesc = []byte{ 0x73, 0x65, 0x72, 0x10, 0xea, 0x07, 0x12, 0x11, 0x0a, 0x0c, 0x47, 0x6f, 0x6c, 0x64, 0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xeb, 0x07, 0x12, 0x14, 0x0a, 0x0f, 0x44, 0x69, 0x61, 0x6d, 0x6f, 0x6e, 0x64, 0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xec, 0x07, 0x12, - 0x12, 0x0a, 0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x4e, 0x6f, 0x74, 0x53, 0x65, 0x6c, 0x66, - 0x10, 0xcc, 0x08, 0x12, 0x12, 0x0a, 0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, - 0x66, 0x4d, 0x61, 0x78, 0x10, 0xcd, 0x08, 0x12, 0x14, 0x0a, 0x0f, 0x46, 0x72, 0x69, 0x65, 0x6e, - 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4d, 0x61, 0x78, 0x10, 0xce, 0x08, 0x12, 0x15, 0x0a, - 0x10, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x4e, 0x6f, 0x44, 0x61, 0x74, - 0x61, 0x10, 0xcf, 0x08, 0x12, 0x17, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x61, - 0x72, 0x67, 0x65, 0x74, 0x4e, 0x6f, 0x44, 0x61, 0x74, 0x61, 0x10, 0xd0, 0x08, 0x12, 0x0e, 0x0a, - 0x09, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x59, 0x65, 0x74, 0x10, 0xd1, 0x08, 0x12, 0x13, 0x0a, - 0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x59, 0x65, 0x74, 0x10, - 0xd2, 0x08, 0x12, 0x17, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, - 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x59, 0x65, 0x74, 0x10, 0xd3, 0x08, 0x12, 0x19, 0x0a, 0x14, 0x46, - 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x61, 0x63, 0x6b, - 0x59, 0x65, 0x74, 0x10, 0xd4, 0x08, 0x12, 0x15, 0x0a, 0x10, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, - 0x41, 0x70, 0x70, 0x6c, 0x79, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0xd5, 0x08, 0x12, 0x13, 0x0a, - 0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4d, 0x61, 0x78, 0x10, - 0xd6, 0x08, 0x12, 0x1a, 0x0a, 0x15, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x61, 0x72, - 0x63, 0x68, 0x4e, 0x61, 0x6d, 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x10, 0xd7, 0x08, 0x12, 0x12, - 0x0a, 0x0d, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, - 0xb0, 0x09, 0x12, 0x15, 0x0a, 0x10, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x4e, 0x6f, 0x46, 0x6f, 0x75, - 0x6e, 0x64, 0x47, 0x69, 0x72, 0x64, 0x10, 0xb1, 0x09, 0x12, 0x16, 0x0a, 0x11, 0x49, 0x74, 0x65, - 0x6d, 0x73, 0x47, 0x72, 0x69, 0x64, 0x4e, 0x75, 0x6d, 0x55, 0x70, 0x70, 0x65, 0x72, 0x10, 0xb2, - 0x09, 0x12, 0x19, 0x0a, 0x14, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x47, 0x69, 0x72, 0x64, 0x41, 0x6d, - 0x6f, 0x75, 0x6e, 0x74, 0x55, 0x70, 0x70, 0x65, 0x72, 0x10, 0xb3, 0x09, 0x12, 0x10, 0x0a, 0x0b, - 0x48, 0x65, 0x72, 0x6f, 0x4e, 0x6f, 0x45, 0x78, 0x69, 0x73, 0x74, 0x10, 0x94, 0x0a, 0x12, 0x11, - 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0x95, - 0x0a, 0x12, 0x0e, 0x0a, 0x09, 0x48, 0x65, 0x72, 0x6f, 0x4d, 0x61, 0x78, 0x4c, 0x76, 0x10, 0x96, - 0x0a, 0x12, 0x12, 0x0a, 0x0d, 0x48, 0x65, 0x72, 0x6f, 0x49, 0x6e, 0x69, 0x74, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x10, 0x97, 0x0a, 0x12, 0x11, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x6f, 0x6c, - 0x6f, 0x72, 0x45, 0x72, 0x72, 0x10, 0x98, 0x0a, 0x12, 0x1e, 0x0a, 0x19, 0x45, 0x71, 0x75, 0x69, - 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4f, 0x6e, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x45, 0x71, 0x75, 0x69, - 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0xf8, 0x0a, 0x12, 0x1c, 0x0a, 0x17, 0x45, 0x71, 0x75, 0x69, - 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x76, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x61, 0x63, - 0x68, 0x65, 0x64, 0x10, 0xf9, 0x0a, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x10, 0x0a, 0x0b, 0x52, 0x6f, 0x6c, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x10, 0xed, + 0x07, 0x12, 0x12, 0x0a, 0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x4e, 0x6f, 0x74, 0x53, 0x65, + 0x6c, 0x66, 0x10, 0xcc, 0x08, 0x12, 0x12, 0x0a, 0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, + 0x65, 0x6c, 0x66, 0x4d, 0x61, 0x78, 0x10, 0xcd, 0x08, 0x12, 0x14, 0x0a, 0x0f, 0x46, 0x72, 0x69, + 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4d, 0x61, 0x78, 0x10, 0xce, 0x08, 0x12, + 0x15, 0x0a, 0x10, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x4e, 0x6f, 0x44, + 0x61, 0x74, 0x61, 0x10, 0xcf, 0x08, 0x12, 0x17, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, + 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4e, 0x6f, 0x44, 0x61, 0x74, 0x61, 0x10, 0xd0, 0x08, 0x12, + 0x0e, 0x0a, 0x09, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x59, 0x65, 0x74, 0x10, 0xd1, 0x08, 0x12, + 0x13, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x59, 0x65, + 0x74, 0x10, 0xd2, 0x08, 0x12, 0x17, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, + 0x6c, 0x66, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x59, 0x65, 0x74, 0x10, 0xd3, 0x08, 0x12, 0x19, 0x0a, + 0x14, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x61, + 0x63, 0x6b, 0x59, 0x65, 0x74, 0x10, 0xd4, 0x08, 0x12, 0x15, 0x0a, 0x10, 0x46, 0x72, 0x69, 0x65, + 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0xd5, 0x08, 0x12, + 0x13, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4d, 0x61, + 0x78, 0x10, 0xd6, 0x08, 0x12, 0x1a, 0x0a, 0x15, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, + 0x61, 0x72, 0x63, 0x68, 0x4e, 0x61, 0x6d, 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x10, 0xd7, 0x08, + 0x12, 0x12, 0x0a, 0x0d, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, + 0x68, 0x10, 0xb0, 0x09, 0x12, 0x15, 0x0a, 0x10, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x4e, 0x6f, 0x46, + 0x6f, 0x75, 0x6e, 0x64, 0x47, 0x69, 0x72, 0x64, 0x10, 0xb1, 0x09, 0x12, 0x16, 0x0a, 0x11, 0x49, + 0x74, 0x65, 0x6d, 0x73, 0x47, 0x72, 0x69, 0x64, 0x4e, 0x75, 0x6d, 0x55, 0x70, 0x70, 0x65, 0x72, + 0x10, 0xb2, 0x09, 0x12, 0x19, 0x0a, 0x14, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x47, 0x69, 0x72, 0x64, + 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x55, 0x70, 0x70, 0x65, 0x72, 0x10, 0xb3, 0x09, 0x12, 0x10, + 0x0a, 0x0b, 0x48, 0x65, 0x72, 0x6f, 0x4e, 0x6f, 0x45, 0x78, 0x69, 0x73, 0x74, 0x10, 0x94, 0x0a, + 0x12, 0x11, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, + 0x10, 0x95, 0x0a, 0x12, 0x0e, 0x0a, 0x09, 0x48, 0x65, 0x72, 0x6f, 0x4d, 0x61, 0x78, 0x4c, 0x76, + 0x10, 0x96, 0x0a, 0x12, 0x12, 0x0a, 0x0d, 0x48, 0x65, 0x72, 0x6f, 0x49, 0x6e, 0x69, 0x74, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x10, 0x97, 0x0a, 0x12, 0x11, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x43, + 0x6f, 0x6c, 0x6f, 0x72, 0x45, 0x72, 0x72, 0x10, 0x98, 0x0a, 0x12, 0x1e, 0x0a, 0x19, 0x45, 0x71, + 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4f, 0x6e, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x45, 0x71, + 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0xf8, 0x0a, 0x12, 0x1c, 0x0a, 0x17, 0x45, 0x71, + 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x76, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x52, 0x65, + 0x61, 0x63, 0x68, 0x65, 0x64, 0x10, 0xf9, 0x0a, 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 0235c74f8..f7311c410 100644 --- a/pb/proto/errorcode.proto +++ b/pb/proto/errorcode.proto @@ -23,11 +23,12 @@ enum ErrorCode { ConfigNoFound = 104; //配置未找到 // user - SecKeyInvalid = 1000; //秘钥无效 - SecKey = 1001; //秘钥格式错误 - BindUser = 1002; //用户绑定错误 - GoldNoEnough = 1003; // 金币不足 + SecKeyInvalid = 1000; //秘钥无效 + SecKey = 1001; //秘钥格式错误 + BindUser = 1002; //用户绑定错误 + GoldNoEnough = 1003; // 金币不足 DiamondNoEnough = 1004; // 钻石不足 + RoleCreated = 1005; //已创角 // friend FriendNotSelf = 1100; //不能是自己 @@ -54,7 +55,7 @@ enum ErrorCode { HeroNoEnough = 1301; //英雄数量不足 HeroMaxLv = 1302; //英雄达到最大等级 HeroInitCreat = 1303; //初始化英雄 - HeroColorErr = 1304; // 品质不匹配 + HeroColorErr = 1304; // 品质不匹配 // equipment EquipmentOnFoundEquipment = 1400; // 未找到武器 EquipmentLvlimitReached = 1401; // 武器等级已达上限 diff --git a/pb/proto/user/user_db.proto b/pb/proto/user/user_db.proto index d43502004..9833e2cb9 100644 --- a/pb/proto/user/user_db.proto +++ b/pb/proto/user/user_db.proto @@ -1,14 +1,14 @@ syntax = "proto3"; option go_package = ".;pb"; -message Cache_UserData { +message CacheUser { string uid = 1; string SessionId = 2; string GatewayServiceId = 3; // DB_UserData UserData = 4; //@go_tags(`json:",inline"`) } -message DB_UserData { +message DBUser { string id = 1; //@go_tags(`bson:"_id"`) ID string uid = 2; //@go_tags(`bson:"uid"`) 用户ID string uuid = 3; //@go_tags(`bson:"uuid"`) 玩家唯一uuid diff --git a/pb/proto/user/user_msg.proto b/pb/proto/user/user_msg.proto index 8dd77e48e..3f57901d9 100644 --- a/pb/proto/user/user_msg.proto +++ b/pb/proto/user/user_msg.proto @@ -9,7 +9,7 @@ message UserLoginReq { int32 sid = 2; //区服编号 } -message UserLoginResp { DB_UserData data = 1; } +message UserLoginResp { DBUser data = 1; } message UserRegisterReq { string account = 1; @@ -21,7 +21,7 @@ message UserRegisterRsp { string account = 2; } -message UserLoadRsp { Cache_UserData data = 1; } +message UserLoadRsp { CacheUser data = 1; } //创角 message UserCreateReq { diff --git a/pb/user_db.pb.go b/pb/user_db.pb.go index 9ce4a4872..f3214d987 100644 --- a/pb/user_db.pb.go +++ b/pb/user_db.pb.go @@ -20,7 +20,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type Cache_UserData struct { +type CacheUser struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -30,8 +30,8 @@ type Cache_UserData struct { GatewayServiceId string `protobuf:"bytes,3,opt,name=GatewayServiceId,proto3" json:",inline"` // DB_UserData UserData = 4; // } -func (x *Cache_UserData) Reset() { - *x = Cache_UserData{} +func (x *CacheUser) Reset() { + *x = CacheUser{} if protoimpl.UnsafeEnabled { mi := &file_user_user_db_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -39,13 +39,13 @@ func (x *Cache_UserData) Reset() { } } -func (x *Cache_UserData) String() string { +func (x *CacheUser) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Cache_UserData) ProtoMessage() {} +func (*CacheUser) ProtoMessage() {} -func (x *Cache_UserData) ProtoReflect() protoreflect.Message { +func (x *CacheUser) ProtoReflect() protoreflect.Message { mi := &file_user_user_db_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -57,33 +57,33 @@ func (x *Cache_UserData) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Cache_UserData.ProtoReflect.Descriptor instead. -func (*Cache_UserData) Descriptor() ([]byte, []int) { +// Deprecated: Use CacheUser.ProtoReflect.Descriptor instead. +func (*CacheUser) Descriptor() ([]byte, []int) { return file_user_user_db_proto_rawDescGZIP(), []int{0} } -func (x *Cache_UserData) GetUid() string { +func (x *CacheUser) GetUid() string { if x != nil { return x.Uid } return "" } -func (x *Cache_UserData) GetSessionId() string { +func (x *CacheUser) GetSessionId() string { if x != nil { return x.SessionId } return "" } -func (x *Cache_UserData) GetGatewayServiceId() string { +func (x *CacheUser) GetGatewayServiceId() string { if x != nil { return x.GatewayServiceId } return "" } -type DB_UserData struct { +type DBUser struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -104,8 +104,8 @@ type DB_UserData struct { Exp int32 `protobuf:"varint,14,opt,name=exp,proto3" json:"exp" bson:"exp"` //经验 } -func (x *DB_UserData) Reset() { - *x = DB_UserData{} +func (x *DBUser) Reset() { + *x = DBUser{} if protoimpl.UnsafeEnabled { mi := &file_user_user_db_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -113,13 +113,13 @@ func (x *DB_UserData) Reset() { } } -func (x *DB_UserData) String() string { +func (x *DBUser) String() string { return protoimpl.X.MessageStringOf(x) } -func (*DB_UserData) ProtoMessage() {} +func (*DBUser) ProtoMessage() {} -func (x *DB_UserData) ProtoReflect() protoreflect.Message { +func (x *DBUser) ProtoReflect() protoreflect.Message { mi := &file_user_user_db_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -131,103 +131,103 @@ func (x *DB_UserData) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use DB_UserData.ProtoReflect.Descriptor instead. -func (*DB_UserData) Descriptor() ([]byte, []int) { +// Deprecated: Use DBUser.ProtoReflect.Descriptor instead. +func (*DBUser) Descriptor() ([]byte, []int) { return file_user_user_db_proto_rawDescGZIP(), []int{1} } -func (x *DB_UserData) GetId() string { +func (x *DBUser) GetId() string { if x != nil { return x.Id } return "" } -func (x *DB_UserData) GetUid() string { +func (x *DBUser) GetUid() string { if x != nil { return x.Uid } return "" } -func (x *DB_UserData) GetUuid() string { +func (x *DBUser) GetUuid() string { if x != nil { return x.Uuid } return "" } -func (x *DB_UserData) GetBinduid() string { +func (x *DBUser) GetBinduid() string { if x != nil { return x.Binduid } return "" } -func (x *DB_UserData) GetName() string { +func (x *DBUser) GetName() string { if x != nil { return x.Name } return "" } -func (x *DB_UserData) GetSid() int32 { +func (x *DBUser) GetSid() int32 { if x != nil { return x.Sid } return 0 } -func (x *DB_UserData) GetCreateip() string { +func (x *DBUser) GetCreateip() string { if x != nil { return x.Createip } return "" } -func (x *DB_UserData) GetLastloginip() string { +func (x *DBUser) GetLastloginip() string { if x != nil { return x.Lastloginip } return "" } -func (x *DB_UserData) GetCtime() int64 { +func (x *DBUser) GetCtime() int64 { if x != nil { return x.Ctime } return 0 } -func (x *DB_UserData) GetLogintime() int64 { +func (x *DBUser) GetLogintime() int64 { if x != nil { return x.Logintime } return 0 } -func (x *DB_UserData) GetFriendPoint() int32 { +func (x *DBUser) GetFriendPoint() int32 { if x != nil { return x.FriendPoint } return 0 } -func (x *DB_UserData) GetAvatar() int32 { +func (x *DBUser) GetAvatar() int32 { if x != nil { return x.Avatar } return 0 } -func (x *DB_UserData) GetGold() int32 { +func (x *DBUser) GetGold() int32 { if x != nil { return x.Gold } return 0 } -func (x *DB_UserData) GetExp() int32 { +func (x *DBUser) GetExp() int32 { if x != nil { return x.Exp } @@ -238,36 +238,35 @@ var File_user_user_db_proto protoreflect.FileDescriptor var file_user_user_db_proto_rawDesc = []byte{ 0x0a, 0x12, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x64, 0x62, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6c, 0x0a, 0x0e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, - 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x53, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x49, 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, 0x22, 0xd5, 0x02, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, - 0x74, 0x61, 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, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x69, 0x6e, 0x64, - 0x75, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x69, 0x6e, 0x64, 0x75, - 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x03, 0x73, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x69, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x69, 0x70, 0x12, 0x20, 0x0a, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x6c, 0x6f, 0x67, 0x69, - 0x6e, 0x69, 0x70, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x6c, - 0x6f, 0x67, 0x69, 0x6e, 0x69, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, - 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, - 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x09, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x66, 0x72, - 0x69, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x0b, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, - 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x61, 0x76, - 0x61, 0x74, 0x61, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x67, 0x6f, 0x6c, 0x64, 0x18, 0x0d, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x04, 0x67, 0x6f, 0x6c, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x78, 0x70, 0x18, - 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x65, 0x78, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x67, 0x0a, 0x09, 0x43, 0x61, 0x63, 0x68, 0x65, 0x55, 0x73, 0x65, + 0x72, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x75, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, + 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, 0x22, 0xd0, 0x02, + 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, + 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, + 0x0a, 0x07, 0x62, 0x69, 0x6e, 0x64, 0x75, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x62, 0x69, 0x6e, 0x64, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, + 0x73, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x73, 0x69, 0x64, 0x12, 0x1a, + 0x0a, 0x08, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x69, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x69, 0x70, 0x12, 0x20, 0x0a, 0x0b, 0x6c, 0x61, + 0x73, 0x74, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x69, 0x70, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x69, 0x70, 0x12, 0x14, 0x0a, 0x05, + 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, + 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x18, + 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x74, 0x69, 0x6d, 0x65, + 0x12, 0x20, 0x0a, 0x0b, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x18, + 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, + 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x0c, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x67, 0x6f, + 0x6c, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x67, 0x6f, 0x6c, 0x64, 0x12, 0x10, + 0x0a, 0x03, 0x65, 0x78, 0x70, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x65, 0x78, 0x70, + 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -284,8 +283,8 @@ func file_user_user_db_proto_rawDescGZIP() []byte { var file_user_user_db_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_user_user_db_proto_goTypes = []interface{}{ - (*Cache_UserData)(nil), // 0: Cache_UserData - (*DB_UserData)(nil), // 1: DB_UserData + (*CacheUser)(nil), // 0: CacheUser + (*DBUser)(nil), // 1: DBUser } var file_user_user_db_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type @@ -302,7 +301,7 @@ func file_user_user_db_proto_init() { } if !protoimpl.UnsafeEnabled { file_user_user_db_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Cache_UserData); i { + switch v := v.(*CacheUser); i { case 0: return &v.state case 1: @@ -314,7 +313,7 @@ func file_user_user_db_proto_init() { } } file_user_user_db_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DB_UserData); i { + switch v := v.(*DBUser); i { case 0: return &v.state case 1: diff --git a/pb/user_msg.pb.go b/pb/user_msg.pb.go index fc7c1fde3..8462c6ff1 100644 --- a/pb/user_msg.pb.go +++ b/pb/user_msg.pb.go @@ -81,7 +81,7 @@ type UserLoginResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Data *DB_UserData `protobuf:"bytes,1,opt,name=data,proto3" json:"data"` + Data *DBUser `protobuf:"bytes,1,opt,name=data,proto3" json:"data"` } func (x *UserLoginResp) Reset() { @@ -116,7 +116,7 @@ func (*UserLoginResp) Descriptor() ([]byte, []int) { return file_user_user_msg_proto_rawDescGZIP(), []int{1} } -func (x *UserLoginResp) GetData() *DB_UserData { +func (x *UserLoginResp) GetData() *DBUser { if x != nil { return x.Data } @@ -238,7 +238,7 @@ type UserLoadRsp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Data *Cache_UserData `protobuf:"bytes,1,opt,name=data,proto3" json:"data"` + Data *CacheUser `protobuf:"bytes,1,opt,name=data,proto3" json:"data"` } func (x *UserLoadRsp) Reset() { @@ -273,7 +273,7 @@ func (*UserLoadRsp) Descriptor() ([]byte, []int) { return file_user_user_msg_proto_rawDescGZIP(), []int{4} } -func (x *UserLoadRsp) GetData() *Cache_UserData { +func (x *UserLoadRsp) GetData() *CacheUser { if x != nil { return x.Data } @@ -376,27 +376,26 @@ var file_user_user_msg_proto_rawDesc = []byte{ 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, 0x31, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, - 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x20, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, - 0x61, 0x74, 0x61, 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, 0x4b, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 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, 0x32, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x61, - 0x64, 0x52, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, - 0x61, 0x74, 0x61, 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, 0x0f, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x52, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 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, 0x4b, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x65, 0x72, 0x52, 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, 0x2d, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x61, 0x64, 0x52, 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, 0x0f, 0x0a, 0x0d, + 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x73, 0x70, 0x42, 0x06, 0x5a, + 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -420,14 +419,14 @@ var file_user_user_msg_proto_goTypes = []interface{}{ (*UserLoadRsp)(nil), // 4: UserLoadRsp (*UserCreateReq)(nil), // 5: UserCreateReq (*UserCreateRsp)(nil), // 6: UserCreateRsp - (*DB_UserData)(nil), // 7: DB_UserData + (*DBUser)(nil), // 7: DBUser (ErrorCode)(0), // 8: ErrorCode - (*Cache_UserData)(nil), // 9: Cache_UserData + (*CacheUser)(nil), // 9: CacheUser } var file_user_user_msg_proto_depIdxs = []int32{ - 7, // 0: UserLoginResp.data:type_name -> DB_UserData + 7, // 0: UserLoginResp.data:type_name -> DBUser 8, // 1: UserRegisterRsp.Code:type_name -> ErrorCode - 9, // 2: UserLoadRsp.data:type_name -> Cache_UserData + 9, // 2: UserLoadRsp.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 From f463f686abc00401634fdd997ed21cbce73f7da3 Mon Sep 17 00:00:00 2001 From: wnp Date: Wed, 29 Jun 2022 13:49:55 +0800 Subject: [PATCH 3/9] =?UTF-8?q?gateway.module=E5=91=BD=E5=90=8D=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/gateway/module.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/gateway/module.go b/modules/gateway/module.go index 64b645319..783c3f282 100644 --- a/modules/gateway/module.go +++ b/modules/gateway/module.go @@ -22,8 +22,8 @@ func NewModule() core.IModule { type Gateway struct { modules.ModuleBase service base.IRPCXService - wsservice *WSServiceComp //websocket 服务组件 提供websocket服务监听 - agentmgr *AgentMgrComp //用户代理对象管理组件 管理用户socekt对象 + wsService *WSServiceComp //websocket 服务组件 提供websocket服务监听 + agentMgr *AgentMgrComp //用户代理对象管理组件 管理用户socekt对象 configure *configureComp } @@ -52,17 +52,17 @@ func (this *Gateway) Init(service core.IService, module core.IModule, options co //模块启动函数 注册rpc服务接口提供用户相关的rpc接口服务 func (this *Gateway) Start() (err error) { //注册用户绑定uid接口 登录成功后触发 - this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentBind), this.agentmgr.Bind) + this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentBind), this.agentMgr.Bind) //注册用户解绑uid接口 登出或则切换账号是触发 - this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentUnBind), this.agentmgr.UnBind) + this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentUnBind), this.agentMgr.UnBind) //向用户发送消息接口 - this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentSendMsg), this.agentmgr.SendMsgToAgent) + this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentSendMsg), this.agentMgr.SendMsgToAgent) //向多个用户对象发送消息接口 - this.service.RegisterFunctionName(string(comm.Rpc_GatewaySendBatchMsg), this.agentmgr.SendMsgToAgents) + this.service.RegisterFunctionName(string(comm.Rpc_GatewaySendBatchMsg), this.agentMgr.SendMsgToAgents) //向所有用户发送消息接口 - this.service.RegisterFunctionName(string(comm.Rpc_GatewaySendRadioMsg), this.agentmgr.SendMsgToAllAgent) + this.service.RegisterFunctionName(string(comm.Rpc_GatewaySendRadioMsg), this.agentMgr.SendMsgToAllAgent) //关闭用户socket连接接口 - this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentClose), this.agentmgr.CloseAgent) + this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentClose), this.agentMgr.CloseAgent) err = this.ModuleBase.Start() return } @@ -70,21 +70,21 @@ func (this *Gateway) Start() (err error) { //装备组件 func (this *Gateway) OnInstallComp() { this.ModuleBase.OnInstallComp() - this.agentmgr = this.RegisterComp(new(AgentMgrComp)).(*AgentMgrComp) - this.wsservice = this.RegisterComp(new(WSServiceComp)).(*WSServiceComp) + this.agentMgr = this.RegisterComp(new(AgentMgrComp)).(*AgentMgrComp) + this.wsService = this.RegisterComp(new(WSServiceComp)).(*WSServiceComp) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } //有新的连接对象进入 func (this *Gateway) Connect(a IAgent) { log.Debugf("[Module.Gateway] have new connect:Ip[%s] SessionId:[%s]", a.IP(), a.SessionId()) - this.agentmgr.Connect(a) + this.agentMgr.Connect(a) } //有用户断开连接 func (this *Gateway) DisConnect(a IAgent) { log.Debugf("[Module.Gateway] have disConnect:Ip[%s] SessionId:[%s] uid:[%s]", a.IP(), a.SessionId(), a.UserId()) - this.agentmgr.DisConnect(a) + this.agentMgr.DisConnect(a) } //读取消息分发规则 From 9558e7c4ffcab6698240a4080b20b44fa491319e Mon Sep 17 00:00:00 2001 From: wnp Date: Wed, 29 Jun 2022 14:40:59 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E6=8E=A8=E9=80=81=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/gateway/module.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gateway/module.go b/modules/gateway/module.go index 783c3f282..ab704185e 100644 --- a/modules/gateway/module.go +++ b/modules/gateway/module.go @@ -23,7 +23,7 @@ type Gateway struct { modules.ModuleBase service base.IRPCXService wsService *WSServiceComp //websocket 服务组件 提供websocket服务监听 - agentMgr *AgentMgrComp //用户代理对象管理组件 管理用户socekt对象 + agentMgr *AgentMgrComp //用户代理对象管理组件 管理用户socket对象 configure *configureComp } From e6f13429bfb53eddfb2e8ae1439cc3a20cd41ebf Mon Sep 17 00:00:00 2001 From: wnp Date: Wed, 29 Jun 2022 15:36:15 +0800 Subject: [PATCH 5/9] =?UTF-8?q?gateway.modules=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=B3=A8=E9=87=8A+=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/gateway/agent.go | 2 +- modules/gateway/agentmgr_comp.go | 1 + modules/gateway/configure_comp.go | 2 +- modules/gateway/core.go | 2 +- modules/gateway/module.go | 59 +++++++++++++++++-------------- 5 files changed, 37 insertions(+), 29 deletions(-) diff --git a/modules/gateway/agent.go b/modules/gateway/agent.go index 4aadb1872..f4106296c 100644 --- a/modules/gateway/agent.go +++ b/modules/gateway/agent.go @@ -212,7 +212,7 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) { reply := &pb.RPCMessageReply{} log.Debugf("agent:%s uId:%s MessageDistribution msg:%s.%s", this.sessionId, this.uId, msg.MainType, msg.SubType) servicePath := comm.Service_Worker - if rule, ok := this.gateway.GetMsgDistribRule(msg.MainType, msg.SubType); ok { + if rule, ok := this.gateway.GetMsgDistribute(msg.MainType, msg.SubType); ok { servicePath = rule } else { if len(this.wId) > 0 { diff --git a/modules/gateway/agentmgr_comp.go b/modules/gateway/agentmgr_comp.go index c21b3002a..1bc209aaf 100644 --- a/modules/gateway/agentmgr_comp.go +++ b/modules/gateway/agentmgr_comp.go @@ -16,6 +16,7 @@ import ( /* 用户代理对象管理组件 */ + type AgentMgrComp struct { cbase.ModuleCompBase service base.IRPCXService diff --git a/modules/gateway/configure_comp.go b/modules/gateway/configure_comp.go index 0afe78a87..8b155e9bc 100644 --- a/modules/gateway/configure_comp.go +++ b/modules/gateway/configure_comp.go @@ -24,7 +24,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp } //获取消息分发规则读取配置表 -func (this *configureComp) GetMsgDistribRule(mtype, stype string) (rule string, ok bool) { +func (this *configureComp) GetMsgDistribute(mtype, stype string) (rule string, ok bool) { var ( err error v interface{} diff --git a/modules/gateway/core.go b/modules/gateway/core.go index 217c8a797..7159211ea 100644 --- a/modules/gateway/core.go +++ b/modules/gateway/core.go @@ -25,6 +25,6 @@ type ( Service() base.IRPCXService Connect(a IAgent) DisConnect(a IAgent) - GetMsgDistribRule(mtype, stype string) (rule string, ok bool) + GetMsgDistribute(mtype, stype string) (rule string, ok bool) } ) diff --git a/modules/gateway/module.go b/modules/gateway/module.go index ab704185e..722c80585 100644 --- a/modules/gateway/module.go +++ b/modules/gateway/module.go @@ -14,6 +14,7 @@ import ( 描述:提供客户端网关路由服务 管理用户socket对象 以及分发用户消息 开发:李伟 */ + func NewModule() core.IModule { m := new(Gateway) return m @@ -21,53 +22,59 @@ func NewModule() core.IModule { type Gateway struct { modules.ModuleBase - service base.IRPCXService - wsService *WSServiceComp //websocket 服务组件 提供websocket服务监听 - agentMgr *AgentMgrComp //用户代理对象管理组件 管理用户socket对象 + service base.IRPCXService // rpcx服务接口 主要client->server + wsService *WSServiceComp // websocket服务 监听websocket连接 + agentMgr *AgentMgrComp // 客户端websocket连接管理 configure *configureComp } -//模块名 +// GetType 获取模块服务类型 func (this *Gateway) GetType() core.M_Modules { return comm.ModuleGate } -//模块自定义参数 +// NewOptions 模块自定义参数 func (this *Gateway) NewOptions() (options core.IModuleOptions) { return new(Options) } -//提供服务对象获取接口 +// Service 获取rpcx服务接口 func (this *Gateway) Service() base.IRPCXService { return this.service } -//模块初始化函数 +// Init 模块初始化函数 func (this *Gateway) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { err = this.ModuleBase.Init(service, module, options) this.service = service.(base.IRPCXService) return } -//模块启动函数 注册rpc服务接口提供用户相关的rpc接口服务 +// Start 模块启动函数 注册rpc服务接口提供用户相关的rpc接口服务 func (this *Gateway) Start() (err error) { - //注册用户绑定uid接口 登录成功后触发 - this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentBind), this.agentMgr.Bind) - //注册用户解绑uid接口 登出或则切换账号是触发 - this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentUnBind), this.agentMgr.UnBind) - //向用户发送消息接口 - this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentSendMsg), this.agentMgr.SendMsgToAgent) - //向多个用户对象发送消息接口 - this.service.RegisterFunctionName(string(comm.Rpc_GatewaySendBatchMsg), this.agentMgr.SendMsgToAgents) - //向所有用户发送消息接口 - this.service.RegisterFunctionName(string(comm.Rpc_GatewaySendRadioMsg), this.agentMgr.SendMsgToAllAgent) - //关闭用户socket连接接口 - this.service.RegisterFunctionName(string(comm.Rpc_GatewayAgentClose), this.agentMgr.CloseAgent) + _name2Func := map[string]any{ + // 注册用户绑定uid接口 登录成功后触发 + string(comm.Rpc_GatewayAgentBind): this.agentMgr.Bind, + // 注册用户解绑uid接口 登出或则切换账号是触发 + string(comm.Rpc_GatewayAgentUnBind): this.agentMgr.UnBind, + // 向用户发送消息接口 + string(comm.Rpc_GatewayAgentSendMsg): this.agentMgr.SendMsgToAgent, + // 向多个用户对象发送消息接口 + string(comm.Rpc_GatewaySendBatchMsg): this.agentMgr.SendMsgToAgents, + // 向所有用户发送消息接口 + string(comm.Rpc_GatewaySendRadioMsg): this.agentMgr.SendMsgToAllAgent, + // 关闭用户socket连接接口 + string(comm.Rpc_GatewayAgentClose): this.agentMgr.CloseAgent, + } + for name, fn := range _name2Func { + this.service.RegisterFunctionName(name, fn) + } err = this.ModuleBase.Start() return + } -//装备组件 +// OnInstallComp 装备组件 func (this *Gateway) OnInstallComp() { this.ModuleBase.OnInstallComp() this.agentMgr = this.RegisterComp(new(AgentMgrComp)).(*AgentMgrComp) @@ -75,19 +82,19 @@ func (this *Gateway) OnInstallComp() { this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } -//有新的连接对象进入 +// Connect 有新的连接对象进入 func (this *Gateway) Connect(a IAgent) { log.Debugf("[Module.Gateway] have new connect:Ip[%s] SessionId:[%s]", a.IP(), a.SessionId()) this.agentMgr.Connect(a) } -//有用户断开连接 +// DisConnect 有用户断开连接 func (this *Gateway) DisConnect(a IAgent) { log.Debugf("[Module.Gateway] have disConnect:Ip[%s] SessionId:[%s] uid:[%s]", a.IP(), a.SessionId(), a.UserId()) this.agentMgr.DisConnect(a) } -//读取消息分发规则 -func (this *Gateway) GetMsgDistribRule(mtype, stype string) (rule string, ok bool) { - return this.configure.GetMsgDistribRule(mtype, stype) +// GetMsgDistribute 读取消息分发规则 +func (this *Gateway) GetMsgDistribute(mtype, stype string) (rule string, ok bool) { + return this.configure.GetMsgDistribute(mtype, stype) } From 6d03d7b59c8f68e48a6d9bed1559c633b4a7b9b4 Mon Sep 17 00:00:00 2001 From: zhaocy Date: Wed, 29 Jun 2022 17:14:17 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E6=89=93=E5=8C=85=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.bat | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 build.bat diff --git a/build.bat b/build.bat new file mode 100644 index 000000000..bfedb4229 --- /dev/null +++ b/build.bat @@ -0,0 +1,7 @@ +SET CGO_ENABLED=0 +SET GOOS=windows +SET GOARCH=amd64 +go build -o build/gateway.exe services/gateway/main.go +go build -o build/worker.exe services/worker/main.go +go build -o build/web.exe services/web/main.go +go build -o build/dbservice.exe services/dbservice/main.go \ No newline at end of file From dea561817f9136ddaac5f7278eef291b78b31d2d Mon Sep 17 00:00:00 2001 From: zhaocy Date: Wed, 29 Jun 2022 17:15:05 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=A1=E5=8F=A0?= =?UTF-8?q?=E5=8A=A0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/robot/hero.go | 10 ++- cmd/robot/user.go | 2 +- modules/hero/api.go | 7 +- modules/hero/api_chouka.go | 32 ++++++- modules/hero/model_hero.go | 65 +++++++++----- modules/mail/module.go | 2 +- pb/errorcode.pb.go | 18 ++-- pb/hero_msg.pb.go | 158 ++++++++++++++++++++++++++++++----- pb/proto/errorcode.proto | 1 + pb/proto/hero/hero_msg.proto | 23 +++-- 10 files changed, 252 insertions(+), 66 deletions(-) diff --git a/cmd/robot/hero.go b/cmd/robot/hero.go index 7388fdc9a..71faaa594 100644 --- a/cmd/robot/hero.go +++ b/cmd/robot/hero.go @@ -21,8 +21,14 @@ var ( req: &pb.HeroInfoReq{ HeroId: "62baac19aa7c09b3679be57c", }, - rsp: &pb.HeroInfoRsp{}, - enabled: true, + rsp: &pb.HeroInfoRsp{}, + // enabled: true, + }, { + mainType: string(comm.ModuleHero), + subType: hero.HeroSubTypeChouka, + req: &pb.HeroChoukaReq{}, + rsp: &pb.HeroChoukaResp{}, + enabled: true, }, } ) diff --git a/cmd/robot/user.go b/cmd/robot/user.go index 749b220f9..3ede6b8ab 100644 --- a/cmd/robot/user.go +++ b/cmd/robot/user.go @@ -13,7 +13,7 @@ var user_builders = []*builder{ mainType: string(comm.ModuleUser), subType: user.UserSubTypeCreate, req: &pb.UserCreateReq{ //设置请求参数 - NickName: "乐谷6281", + NickName: "乐谷62911", }, rsp: &pb.UserCreateRsp{}, // enabled: true, diff --git a/modules/hero/api.go b/modules/hero/api.go index dc44450cb..a3a4bab6d 100644 --- a/modules/hero/api.go +++ b/modules/hero/api.go @@ -14,9 +14,10 @@ type apiComp struct { } const ( //消息回复的头名称 - StrengthenUplv = "strengthenherolv" - HeroSubTypeInfo = "info" //英雄卡片信息 - HeroSubTypeList = "list" //英雄列表 + StrengthenUplv = "strengthenherolv" + HeroSubTypeInfo = "info" //英雄卡片信息 + HeroSubTypeList = "list" //英雄列表 + HeroSubTypeChouka = "chouka" //抽卡 ) //组件初始化接口 diff --git a/modules/hero/api_chouka.go b/modules/hero/api_chouka.go index af895aab6..d862b0cfa 100644 --- a/modules/hero/api_chouka.go +++ b/modules/hero/api_chouka.go @@ -2,13 +2,41 @@ package hero import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" + "go_dreamfactory/utils" ) -func (this *apiComp) ChoukaCheck() (result map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) ChoukaCheck(session comm.IUserSession, req *pb.HeroChoukaReq) (result map[string]interface{}, code comm.ErrorCode) { + result = make(map[string]interface{}) return } -func (this *apiComp) Chouka(session comm.IUserSession, result map[string]interface{}, req *pb.HeroInfoReq) { +//抽卡 +func (this *apiComp) Chouka(session comm.IUserSession, result map[string]interface{}, req *pb.HeroChoukaReq) (code pb.ErrorCode) { + rsp := &pb.HeroChoukaResp{} + defer func() { + err := session.SendMsg(string(this.moduleHero.GetType()), HeroSubTypeChouka, rsp) + if err != nil { + code = pb.ErrorCode_SystemError + return + } + utils.TraceFunc(session.GetUserId(), string(this.moduleHero.GetType()), HeroSubTypeChouka, req, rsp) + }() + + heroCfgIds := []int32{15001, 25001} + if err := this.moduleHero.modelHero.createMultiHero(session.GetUserId(), heroCfgIds...); err != nil { + code = pb.ErrorCode_HeroCreate + return + } + + heroes, err := this.moduleHero.modelHero.getHeroList(session.GetUserId()) + if err != nil { + log.Errorf("%v", err) + code = pb.ErrorCode_DBError + return + } + rsp.Heroes = heroes + return } diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 8dbfd4a72..55b3c30c3 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -42,8 +42,10 @@ func (this *ModelHero) initHero(uid string, heroCfgId int32) *pb.DBHero { NormalSkill: []*pb.SkillData{}, //初始技能 IsOverlying: true, //是否允许叠加, Block: false, //未锁定 + CardType: heroCfg.Type, //卡片类型 Skins: []int32{}, EquipID: make([]string, 6), //初始装备 + SameCount: 1, //默认叠加数量 AddProperty: make(map[int32]int32), Energy: make(map[int32]int32), Property: make(map[int32]int32), @@ -52,24 +54,12 @@ func (this *ModelHero) initHero(uid string, heroCfgId int32) *pb.DBHero { } //创建一个指定的英雄 -func (this *ModelHero) createOneHero(uid string, heroCfgId int32) error { - heroes, err := this.getHeroList(uid) - if err != nil { - log.Errorf("%v", err) - return err - } - for _, v := range heroes { - if v.HeroID == heroCfgId { - v.SameCount++ - data := map[string]interface{}{ - "sameCount": v.SameCount, //叠加数 - } - return this.moduleHero.modelHero.Change(uid, data) - } else { - hero := this.initHero(uid, heroCfgId) - if hero != nil { - return this.moduleHero.modelHero.AddList(uid, hero.Id, hero) - } +func (this *ModelHero) createOneHero(uid string, heroCfgId int32) (err error) { + hero := this.initHero(uid, heroCfgId) + if hero != nil { + if err = this.moduleHero.modelHero.AddList(uid, hero.Id, hero); err != nil { + log.Errorf("%v", err) + return } } return nil @@ -77,11 +67,44 @@ func (this *ModelHero) createOneHero(uid string, heroCfgId int32) error { //创建多个指定的英雄 heroCfgIds可填入多个英雄ID func (this *ModelHero) createMultiHero(uid string, heroCfgIds ...int32) error { - for _, v := range heroCfgIds { - if err := this.createOneHero(uid, v); err != nil { - return err + heroes, err := this.moduleHero.modelHero.getHeroList(uid) + if err != nil { + return err + } + + if len(heroes) == 0 { + for _, v := range heroCfgIds { + if err := this.createOneHero(uid, v); err != nil { + return err + } + } + } else { + + findHero := func(heroId int32) (*pb.DBHero, bool) { + for _, h := range heroes { + if h.HeroID == heroId { + return h, true + } + } + return nil, false + } + for _, v := range heroCfgIds { + if h, ok := findHero(v); ok { + h.SameCount++ + data := map[string]interface{}{ + "sameCount": h.SameCount, //叠加数 + } + if err := this.modifyHero(uid, h.Id, data); err != nil { + return err + } + } else { + if err := this.createOneHero(uid, v); err != nil { + return err + } + } } } + return nil } diff --git a/modules/mail/module.go b/modules/mail/module.go index 66e994fb1..e60c2ee26 100644 --- a/modules/mail/module.go +++ b/modules/mail/module.go @@ -56,7 +56,7 @@ func (this *Mail) CreateNewMail(uId string) { log.Error("create mail failed") } // 通知玩家 - var _cache = &pb.Cache_UserData{} + var _cache = &pb.CacheUser{} err = this.modelMail.MCompModel.Get(uId, _cache) if err == nil { return diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index bdbcb25c6..198d61ec7 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -73,6 +73,7 @@ const ( ErrorCode_HeroMaxLv ErrorCode = 1302 //英雄达到最大等级 ErrorCode_HeroInitCreat ErrorCode = 1303 //初始化英雄 ErrorCode_HeroColorErr ErrorCode = 1304 // 品质不匹配 + ErrorCode_HeroCreate ErrorCode = 1305 // 创建卡失败 // equipment ErrorCode_EquipmentOnFoundEquipment ErrorCode = 1400 // 未找到武器 ErrorCode_EquipmentLvlimitReached ErrorCode = 1401 // 武器等级已达上限 @@ -127,6 +128,7 @@ var ( 1302: "HeroMaxLv", 1303: "HeroInitCreat", 1304: "HeroColorErr", + 1305: "HeroCreate", 1400: "EquipmentOnFoundEquipment", 1401: "EquipmentLvlimitReached", } @@ -177,6 +179,7 @@ var ( "HeroMaxLv": 1302, "HeroInitCreat": 1303, "HeroColorErr": 1304, + "HeroCreate": 1305, "EquipmentOnFoundEquipment": 1400, "EquipmentLvlimitReached": 1401, } @@ -213,7 +216,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, 0xf4, 0x07, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0x85, 0x08, 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, @@ -272,12 +275,13 @@ var file_errorcode_proto_rawDesc = []byte{ 0x10, 0x95, 0x0a, 0x12, 0x0e, 0x0a, 0x09, 0x48, 0x65, 0x72, 0x6f, 0x4d, 0x61, 0x78, 0x4c, 0x76, 0x10, 0x96, 0x0a, 0x12, 0x12, 0x0a, 0x0d, 0x48, 0x65, 0x72, 0x6f, 0x49, 0x6e, 0x69, 0x74, 0x43, 0x72, 0x65, 0x61, 0x74, 0x10, 0x97, 0x0a, 0x12, 0x11, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x43, - 0x6f, 0x6c, 0x6f, 0x72, 0x45, 0x72, 0x72, 0x10, 0x98, 0x0a, 0x12, 0x1e, 0x0a, 0x19, 0x45, 0x71, - 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4f, 0x6e, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x45, 0x71, - 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0xf8, 0x0a, 0x12, 0x1c, 0x0a, 0x17, 0x45, 0x71, - 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x76, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x52, 0x65, - 0x61, 0x63, 0x68, 0x65, 0x64, 0x10, 0xf9, 0x0a, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6c, 0x6f, 0x72, 0x45, 0x72, 0x72, 0x10, 0x98, 0x0a, 0x12, 0x0f, 0x0a, 0x0a, 0x48, 0x65, + 0x72, 0x6f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x10, 0x99, 0x0a, 0x12, 0x1e, 0x0a, 0x19, 0x45, + 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4f, 0x6e, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x45, + 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0xf8, 0x0a, 0x12, 0x1c, 0x0a, 0x17, 0x45, + 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x76, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x52, + 0x65, 0x61, 0x63, 0x68, 0x65, 0x64, 0x10, 0xf9, 0x0a, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, + 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/hero_msg.pb.go b/pb/hero_msg.pb.go index 4811966cb..1bd70e1a7 100644 --- a/pb/hero_msg.pb.go +++ b/pb/hero_msg.pb.go @@ -1076,6 +1076,92 @@ func (x *HeroJuexingResp) GetHero() *DBHero { return nil } +//抽卡 +type HeroChoukaReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *HeroChoukaReq) Reset() { + *x = HeroChoukaReq{} + if protoimpl.UnsafeEnabled { + mi := &file_hero_hero_msg_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeroChoukaReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeroChoukaReq) ProtoMessage() {} + +func (x *HeroChoukaReq) ProtoReflect() protoreflect.Message { + mi := &file_hero_hero_msg_proto_msgTypes[20] + 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 HeroChoukaReq.ProtoReflect.Descriptor instead. +func (*HeroChoukaReq) Descriptor() ([]byte, []int) { + return file_hero_hero_msg_proto_rawDescGZIP(), []int{20} +} + +type HeroChoukaResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Heroes []*DBHero `protobuf:"bytes,1,rep,name=heroes,proto3" json:"heroes"` +} + +func (x *HeroChoukaResp) Reset() { + *x = HeroChoukaResp{} + if protoimpl.UnsafeEnabled { + mi := &file_hero_hero_msg_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeroChoukaResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeroChoukaResp) ProtoMessage() {} + +func (x *HeroChoukaResp) ProtoReflect() protoreflect.Message { + mi := &file_hero_hero_msg_proto_msgTypes[21] + 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 HeroChoukaResp.ProtoReflect.Descriptor instead. +func (*HeroChoukaResp) Descriptor() ([]byte, []int) { + return file_hero_hero_msg_proto_rawDescGZIP(), []int{21} +} + +func (x *HeroChoukaResp) GetHeroes() []*DBHero { + if x != nil { + return x.Heroes + } + return nil +} + var File_hero_hero_msg_proto protoreflect.FileDescriptor var file_hero_hero_msg_proto_rawDesc = []byte{ @@ -1172,8 +1258,13 @@ var file_hero_hero_msg_proto_rawDesc = []byte{ 0x09, 0x63, 0x6f, 0x73, 0x74, 0x49, 0x74, 0x6d, 0x65, 0x73, 0x22, 0x31, 0x0a, 0x0f, 0x48, 0x65, 0x72, 0x6f, 0x4a, 0x75, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, - 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x42, 0x06, 0x5a, - 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x22, 0x0f, 0x0a, + 0x0d, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x68, 0x6f, 0x75, 0x6b, 0x61, 0x52, 0x65, 0x71, 0x22, 0x34, + 0x0a, 0x0e, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x68, 0x6f, 0x75, 0x6b, 0x61, 0x52, 0x65, 0x73, 0x70, + 0x12, 0x22, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x06, 0x68, 0x65, + 0x72, 0x6f, 0x65, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1188,7 +1279,7 @@ func file_hero_hero_msg_proto_rawDescGZIP() []byte { return file_hero_hero_msg_proto_rawDescData } -var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 20) +var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 22) var file_hero_hero_msg_proto_goTypes = []interface{}{ (*HeroInfoReq)(nil), // 0: pb.HeroInfoReq (*HeroInfoRsp)(nil), // 1: pb.HeroInfoRsp @@ -1210,27 +1301,30 @@ var file_hero_hero_msg_proto_goTypes = []interface{}{ (*HeroGongmingUseEnergyResp)(nil), // 17: pb.HeroGongmingUseEnergyResp (*HeroJuexingReq)(nil), // 18: pb.HeroJuexingReq (*HeroJuexingResp)(nil), // 19: pb.HeroJuexingResp - (*DBHero)(nil), // 20: pb.DBHero + (*HeroChoukaReq)(nil), // 20: pb.HeroChoukaReq + (*HeroChoukaResp)(nil), // 21: pb.HeroChoukaResp + (*DBHero)(nil), // 22: pb.DBHero } var file_hero_hero_msg_proto_depIdxs = []int32{ - 20, // 0: pb.HeroInfoRsp.base:type_name -> pb.DBHero - 20, // 1: pb.HeroListRsp.list:type_name -> pb.DBHero - 20, // 2: pb.HeroStrengthenUplvResp.hero:type_name -> pb.DBHero + 22, // 0: pb.HeroInfoRsp.base:type_name -> pb.DBHero + 22, // 1: pb.HeroListRsp.list:type_name -> pb.DBHero + 22, // 2: pb.HeroStrengthenUplvResp.hero:type_name -> pb.DBHero 7, // 3: pb.HeroStrengthenUpStarReq.hero:type_name -> pb.CostCardData 7, // 4: pb.HeroStrengthenUpStarReq.heroRace:type_name -> pb.CostCardData - 20, // 5: pb.HeroStrengthenUpStarResp.hero:type_name -> pb.DBHero - 20, // 6: pb.HeroStrengthenUpSkillResp.hero:type_name -> pb.DBHero - 20, // 7: pb.HeroGongmingResp.hero:type_name -> pb.DBHero - 20, // 8: pb.HeroGongmingResp.upStarCard:type_name -> pb.DBHero - 20, // 9: pb.HeroGongmingResetResp.hero:type_name -> pb.DBHero - 20, // 10: pb.HeroGongmingUseEnergyResp.hero:type_name -> pb.DBHero + 22, // 5: pb.HeroStrengthenUpStarResp.hero:type_name -> pb.DBHero + 22, // 6: pb.HeroStrengthenUpSkillResp.hero:type_name -> pb.DBHero + 22, // 7: pb.HeroGongmingResp.hero:type_name -> pb.DBHero + 22, // 8: pb.HeroGongmingResp.upStarCard:type_name -> pb.DBHero + 22, // 9: pb.HeroGongmingResetResp.hero:type_name -> pb.DBHero + 22, // 10: pb.HeroGongmingUseEnergyResp.hero:type_name -> pb.DBHero 4, // 11: pb.HeroJuexingReq.costItmes:type_name -> pb.ItemData - 20, // 12: pb.HeroJuexingResp.hero:type_name -> pb.DBHero - 13, // [13:13] is the sub-list for method output_type - 13, // [13:13] is the sub-list for method input_type - 13, // [13:13] is the sub-list for extension type_name - 13, // [13:13] is the sub-list for extension extendee - 0, // [0:13] is the sub-list for field type_name + 22, // 12: pb.HeroJuexingResp.hero:type_name -> pb.DBHero + 22, // 13: pb.HeroChoukaResp.heroes:type_name -> pb.DBHero + 14, // [14:14] is the sub-list for method output_type + 14, // [14:14] is the sub-list for method input_type + 14, // [14:14] is the sub-list for extension type_name + 14, // [14:14] is the sub-list for extension extendee + 0, // [0:14] is the sub-list for field type_name } func init() { file_hero_hero_msg_proto_init() } @@ -1480,6 +1574,30 @@ func file_hero_hero_msg_proto_init() { return nil } } + file_hero_hero_msg_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeroChoukaReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_hero_hero_msg_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeroChoukaResp); 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{ @@ -1487,7 +1605,7 @@ func file_hero_hero_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_hero_hero_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 20, + NumMessages: 22, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/proto/errorcode.proto b/pb/proto/errorcode.proto index f7311c410..785bd5fbf 100644 --- a/pb/proto/errorcode.proto +++ b/pb/proto/errorcode.proto @@ -56,6 +56,7 @@ enum ErrorCode { HeroMaxLv = 1302; //英雄达到最大等级 HeroInitCreat = 1303; //初始化英雄 HeroColorErr = 1304; // 品质不匹配 + HeroCreate = 1305; // 创建卡失败 // equipment EquipmentOnFoundEquipment = 1400; // 未找到武器 EquipmentLvlimitReached = 1401; // 武器等级已达上限 diff --git a/pb/proto/hero/hero_msg.proto b/pb/proto/hero/hero_msg.proto index 7fa3a3759..ed8a5cb80 100644 --- a/pb/proto/hero/hero_msg.proto +++ b/pb/proto/hero/hero_msg.proto @@ -25,9 +25,9 @@ message ItemData { // 卡牌升级 message HeroStrengthenUplvReq { - string heroObjID = 1; // 英雄对象ID - string expCardID = 2; // 经验卡对象ID - int32 amount = 3; // 消耗经验卡数量} + string heroObjID = 1; // 英雄对象ID + string expCardID = 2; // 经验卡对象ID + int32 amount = 3; // 消耗经验卡数量} } // 卡牌升级返回 @@ -41,8 +41,8 @@ message CostCardData { } // 卡牌升星 message HeroStrengthenUpStarReq { - string heroObjID = 1; // 英雄对象ID - repeated CostCardData hero = 2; // 消耗卡牌对象ID + string heroObjID = 1; // 英雄对象ID + repeated CostCardData hero = 2; // 消耗卡牌对象ID repeated CostCardData heroRace = 3; // 消耗种族卡牌对象ID } @@ -70,7 +70,7 @@ message HeroGongmingReq { message HeroGongmingResp { DBHero hero = 1; // 英雄对象 - int32 energy = 2; // 共鸣成功 获得的能量点数 + int32 energy = 2; // 共鸣成功 获得的能量点数 DBHero upStarCard = 3; //共鸣成功 获得的升星卡 } @@ -80,8 +80,8 @@ message HeroGongmingResetReq { } message HeroGongmingResetResp { - DBHero hero = 1; // 英雄对象 - int32 energy = 2; // 能量点数 + DBHero hero = 1; // 英雄对象 + int32 energy = 2; // 能量点数 } // 使用能量点数 @@ -104,4 +104,9 @@ message HeroJuexingReq { // 觉醒返回 message HeroJuexingResp { DBHero hero = 1; // 英雄对象 -} \ No newline at end of file +} + +//抽卡 +message HeroChoukaReq {} + +message HeroChoukaResp { repeated DBHero heroes = 1; } \ No newline at end of file From 7670cb6505fae942597dfa584ee0a3f789f0d0ae Mon Sep 17 00:00:00 2001 From: wnp Date: Wed, 29 Jun 2022 17:31:08 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E6=8E=A8=E9=80=81=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/gateway/options.go | 2 +- modules/gateway/wservice_comp.go | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/gateway/options.go b/modules/gateway/options.go index 87c1f797a..f042a61cb 100644 --- a/modules/gateway/options.go +++ b/modules/gateway/options.go @@ -14,7 +14,7 @@ type ( } ) -//序列化参数对象 +// LoadConfig 配置文件序列化为Options func (this *Options) LoadConfig(settings map[string]interface{}) (err error) { if settings != nil { err = mapstructure.Decode(settings, this) diff --git a/modules/gateway/wservice_comp.go b/modules/gateway/wservice_comp.go index 0a75bd650..d730369ff 100644 --- a/modules/gateway/wservice_comp.go +++ b/modules/gateway/wservice_comp.go @@ -16,19 +16,24 @@ type WSServiceComp struct { cbase.ModuleCompBase options *Options - module IGateway - gin gin.ISys + module IGateway // 网关 + gin gin.ISys // gin服务接口 } +// Init websocket服务初始化 func (this *WSServiceComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { err = this.ModuleCompBase.Init(service, module, comp, options) this.options = options.(*Options) this.module = module.(IGateway) this.gin, err = gin.NewSys(gin.SetListenPort(this.options.ListenPort)) + + // 游戏业务逻辑处理 this.gin.GET("/gateway", this.ws) + return } +// ws 升级websocket连接处理本次请求 func (this *WSServiceComp) ws(c *engine.Context) { upGrader := websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool { From 0ca503749757556138d05f70d507ec75fc80bc23 Mon Sep 17 00:00:00 2001 From: wnp Date: Wed, 29 Jun 2022 17:34:11 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/gateway/agentmgr_comp.go | 16 ++++++++-------- modules/gateway/configure_comp.go | 4 ++-- modules/gateway/core.go | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/gateway/agentmgr_comp.go b/modules/gateway/agentmgr_comp.go index 1bc209aaf..d9a487132 100644 --- a/modules/gateway/agentmgr_comp.go +++ b/modules/gateway/agentmgr_comp.go @@ -30,12 +30,12 @@ func (this *AgentMgrComp) Init(service core.IService, module core.IModule, comp return } -//加入新的用户 +// Connect 加入新的用户 func (this *AgentMgrComp) Connect(a IAgent) { this.agents.Store(a.SessionId(), a) } -//移除断开的用户 +// DisConnect 移除断开的用户 func (this *AgentMgrComp) DisConnect(a IAgent) { this.agents.Delete(a.SessionId()) if a.UserId() != "" { //登录用户 通知业务服务处理玩家离线相关 @@ -49,7 +49,7 @@ func (this *AgentMgrComp) DisConnect(a IAgent) { } } -//用户登录绑定Id +// Bind 用户绑定Id func (this *AgentMgrComp) Bind(ctx context.Context, args *pb.AgentBuildReq, reply *pb.RPCMessageReply) error { if a, ok := this.agents.Load(args.UserSessionId); ok { a.(IAgent).Bind(args.UserId, args.WorkerId) @@ -60,7 +60,7 @@ func (this *AgentMgrComp) Bind(ctx context.Context, args *pb.AgentBuildReq, repl return nil } -//用户登录解绑Id +// UnBind 用户解绑Id func (this *AgentMgrComp) UnBind(ctx context.Context, args *pb.AgentUnBuildReq, reply *pb.RPCMessageReply) error { if a, ok := this.agents.Load(args.UserSessionId); ok { a.(IAgent).UnBind() @@ -71,7 +71,7 @@ func (this *AgentMgrComp) UnBind(ctx context.Context, args *pb.AgentUnBuildReq, return nil } -//向用户发送消息 +// SendMsgToAgent 向用户发送消息 func (this *AgentMgrComp) SendMsgToAgent(ctx context.Context, args *pb.AgentSendMessageReq, reply *pb.RPCMessageReply) error { if a, ok := this.agents.Load(args.UserSessionId); ok { a.(IAgent).WriteMsg(&pb.UserMessage{ @@ -86,7 +86,7 @@ func (this *AgentMgrComp) SendMsgToAgent(ctx context.Context, args *pb.AgentSend return nil } -//向多个户发送消息 +// SendMsgToAgents 向多个户发送消息 func (this *AgentMgrComp) SendMsgToAgents(ctx context.Context, args *pb.BatchMessageReq, reply *pb.RPCMessageReply) error { msg := &pb.UserMessage{ MainType: args.MainType, @@ -101,7 +101,7 @@ func (this *AgentMgrComp) SendMsgToAgents(ctx context.Context, args *pb.BatchMes return nil } -//向所有户发送消息 +// SendMsgToAllAgent 向所有户发送消息 func (this *AgentMgrComp) SendMsgToAllAgent(ctx context.Context, args *pb.BroadCastMessageReq, reply *pb.RPCMessageReply) error { msg := &pb.UserMessage{ MainType: args.MainType, @@ -115,7 +115,7 @@ func (this *AgentMgrComp) SendMsgToAllAgent(ctx context.Context, args *pb.BroadC return nil } -//关闭代理 +// CloseAgent 关闭某个用户 func (this *AgentMgrComp) CloseAgent(ctx context.Context, args *pb.AgentCloseeReq, reply *pb.RPCMessageReply) error { if a, ok := this.agents.Load(args.UserSessionId); ok { a.(IAgent).Close() diff --git a/modules/gateway/configure_comp.go b/modules/gateway/configure_comp.go index 8b155e9bc..2136dd29e 100644 --- a/modules/gateway/configure_comp.go +++ b/modules/gateway/configure_comp.go @@ -16,14 +16,14 @@ type configureComp struct { modules.MCompConfigure } -//组件初始化接口 +// Init 组件初始化接口 func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { this.ModuleCompBase.Init(service, module, comp, options) this.LoadConfigure(game_msgdistrib, cfg.NewGame_msgDistrib) return } -//获取消息分发规则读取配置表 +// GetMsgDistribute 获取消息分发规则读取配置表 func (this *configureComp) GetMsgDistribute(mtype, stype string) (rule string, ok bool) { var ( err error diff --git a/modules/gateway/core.go b/modules/gateway/core.go index 7159211ea..7fd4749a6 100644 --- a/modules/gateway/core.go +++ b/modules/gateway/core.go @@ -8,7 +8,7 @@ import ( ) type ( - //用户代理对象接口定义 + // IAgent 用户代理对象接口定义 IAgent interface { SessionId() string IP() string @@ -19,7 +19,7 @@ type ( WriteMsg(msg *pb.UserMessage) (err error) Close() //主动关闭接口 } - //网关模块 接口定义 + // IGateway 网关模块 接口定义 IGateway interface { core.IModule Service() base.IRPCXService