This commit is contained in:
liwei1dao 2023-03-29 10:49:04 +08:00
commit eab92a1205
3 changed files with 93 additions and 62 deletions

View File

@ -9,40 +9,41 @@ import (
//参数校验 //参数校验
func (this *apiComp) ActivateCheck(session comm.IUserSession, req *pb.AtlasActivateReq) (code pb.ErrorCode) { func (this *apiComp) ActivateCheck(session comm.IUserSession, req *pb.AtlasActivateReq) (code pb.ErrorCode) {
if req.Id == "" {
code = pb.ErrorCode_ReqParameterError
}
return return
} }
// 激活图鉴信息 // 一键激活所有激活图鉴信息
func (this *apiComp) Activate(session comm.IUserSession, req *pb.AtlasActivateReq) (code pb.ErrorCode, data proto.Message) { func (this *apiComp) Activate(session comm.IUserSession, req *pb.AtlasActivateReq) (code pb.ErrorCode, data proto.Message) {
var (
bUpdate bool
)
if code = this.ActivateCheck(session, req); code != pb.ErrorCode_Success { if code = this.ActivateCheck(session, req); code != pb.ErrorCode_Success {
return return
} }
atlasConf := this.module.configure.GetPandoAtlasConf(req.Id)
if atlasConf == nil {
code = pb.ErrorCode_ReqParameterError
return
}
list, _ := this.module.modelPandaAtlas.getPandaAtlasList(session.GetUserId()) list, _ := this.module.modelPandaAtlas.getPandaAtlasList(session.GetUserId())
if v, ok := list.Collect[req.Id]; ok { for k, v := range list.Collect {
if !v.Activate { if !v.Activate {
update := make(map[string]interface{})
v.Activate = true // 找到图鉴积分 并更新积分 v.Activate = true // 找到图鉴积分 并更新积分
if atlasConf := this.module.configure.GetPandoAtlasConf(k); atlasConf != nil {
list.Score += atlasConf.AtlasScore list.Score += atlasConf.AtlasScore
bUpdate = true
}
}
}
if bUpdate { // 更新数据
update := make(map[string]interface{})
update["collect"] = list.Collect update["collect"] = list.Collect
update["score"] = list.Score update["score"] = list.Score
this.module.modelPandaAtlas.modifyPandaAtlasList(session.GetUserId(), update) this.module.modelPandaAtlas.modifyPandaAtlasList(session.GetUserId(), update)
} else {
code = pb.ErrorCode_MartialhallAtlasError
}
session.SendMsg(string(this.module.GetType()), "activate", &pb.AtlasActivateResp{ session.SendMsg(string(this.module.GetType()), "activate", &pb.AtlasActivateResp{
Data: list, Data: list,
}) })
return return
} else {
code = pb.ErrorCode_SmithyNoActivateAtlas
}
}
code = pb.ErrorCode_SmithyNoFoundAtlas
return
} }

View File

@ -3,6 +3,7 @@ package atlas
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@ -13,27 +14,52 @@ func (this *apiComp) AwardCheck(session comm.IUserSession, req *pb.AtlasAwardReq
return return
} }
// 获取铁匠铺图鉴信息 // 一键领取所有可以领取的奖励
func (this *apiComp) Award(session comm.IUserSession, req *pb.AtlasAwardReq) (code pb.ErrorCode, data proto.Message) { func (this *apiComp) Award(session comm.IUserSession, req *pb.AtlasAwardReq) (code pb.ErrorCode, data proto.Message) {
var (
res []*cfg.Gameatn
respRes []*pb.UserAssets
)
list, _ := this.module.modelPandaAtlas.getPandaAtlasList(session.GetUserId()) list, _ := this.module.modelPandaAtlas.getPandaAtlasList(session.GetUserId())
for {
conf := this.module.configure.GetPandoAtlasAwardConf(list.Award + 1) conf := this.module.configure.GetPandoAtlasAwardConf(list.Award + 1)
if conf == nil { if conf == nil {
code = pb.ErrorCode_SmithyAtlasMaxLv break
return
} }
// 校验积分够不够 if list.Score < conf.AtlasScore { // 校验积分够不够
if list.Score < conf.AtlasScore { break
code = pb.ErrorCode_SmithyAtlasLackLv
return
} }
this.module.DispenseRes(session, conf.ItemId, true)
update := make(map[string]interface{})
list.Award += 1 list.Award += 1
res = append(res, conf.ItemId...)
}
if len(res) == 0 { // 没有奖励可领取
code = pb.ErrorCode_MartialhallAtlasNoReward
return
}
this.module.DispenseRes(session, res, true)
for _, v := range res {
for _, v1 := range respRes {
bFind := false
if v1.A == v.A && v1.T == v.T {
v1.N += v.N
bFind = true
}
if !bFind {
respRes = append(respRes, &pb.UserAssets{
A: v.A,
T: v.T,
N: v.N,
})
}
}
}
update := make(map[string]interface{})
update["award"] = list.Award update["award"] = list.Award
this.module.modelPandaAtlas.modifyPandaAtlasList(session.GetUserId(), update) this.module.modelPandaAtlas.modifyPandaAtlasList(session.GetUserId(), update)
session.SendMsg(string(this.module.GetType()), "award", &pb.AtlasAwardResp{ session.SendMsg(string(this.module.GetType()), "award", &pb.AtlasAwardResp{
Data: list, Data: list,
Res: respRes,
}) })
return return
} }

View File

@ -111,8 +111,6 @@ type AtlasActivateReq struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"` // 图鉴ID
} }
func (x *AtlasActivateReq) Reset() { func (x *AtlasActivateReq) Reset() {
@ -147,13 +145,6 @@ func (*AtlasActivateReq) Descriptor() ([]byte, []int) {
return file_atlas_atlas_msg_proto_rawDescGZIP(), []int{2} return file_atlas_atlas_msg_proto_rawDescGZIP(), []int{2}
} }
func (x *AtlasActivateReq) GetId() string {
if x != nil {
return x.Id
}
return ""
}
type AtlasActivateResp struct { type AtlasActivateResp struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@ -246,6 +237,7 @@ type AtlasAwardResp struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Data *DBPandaAtlas `protobuf:"bytes,1,opt,name=data,proto3" json:"data"` // 奖励信息 Data *DBPandaAtlas `protobuf:"bytes,1,opt,name=data,proto3" json:"data"` // 奖励信息
Res []*UserAssets `protobuf:"bytes,2,rep,name=res,proto3" json:"res"` // 获得的奖励
} }
func (x *AtlasAwardResp) Reset() { func (x *AtlasAwardResp) Reset() {
@ -287,28 +279,37 @@ func (x *AtlasAwardResp) GetData() *DBPandaAtlas {
return nil return nil
} }
func (x *AtlasAwardResp) GetRes() []*UserAssets {
if x != nil {
return x.Res
}
return nil
}
var File_atlas_atlas_msg_proto protoreflect.FileDescriptor var File_atlas_atlas_msg_proto protoreflect.FileDescriptor
var file_atlas_atlas_msg_proto_rawDesc = []byte{ var file_atlas_atlas_msg_proto_rawDesc = []byte{
0x0a, 0x15, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2f, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x5f, 0x6d, 0x73, 0x0a, 0x15, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2f, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x5f, 0x6d, 0x73,
0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2f, 0x61, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2f, 0x61,
0x74, 0x6c, 0x61, 0x73, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x11, 0x0a, 0x74, 0x6c, 0x61, 0x73, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0a, 0x63,
0x0f, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x11, 0x0a, 0x0f, 0x41, 0x74, 0x6c,
0x22, 0x35, 0x0a, 0x10, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x61, 0x73, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, 0x35, 0x0a, 0x10,
0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70,
0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x6e, 0x64, 0x61, 0x41, 0x74, 0x6c, 0x61,
0x73, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x22, 0x0a, 0x10, 0x41, 0x74, 0x6c, 0x61, 0x73,
0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x69,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x36, 0x0a, 0x11, 0x41,
0x74, 0x6c, 0x61, 0x73, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70,
0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d,
0x2e, 0x44, 0x42, 0x50, 0x61, 0x6e, 0x64, 0x61, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x52, 0x04, 0x64, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x6e, 0x64, 0x61, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x52, 0x04, 0x64,
0x61, 0x74, 0x61, 0x22, 0x0f, 0x0a, 0x0d, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x41, 0x77, 0x61, 0x72, 0x61, 0x74, 0x61, 0x22, 0x12, 0x0a, 0x10, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x41, 0x63, 0x74, 0x69,
0x64, 0x52, 0x65, 0x71, 0x22, 0x33, 0x0a, 0x0e, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x41, 0x77, 0x61, 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x22, 0x36, 0x0a, 0x11, 0x41, 0x74, 0x6c, 0x61, 0x73,
0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x04,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x6e, 0x64, 0x61, 0x41, 0x74, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x50,
0x6c, 0x61, 0x73, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x61, 0x6e, 0x64, 0x61, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22,
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x0f, 0x0a, 0x0d, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x41, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71,
0x22, 0x52, 0x0a, 0x0e, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x41, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65,
0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x0d, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x6e, 0x64, 0x61, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x52,
0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1d, 0x0a, 0x03, 0x72, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03,
0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52,
0x03, 0x72, 0x65, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -332,16 +333,18 @@ var file_atlas_atlas_msg_proto_goTypes = []interface{}{
(*AtlasAwardReq)(nil), // 4: AtlasAwardReq (*AtlasAwardReq)(nil), // 4: AtlasAwardReq
(*AtlasAwardResp)(nil), // 5: AtlasAwardResp (*AtlasAwardResp)(nil), // 5: AtlasAwardResp
(*DBPandaAtlas)(nil), // 6: DBPandaAtlas (*DBPandaAtlas)(nil), // 6: DBPandaAtlas
(*UserAssets)(nil), // 7: UserAssets
} }
var file_atlas_atlas_msg_proto_depIdxs = []int32{ var file_atlas_atlas_msg_proto_depIdxs = []int32{
6, // 0: AtlasGetListResp.data:type_name -> DBPandaAtlas 6, // 0: AtlasGetListResp.data:type_name -> DBPandaAtlas
6, // 1: AtlasActivateResp.data:type_name -> DBPandaAtlas 6, // 1: AtlasActivateResp.data:type_name -> DBPandaAtlas
6, // 2: AtlasAwardResp.data:type_name -> DBPandaAtlas 6, // 2: AtlasAwardResp.data:type_name -> DBPandaAtlas
3, // [3:3] is the sub-list for method output_type 7, // 3: AtlasAwardResp.res:type_name -> UserAssets
3, // [3:3] is the sub-list for method input_type 4, // [4:4] is the sub-list for method output_type
3, // [3:3] is the sub-list for extension type_name 4, // [4:4] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension extendee 4, // [4:4] is the sub-list for extension type_name
0, // [0:3] is the sub-list for field type_name 4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
} }
func init() { file_atlas_atlas_msg_proto_init() } func init() { file_atlas_atlas_msg_proto_init() }
@ -350,6 +353,7 @@ func file_atlas_atlas_msg_proto_init() {
return return
} }
file_atlas_atlas_db_proto_init() file_atlas_atlas_db_proto_init()
file_comm_proto_init()
if !protoimpl.UnsafeEnabled { if !protoimpl.UnsafeEnabled {
file_atlas_atlas_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { file_atlas_atlas_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AtlasGetListReq); i { switch v := v.(*AtlasGetListReq); i {