等级推送

This commit is contained in:
zhaocy 2022-07-25 15:26:13 +08:00
parent ef6f6efa69
commit 4b2873db8e
12 changed files with 157 additions and 51 deletions

View File

@ -24,7 +24,7 @@ var (
fmt.Printf("%d- %v\n", (i + 1), v) fmt.Printf("%d- %v\n", (i + 1), v)
} }
}, },
enabled: true, // enabled: true,
next: func(robot *Robot, rsp proto.Message) { next: func(robot *Robot, rsp proto.Message) {
tcs := []*TestCase{} tcs := []*TestCase{}
if _, ok := rsp.(*pb.HeroListResp); ok { if _, ok := rsp.(*pb.HeroListResp); ok {
@ -33,13 +33,16 @@ var (
mainType: string(comm.ModuleHero), mainType: string(comm.ModuleHero),
subType: hero.StrengthenUplv, subType: hero.StrengthenUplv,
req: &pb.HeroStrengthenUplvReq{ req: &pb.HeroStrengthenUplvReq{
HeroObjID: "62dabaacd8c5789e2cc8b95e", HeroObjID: "62de35b92f462b70c1105aa8",
ExpCards: map[string]int32{ ExpCards: []*pb.MapStringInt32{
"62dabac1d8c5789e2cc8b9d3": 1, {
Key: "62de35b92f462b70c1105ab8",
Value: 1,
},
}, },
}, },
rsp: &pb.HeroStrengthenUplvResp{}, rsp: &pb.HeroStrengthenUplvResp{},
enabled: true, // enabled: true,
} }
tcs = append(tcs, tc) tcs = append(tcs, tc)
} }
@ -97,8 +100,11 @@ var (
subType: hero.StrengthenUplv, subType: hero.StrengthenUplv,
req: &pb.HeroStrengthenUplvReq{ req: &pb.HeroStrengthenUplvReq{
HeroObjID: heroId, HeroObjID: heroId,
ExpCards: map[string]int32{ ExpCards: []*pb.MapStringInt32{
"62da19017944b60fd473df61": 1, {
Key: "62da19017944b60fd473df61",
Value: 1,
},
}, },
}, },
rsp: &pb.HeroStrengthenUplvResp{}, rsp: &pb.HeroStrengthenUplvResp{},

View File

@ -40,7 +40,7 @@ var (
subType: task.TaskSubTypeReceive, subType: task.TaskSubTypeReceive,
req: &pb.TaskReceiveReq{ req: &pb.TaskReceiveReq{
TaskTag: int32(comm.TASK_DAILY), TaskTag: int32(comm.TASK_DAILY),
Id: "62dab21d9efd6536b1cc1bb9", Id: "62de35b92f462b70c1105ac5",
}, },
rsp: &pb.TaskReceiveResp{}, rsp: &pb.TaskReceiveResp{},
// enabled: true, // enabled: true,

View File

@ -11,15 +11,14 @@ import (
//申明测试接口及请求和响应参数 //申明测试接口及请求和响应参数
var user_builders = []*TestCase{ var user_builders = []*TestCase{
{ {
//create desc: "修改名称",
desc: "创角",
mainType: string(comm.ModuleUser), mainType: string(comm.ModuleUser),
subType: user.UserSubTypeCreate, subType: user.UserSubTypeModifyName,
req: &pb.UserCreateReq{ //设置请求参数 req: &pb.UserModifynameReq{ //设置请求参数
NickName: "乐谷70616", Name: "uuuuuu",
}, },
rsp: &pb.UserCreateResp{}, rsp: &pb.UserModifynameResp{},
// enabled: true, enabled: true,
}, { }, {
desc: "添加资源", desc: "添加资源",
mainType: string(comm.ModuleUser), mainType: string(comm.ModuleUser),

View File

@ -492,7 +492,7 @@ func (this *MCompModel) DelListlds(uid string, ids ...string) (err error) {
func (this *MCompModel) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) { func (this *MCompModel) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) {
result = &pb.DBUserExpand{} result = &pb.DBUserExpand{}
key := fmt.Sprintf("userexpand:%s", uid) key := fmt.Sprintf("userexpand:%s", uid)
if err = this.Redis.HGetAll(key, result); err != nil && err != redis.RedisNil { if err = this.Redis.HGetAll(key, result); err != nil {
return return
} }
if err == redis.RedisNil { if err == redis.RedisNil {

View File

@ -120,8 +120,12 @@ func (this *ModelTaskActive) receiveHandle(uid, id string, conf *cfg.Game_active
} }
//清空任务 //清空任务
func (this *ModelTaskActive) clearTask(uid string) { func (this *ModelTaskActive) clearTask(uid string, taskTag ...comm.TaskTag) {
data := this.getActiveList(uid) if len(taskTag) == 0 {
log.Errorf("least one param for taskTag")
return
}
data := this.getActiveListByTag(uid, taskTag[0])
for _, v := range data { for _, v := range data {
if err := this.moduleTask.modelTaskActive.DelListlds(uid, v.Id); err != nil { if err := this.moduleTask.modelTaskActive.DelListlds(uid, v.Id); err != nil {
log.Errorf("uid: %v err:%v", uid, err) log.Errorf("uid: %v err:%v", uid, err)

View File

@ -142,8 +142,12 @@ func (this *ModelTask) modifyUserTask(uid string, taskId string, data map[string
} }
//清空任务 //清空任务
func (this *ModelTask) clearTask(uid string) { func (this *ModelTask) clearTask(uid string, taskTag ...comm.TaskTag) {
taskList := this.getTaskList(uid) if len(taskTag) == 0 {
log.Errorf("least one param for taskTag")
return
}
taskList := this.getTaskListByTag(uid, taskTag[0])
for _, v := range taskList { for _, v := range taskList {
if err := this.moduleTask.modelTask.DelListlds(uid, v.Id); err != nil { if err := this.moduleTask.modelTask.DelListlds(uid, v.Id); err != nil {
log.Errorf("uid: %v err:%v", uid, err) log.Errorf("uid: %v err:%v", uid, err)

View File

@ -56,9 +56,9 @@ func (this *ModuleTask) InitTaskAll(uid string) {
} }
//重置任务 //重置任务
func (this *ModuleTask) ResetTask(uid string) { func (this *ModuleTask) ResetTask(uid string, taskTag comm.TaskTag) {
this.modelTask.clearTask(uid) this.modelTask.clearTask(uid, taskTag)
this.modelTaskActive.clearTask(uid) this.modelTaskActive.clearTask(uid, taskTag)
this.InitTaskAll(uid) this.InitTaskAll(uid)
} }

View File

@ -18,6 +18,8 @@ const (
UserSubTypeVeriCode = "vericode" //验证码 UserSubTypeVeriCode = "vericode" //验证码
UserSubTypeInitData = "initdata" //初始化用户 UserSubTypeInitData = "initdata" //初始化用户
UserGetTujianResp = "gettujian" //获取图鉴信息 UserGetTujianResp = "gettujian" //获取图鉴信息
UserSubTypeLvChangedPush = "lvChangedPush" //等级变化推送
UserSubTypeModifyName = "modifyname" //修改名称
) )
type apiComp struct { type apiComp struct {

View File

@ -4,12 +4,13 @@ import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"strings"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
func (this *apiComp) ModifynameCheck(session comm.IUserSession, req *pb.UserModifynameReq) (code pb.ErrorCode) { func (this *apiComp) ModifynameCheck(session comm.IUserSession, req *pb.UserModifynameReq) (code pb.ErrorCode) {
if req.Name == "" || len(req.Name) > 6 { if strings.TrimSpace(req.Name) == "" || len(strings.TrimSpace(req.Name)) > 6 {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
} }
return return
@ -20,13 +21,14 @@ func (this *apiComp) Modifyname(session comm.IUserSession, req *pb.UserModifynam
return return
} }
name := strings.TrimSpace(req.Name)
//验证名称 //验证名称
if this.module.modelUser.NickNameIsExist(req.Name) { if !this.module.modelUser.NickNameIsExist(name) {
code = pb.ErrorCode_NameExist code = pb.ErrorCode_NameExist
return return
} }
expand, err := this.module.modelUser.GetUserExpand(session.GetSessionId()) expand, err := this.module.modelUser.GetUserExpand(session.GetUserId())
if err != nil { if err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
@ -56,7 +58,7 @@ func (this *apiComp) Modifyname(session comm.IUserSession, req *pb.UserModifynam
} }
// 修改名称 // 修改名称
if code = this.module.modelUser.modifyName(session.GetUserId(), req.Name); code != pb.ErrorCode_Success { if code = this.module.modelUser.modifyName(session.GetUserId(), name); code != pb.ErrorCode_Success {
return return
} }

View File

@ -158,6 +158,9 @@ func (this *ModelUser) ChangeLevel(event interface{}, next func(event interface{
"lv": ul.lv, "lv": ul.lv,
} }
this.moduleUser.modelUser.Change(ul.session.GetUserId(), update) this.moduleUser.modelUser.Change(ul.session.GetUserId(), update)
ul.session.SendMsg(string(this.moduleUser.GetType()),
UserSubTypeLvChangedPush,
&pb.UserChangedPush{Uid: ul.session.GetUserId(), Exp: ul.exp, Lv: ul.lv})
} }
} }

View File

@ -93,10 +93,13 @@ message UserModifynameResp {
uint32 count = 2; // uint32 count = 2; //
} }
message UserGetTujianReq{ //
message UserGetTujianReq {}
message UserGetTujianResp { repeated string heroids = 1; }
} //
message UserChangedPush {
message UserGetTujianResp{ string uid = 1;
repeated string heroids = 1; int32 exp = 2;
int32 lv = 3;
} }

View File

@ -1083,6 +1083,7 @@ func (x *UserModifynameResp) GetCount() uint32 {
return 0 return 0
} }
// 图鉴
type UserGetTujianReq struct { type UserGetTujianReq struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@ -1168,6 +1169,70 @@ func (x *UserGetTujianResp) GetHeroids() []string {
return nil return nil
} }
//玩家等级经验变化推送
type UserChangedPush struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"`
Exp int32 `protobuf:"varint,2,opt,name=exp,proto3" json:"exp"`
Lv int32 `protobuf:"varint,3,opt,name=lv,proto3" json:"lv"`
}
func (x *UserChangedPush) Reset() {
*x = UserChangedPush{}
if protoimpl.UnsafeEnabled {
mi := &file_user_user_msg_proto_msgTypes[24]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UserChangedPush) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UserChangedPush) ProtoMessage() {}
func (x *UserChangedPush) ProtoReflect() protoreflect.Message {
mi := &file_user_user_msg_proto_msgTypes[24]
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 UserChangedPush.ProtoReflect.Descriptor instead.
func (*UserChangedPush) Descriptor() ([]byte, []int) {
return file_user_user_msg_proto_rawDescGZIP(), []int{24}
}
func (x *UserChangedPush) GetUid() string {
if x != nil {
return x.Uid
}
return ""
}
func (x *UserChangedPush) GetExp() int32 {
if x != nil {
return x.Exp
}
return 0
}
func (x *UserChangedPush) GetLv() int32 {
if x != nil {
return x.Lv
}
return 0
}
var File_user_user_msg_proto protoreflect.FileDescriptor var File_user_user_msg_proto protoreflect.FileDescriptor
var file_user_user_msg_proto_rawDesc = []byte{ var file_user_user_msg_proto_rawDesc = []byte{
@ -1247,7 +1312,12 @@ var file_user_user_msg_proto_rawDesc = []byte{
0x71, 0x22, 0x2d, 0x0a, 0x11, 0x55, 0x73, 0x65, 0x72, 0x47, 0x65, 0x74, 0x54, 0x75, 0x6a, 0x69, 0x71, 0x22, 0x2d, 0x0a, 0x11, 0x55, 0x73, 0x65, 0x72, 0x47, 0x65, 0x74, 0x54, 0x75, 0x6a, 0x69,
0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x69, 0x64, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x69, 0x64,
0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x69, 0x64, 0x73, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x69, 0x64, 0x73,
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x22, 0x45, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x50,
0x75, 0x73, 0x68, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x78, 0x70, 0x18, 0x02, 0x20, 0x01,
0x28, 0x05, 0x52, 0x03, 0x65, 0x78, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x03, 0x20,
0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -1262,7 +1332,7 @@ func file_user_user_msg_proto_rawDescGZIP() []byte {
return file_user_user_msg_proto_rawDescData return file_user_user_msg_proto_rawDescData
} }
var file_user_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 24) var file_user_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 25)
var file_user_user_msg_proto_goTypes = []interface{}{ var file_user_user_msg_proto_goTypes = []interface{}{
(*UserLoginReq)(nil), // 0: UserLoginReq (*UserLoginReq)(nil), // 0: UserLoginReq
(*UserLoginResp)(nil), // 1: UserLoginResp (*UserLoginResp)(nil), // 1: UserLoginResp
@ -1288,22 +1358,23 @@ var file_user_user_msg_proto_goTypes = []interface{}{
(*UserModifynameResp)(nil), // 21: UserModifynameResp (*UserModifynameResp)(nil), // 21: UserModifynameResp
(*UserGetTujianReq)(nil), // 22: UserGetTujianReq (*UserGetTujianReq)(nil), // 22: UserGetTujianReq
(*UserGetTujianResp)(nil), // 23: UserGetTujianResp (*UserGetTujianResp)(nil), // 23: UserGetTujianResp
(*DBUser)(nil), // 24: DBUser (*UserChangedPush)(nil), // 24: UserChangedPush
(*DBUserExpand)(nil), // 25: DBUserExpand (*DBUser)(nil), // 25: DBUser
(ErrorCode)(0), // 26: ErrorCode (*DBUserExpand)(nil), // 26: DBUserExpand
(*CacheUser)(nil), // 27: CacheUser (ErrorCode)(0), // 27: ErrorCode
(*UserAssets)(nil), // 28: UserAssets (*CacheUser)(nil), // 28: CacheUser
(*DBUserSetting)(nil), // 29: DBUserSetting (*UserAssets)(nil), // 29: UserAssets
(*DBUserSetting)(nil), // 30: DBUserSetting
} }
var file_user_user_msg_proto_depIdxs = []int32{ var file_user_user_msg_proto_depIdxs = []int32{
24, // 0: UserLoginResp.data:type_name -> DBUser 25, // 0: UserLoginResp.data:type_name -> DBUser
25, // 1: UserLoginResp.ex:type_name -> DBUserExpand 26, // 1: UserLoginResp.ex:type_name -> DBUserExpand
26, // 2: UserRegisterResp.Code:type_name -> ErrorCode 27, // 2: UserRegisterResp.Code:type_name -> ErrorCode
27, // 3: UserLoadResp.data:type_name -> CacheUser 28, // 3: UserLoadResp.data:type_name -> CacheUser
28, // 4: UserAddResReq.res:type_name -> UserAssets 29, // 4: UserAddResReq.res:type_name -> UserAssets
28, // 5: UserAddResResp.res:type_name -> UserAssets 29, // 5: UserAddResResp.res:type_name -> UserAssets
29, // 6: UserGetSettingResp.setting:type_name -> DBUserSetting 30, // 6: UserGetSettingResp.setting:type_name -> DBUserSetting
29, // 7: UserUpdateSettingReq.setting:type_name -> DBUserSetting 30, // 7: UserUpdateSettingReq.setting:type_name -> DBUserSetting
8, // [8:8] is the sub-list for method output_type 8, // [8:8] is the sub-list for method output_type
8, // [8:8] is the sub-list for method input_type 8, // [8:8] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name 8, // [8:8] is the sub-list for extension type_name
@ -1609,6 +1680,18 @@ func file_user_user_msg_proto_init() {
return nil return nil
} }
} }
file_user_user_msg_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UserChangedPush); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -1616,7 +1699,7 @@ func file_user_user_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_user_user_msg_proto_rawDesc, RawDescriptor: file_user_user_msg_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 24, NumMessages: 25,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },