章节宝箱领取

This commit is contained in:
meixiongfeng 2023-01-06 16:04:12 +08:00
parent 31a2973f36
commit 32fe177428
3 changed files with 88 additions and 33 deletions

View File

@ -50,7 +50,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MlineChallenge
ChapterId: stageConf.Chapterid,
StageId: stageConf.Id,
Star: map[int32]int32{},
Awared: map[int32]bool{},
Award: map[int32]bool{},
Ps: map[int32]int32{},
}
this.module.modelMline.addNewChapter(session.GetUserId(), newData)

View File

@ -3,6 +3,7 @@ package mline
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"google.golang.org/protobuf/proto"
)
@ -15,8 +16,62 @@ func (this *apiComp) GetRewardCheck(session comm.IUserSession, req *pb.MlineGetR
return
}
///获取主线关卡信息
// 领取奖励
func (this *apiComp) GetReward(session comm.IUserSession, req *pb.MlineGetRewardReq) (code pb.ErrorCode, data proto.Message) {
var (
curChapter *pb.DBMline // 当前章节信息
stageConf *cfg.GameMainStageData
update map[string]interface{}
rsp *pb.MlineGetRewardResp
)
update = make(map[string]interface{})
if code = this.GetRewardCheck(session, req); code != pb.ErrorCode_Success {
return
}
if stageConf = this.module.configure.GetMainStageConf(req.CId); stageConf == nil { // 配置文件校验
code = pb.ErrorCode_MainlineNotFindChapter
return
}
mLineConf := this.module.configure.GetMainChapterConf(stageConf.Chapterid)
if mLineConf == nil {
code = pb.ErrorCode_ConfigNoFound
return
}
list, _ := this.module.modelMline.getMainlineList(session.GetUserId())
for _, v := range list {
if stageConf.Chapterid == v.ChapterId {
curChapter = v
break
}
}
if curChapter == nil {
code = pb.ErrorCode_MainlineNotFindChapter
return
}
if b, ok := curChapter.Award[req.Star]; ok && b { // 重复领奖
code = pb.ErrorCode_MainlineRepeatReward
return
}
curChapter.Award[req.Star] = true
update["awared"] = curChapter.Award
awardConf := this.module.configure.GetMainStarRewardConf(mLineConf.Starreward)
for _, v := range awardConf {
if v.Starnum == req.Star {
if code = this.module.DispenseRes(session, v.Reward, true); code != pb.ErrorCode_Success {
return
}
for _, v := range v.Reward {
rsp.Reward = append(rsp.Reward, &pb.UserAssets{
A: v.A,
T: v.T,
N: v.N,
})
}
}
}
rsp.Data = curChapter
this.module.modelMline.modifyMlineData(session.GetUserId(), curChapter.Id, update)
session.SendMsg(string(this.module.GetType()), MlineGetRewardResp, rsp) // 数据推送
return
}

View File

@ -31,7 +31,7 @@ type DBMline struct {
ChapterId int32 `protobuf:"varint,4,opt,name=chapterId,proto3" json:"chapterId" bson:"chapterId"` //章节ID
StageId int32 `protobuf:"varint,5,opt,name=stageId,proto3" json:"stageId" bson:"stageId"` //主线关卡ID
Star map[int32]int32 `protobuf:"bytes,6,rep,name=star,proto3" json:"star" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 关卡对应的星级 (key 关卡ID value 星数)
Awared map[int32]bool `protobuf:"bytes,7,rep,name=awared,proto3" json:"awared" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"awared"` //(key 配置表星级)
Award map[int32]bool `protobuf:"bytes,7,rep,name=award,proto3" json:"award" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"award"` //(key 配置表星级)
Ps map[int32]int32 `protobuf:"bytes,8,rep,name=ps,proto3" json:"ps" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 预扣的体力
}
@ -109,9 +109,9 @@ func (x *DBMline) GetStar() map[int32]int32 {
return nil
}
func (x *DBMline) GetAwared() map[int32]bool {
func (x *DBMline) GetAward() map[int32]bool {
if x != nil {
return x.Awared
return x.Award
}
return nil
}
@ -127,7 +127,7 @@ var File_mline_mline_db_proto protoreflect.FileDescriptor
var file_mline_mline_db_proto_rawDesc = []byte{
0x0a, 0x14, 0x6d, 0x6c, 0x69, 0x6e, 0x65, 0x2f, 0x6d, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x64, 0x62,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9c, 0x03, 0x0a, 0x07, 0x44, 0x42, 0x4d, 0x6c, 0x69,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x98, 0x03, 0x0a, 0x07, 0x44, 0x42, 0x4d, 0x6c, 0x69,
0x6e, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02,
0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x03, 0x75, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20,
@ -137,24 +137,24 @@ var file_mline_mline_db_proto_rawDesc = []byte{
0x65, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x73, 0x74, 0x61, 0x67, 0x65,
0x49, 0x64, 0x12, 0x26, 0x0a, 0x04, 0x73, 0x74, 0x61, 0x72, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x12, 0x2e, 0x44, 0x42, 0x4d, 0x6c, 0x69, 0x6e, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x45,
0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x73, 0x74, 0x61, 0x72, 0x12, 0x2c, 0x0a, 0x06, 0x61, 0x77,
0x61, 0x72, 0x65, 0x64, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x44, 0x42, 0x4d,
0x6c, 0x69, 0x6e, 0x65, 0x2e, 0x41, 0x77, 0x61, 0x72, 0x65, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79,
0x52, 0x06, 0x61, 0x77, 0x61, 0x72, 0x65, 0x64, 0x12, 0x20, 0x0a, 0x02, 0x70, 0x73, 0x18, 0x08,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x44, 0x42, 0x4d, 0x6c, 0x69, 0x6e, 0x65, 0x2e, 0x50,
0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x02, 0x70, 0x73, 0x1a, 0x37, 0x0a, 0x09, 0x53, 0x74,
0x61, 0x72, 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, 0x41, 0x77, 0x61, 0x72, 0x65, 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, 0x1a, 0x35,
0x0a, 0x07, 0x50, 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, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x73, 0x74, 0x61, 0x72, 0x12, 0x29, 0x0a, 0x05, 0x61, 0x77,
0x61, 0x72, 0x64, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x44, 0x42, 0x4d, 0x6c,
0x69, 0x6e, 0x65, 0x2e, 0x41, 0x77, 0x61, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05,
0x61, 0x77, 0x61, 0x72, 0x64, 0x12, 0x20, 0x0a, 0x02, 0x70, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x10, 0x2e, 0x44, 0x42, 0x4d, 0x6c, 0x69, 0x6e, 0x65, 0x2e, 0x50, 0x73, 0x45, 0x6e,
0x74, 0x72, 0x79, 0x52, 0x02, 0x70, 0x73, 0x1a, 0x37, 0x0a, 0x09, 0x53, 0x74, 0x61, 0x72, 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, 0x38, 0x0a, 0x0a, 0x41, 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, 0x1a, 0x35, 0x0a, 0x07, 0x50, 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, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
}
var (
@ -173,12 +173,12 @@ var file_mline_mline_db_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_mline_mline_db_proto_goTypes = []interface{}{
(*DBMline)(nil), // 0: DBMline
nil, // 1: DBMline.StarEntry
nil, // 2: DBMline.AwaredEntry
nil, // 2: DBMline.AwardEntry
nil, // 3: DBMline.PsEntry
}
var file_mline_mline_db_proto_depIdxs = []int32{
1, // 0: DBMline.star:type_name -> DBMline.StarEntry
2, // 1: DBMline.awared:type_name -> DBMline.AwaredEntry
2, // 1: DBMline.award:type_name -> DBMline.AwardEntry
3, // 2: DBMline.ps:type_name -> DBMline.PsEntry
3, // [3:3] is the sub-list for method output_type
3, // [3:3] is the sub-list for method input_type