This commit is contained in:
meixiongfeng 2024-01-19 11:13:24 +08:00
commit ddc7aef6fd
6 changed files with 63 additions and 59 deletions

View File

@ -8,7 +8,7 @@ import (
//参数校验
func (this *apiComp) AwardCheck(session comm.IUserSession, req *pb.MoonlvAwardReq) (errdata *pb.ErrorData) {
if req.Lv == 0 {
if req.Cid == 0 {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
@ -35,7 +35,7 @@ func (this *apiComp) Award(session comm.IUserSession, req *pb.MoonlvAwardReq) (e
return
}
if conf, err = this.module.configure.GetMoonLvConf(list.Lv); err != nil {
if conf, err = this.module.configure.GetMoonLvConf(list.Cid); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
@ -59,22 +59,26 @@ func (this *apiComp) Award(session comm.IUserSession, req *pb.MoonlvAwardReq) (e
return
}
}
if _, ok := list.Reward[req.Lv]; ok {
if _, ok := list.Reward[req.Cid]; ok {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_TaskRepeatedReward,
Title: pb.ErrorCode_TaskRepeatedReward.ToString(),
}
return
}
list.Reward[req.Lv] = true
if _, err = this.module.configure.GetMoonLvConf(list.Lv + 1); err == nil { // 查看能不能继续升级
list.Lv += 1
update["lv"] = list.Lv
if errdata = this.module.ModuleUser.ChangeUserMoonLv(session, list.Lv); errdata != nil {
list.Reward[req.Cid] = true
if _, err = this.module.configure.GetMoonLvConf(list.Cid + 1); err != nil { // 查看能不能继续升级
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Message: "is maxlv",
}
return
}
list.Cid += 1
update["cid"] = list.Cid
if errdata = this.module.ModuleUser.ChangeUserMoonLv(session, list.Cid); errdata != nil {
return
}
update["reward"] = list.Reward
if err := this.module.modelMoonlv.modifyMoonlvList(session.GetUserId(), update); err != nil {
this.module.Error(err.Error())
@ -94,7 +98,7 @@ func (this *apiComp) Award(session comm.IUserSession, req *pb.MoonlvAwardReq) (e
})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
// this.module.ModuleSys.CheckOpenCond(session.Clone(), comm.OpencondTypeMoonLv, list.Lv)
this.module.ModuleBuried.TriggerBuried(session, comm.GetBuriedParam(comm.Rtype242, list.Lv))
this.module.ModuleBuried.TriggerBuried(session, comm.GetBuriedParam(comm.Rtype242, list.Cid))
})
return
}

View File

@ -48,7 +48,7 @@ func (this *apiComp) TaskAward(session comm.IUserSession, req *pb.MoonlvTaskAwar
return
}
list.Tasks[req.TaskId] = 1
if conf, err = this.module.configure.GetMoonLvConf(list.Lv); err != nil {
if conf, err = this.module.configure.GetMoonLvConf(list.Cid); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),

View File

@ -68,18 +68,18 @@ func (this *configureComp) GetConfigure(name string) (v interface{}, err error)
return configure.GetConfigure(name)
}
func (this *configureComp) GetMoonLvConf(lv int32) (conf *cfg.GameMoonLvData, err error) {
func (this *configureComp) GetMoonLvConf(id int32) (conf *cfg.GameMoonLvData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(monnlv); err == nil {
if configure, ok := v.(*cfg.GameMoonLv); ok {
if conf = configure.Get(lv); conf != nil {
if conf = configure.Get(id); conf != nil {
return
}
}
}
err = comm.NewNotFoundConfErr("moonlv", monnlv, lv)
err = comm.NewNotFoundConfErr("moonlv", monnlv, id)
return
}

View File

@ -34,7 +34,7 @@ func (this *modelMoonlv) getMoonlvList(session comm.IUserSession) (result *pb.DB
if mongo.ErrNoDocuments == err {
result.Id = primitive.NewObjectID().Hex()
result.Uid = uid
result.Lv = 1 // 默认1级
result.Cid = 1 // 默认1级
result.Reward = make(map[int32]bool)
result.Tasks = make(map[int32]int32)
this.Add(uid, result)

View File

@ -26,9 +26,9 @@ type DBMoonLv struct {
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID
Tasks map[int32]int32 `protobuf:"bytes,3,rep,name=tasks,proto3" json:"tasks" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"tasks"` // 任务列表
Lv int32 `protobuf:"varint,4,opt,name=lv,proto3" json:"lv"` // 月明度等级
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` //用户ID
Tasks map[int32]int32 `protobuf:"bytes,3,rep,name=tasks,proto3" json:"tasks" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //任务列表
Cid int32 `protobuf:"varint,4,opt,name=cid,proto3" json:"cid"` //月明度配置id
Reward map[int32]bool `protobuf:"bytes,5,rep,name=reward,proto3" json:"reward" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //等级奖励
}
@ -85,9 +85,9 @@ func (x *DBMoonLv) GetTasks() map[int32]int32 {
return nil
}
func (x *DBMoonLv) GetLv() int32 {
func (x *DBMoonLv) GetCid() int32 {
if x != nil {
return x.Lv
return x.Cid
}
return 0
}
@ -103,25 +103,25 @@ var File_moonlv_moonlv_db_proto protoreflect.FileDescriptor
var file_moonlv_moonlv_db_proto_rawDesc = []byte{
0x0a, 0x16, 0x6d, 0x6f, 0x6f, 0x6e, 0x6c, 0x76, 0x2f, 0x6d, 0x6f, 0x6f, 0x6e, 0x6c, 0x76, 0x5f,
0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8c, 0x02, 0x0a, 0x08, 0x44, 0x42, 0x4d,
0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8e, 0x02, 0x0a, 0x08, 0x44, 0x42, 0x4d,
0x6f, 0x6f, 0x6e, 0x4c, 0x76, 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, 0x2a, 0x0a, 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73,
0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x4c,
0x76, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x74, 0x61,
0x73, 0x6b, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52,
0x02, 0x6c, 0x76, 0x12, 0x2d, 0x0a, 0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, 0x05, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x4c, 0x76, 0x2e, 0x52,
0x65, 0x77, 0x61, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65, 0x77, 0x61,
0x72, 0x64, 0x1a, 0x38, 0x0a, 0x0a, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79,
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b,
0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x39, 0x0a, 0x0b,
0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b,
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61,
0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x73, 0x6b, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05,
0x52, 0x03, 0x63, 0x69, 0x64, 0x12, 0x2d, 0x0a, 0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18,
0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x4c, 0x76,
0x2e, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65,
0x77, 0x61, 0x72, 0x64, 0x1a, 0x38, 0x0a, 0x0a, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x45, 0x6e, 0x74,
0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x39,
0x0a, 0x0b, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a,
0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12,
0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05,
0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70,
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -112,7 +112,7 @@ type MoonlvAwardReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Lv int32 `protobuf:"varint,1,opt,name=lv,proto3" json:"lv"`
Cid int32 `protobuf:"varint,1,opt,name=cid,proto3" json:"cid"`
}
func (x *MoonlvAwardReq) Reset() {
@ -147,9 +147,9 @@ func (*MoonlvAwardReq) Descriptor() ([]byte, []int) {
return file_moonlv_moonlv_msg_proto_rawDescGZIP(), []int{2}
}
func (x *MoonlvAwardReq) GetLv() int32 {
func (x *MoonlvAwardReq) GetCid() int32 {
if x != nil {
return x.Lv
return x.Cid
}
return 0
}
@ -331,25 +331,25 @@ var file_moonlv_moonlv_msg_proto_rawDesc = []byte{
0x71, 0x22, 0x32, 0x0a, 0x11, 0x4d, 0x6f, 0x6f, 0x6e, 0x6c, 0x76, 0x47, 0x65, 0x74, 0x4c, 0x69,
0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x4c, 0x76, 0x52,
0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x20, 0x0a, 0x0e, 0x4d, 0x6f, 0x6f, 0x6e, 0x6c, 0x76, 0x41,
0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x01, 0x20,
0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x22, 0x4d, 0x0a, 0x0f, 0x4d, 0x6f, 0x6f, 0x6e, 0x6c,
0x76, 0x41, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x04, 0x64, 0x61,
0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x44, 0x42, 0x4d, 0x6f, 0x6f,
0x6e, 0x4c, 0x76, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1b, 0x0a, 0x03, 0x72, 0x65, 0x73,
0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x74, 0x6e,
0x6f, 0x52, 0x03, 0x72, 0x65, 0x73, 0x22, 0x2c, 0x0a, 0x12, 0x4d, 0x6f, 0x6f, 0x6e, 0x6c, 0x76,
0x54, 0x61, 0x73, 0x6b, 0x41, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06,
0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61,
0x73, 0x6b, 0x49, 0x64, 0x22, 0x6f, 0x0a, 0x13, 0x4d, 0x6f, 0x6f, 0x6e, 0x6c, 0x76, 0x54, 0x61,
0x73, 0x6b, 0x41, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x74,
0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73,
0x6b, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, 0x02, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x74, 0x6e, 0x6f, 0x52, 0x06,
0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x12, 0x1d, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x4c, 0x76, 0x52,
0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x22, 0x0a, 0x0e, 0x4d, 0x6f, 0x6f, 0x6e, 0x6c, 0x76, 0x41,
0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x63, 0x69, 0x64, 0x22, 0x4d, 0x0a, 0x0f, 0x4d, 0x6f, 0x6f,
0x6e, 0x6c, 0x76, 0x41, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x04,
0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x44, 0x42, 0x4d,
0x6f, 0x6f, 0x6e, 0x4c, 0x76, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1b, 0x0a, 0x03, 0x72,
0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41,
0x74, 0x6e, 0x6f, 0x52, 0x03, 0x72, 0x65, 0x73, 0x22, 0x2c, 0x0a, 0x12, 0x4d, 0x6f, 0x6f, 0x6e,
0x6c, 0x76, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x16,
0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06,
0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, 0x6f, 0x0a, 0x13, 0x4d, 0x6f, 0x6f, 0x6e, 0x6c, 0x76,
0x54, 0x61, 0x73, 0x6b, 0x41, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a,
0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74,
0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18,
0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x74, 0x6e, 0x6f,
0x52, 0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x12, 0x1d, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61,
0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x4c,
0x76, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (