接龙奖励改一键领取

This commit is contained in:
meixiongfeng 2023-10-17 10:58:27 +08:00
parent 083ed3c371
commit cfbe3558bc
2 changed files with 47 additions and 56 deletions

View File

@ -3,16 +3,12 @@ package jielong
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
)
// 参数校验
func (this *apiComp) RewardCheck(session comm.IUserSession, req *pb.JielongRewardReq) (errdata *pb.ErrorData) {
if req.Rewardkey == 0 {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
}
return
}
@ -21,6 +17,8 @@ func (this *apiComp) Reward(session comm.IUserSession, req *pb.JielongRewardReq)
list *pb.DBJielongData
err error
update map[string]interface{}
res []*cfg.Gameatn // 奖励
atno []*pb.UserAtno
)
update = make(map[string]interface{}, 0)
if errdata = this.RewardCheck(session, req); errdata != nil {
@ -37,13 +35,7 @@ func (this *apiComp) Reward(session comm.IUserSession, req *pb.JielongRewardReq)
return
}
if req.Cur {
if _, ok := list.Reward[req.Rewardkey]; ok {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_UserRepeadReward,
Title: pb.ErrorCode_UserRepeadReward.ToString(),
}
return
}
if c, e := this.module.configure.getGameFastDataByType(1); e != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
@ -51,24 +43,18 @@ func (this *apiComp) Reward(session comm.IUserSession, req *pb.JielongRewardReq)
}
return
} else {
if _, ok := c[req.Rewardkey]; !ok {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
for _, v := range c {
if list.Wincount >= v.Condition {
if _, ok := c[v.Condition]; !ok {
res = append(res, v.Reward...)
list.Reward[v.Condition] = 1
}
}
return
}
update["reward"] = list.Reward
}
list.Reward[req.Rewardkey] = 1
update["reward"] = list.Reward
} else {
if _, ok := list.Gotarr[req.Rewardkey]; ok {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_UserRepeadReward,
Title: pb.ErrorCode_UserRepeadReward.ToString(),
}
return
}
if c, e := this.module.configure.getGameFastDataByType(2); e != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
@ -76,18 +62,33 @@ func (this *apiComp) Reward(session comm.IUserSession, req *pb.JielongRewardReq)
}
return
} else {
if _, ok := c[req.Rewardkey]; !ok {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
for _, v := range c {
if list.Hisotry >= v.Condition {
if _, ok := c[v.Condition]; !ok {
res = append(res, v.Reward...)
list.Gotarr[v.Condition] = 1
}
}
return
}
update["gotarr"] = list.Gotarr
}
list.Gotarr[req.Rewardkey] = 1
update["gotarr"] = list.Gotarr
}
if len(res) > 0 {
errdata, atno = this.module.DispenseAtno(session, res, true)
if errdata != nil {
return
}
} else { // 没有奖励可以领取
errdata = &pb.ErrorData{
Code: pb.ErrorCode_UserRepeadReward,
Title: pb.ErrorCode_UserRepeadReward.ToString(),
}
return
}
this.module.modelJielong.changeJielongData(session.GetUserId(), update)
session.SendMsg(string(this.module.GetType()), "reward", &pb.JielongRewardResp{})
session.SendMsg(string(this.module.GetType()), "reward", &pb.JielongRewardResp{
Data: list,
Res: atno,
})
return
}

View File

@ -205,8 +205,7 @@ type JielongRewardReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Cur bool `protobuf:"varint,1,opt,name=cur,proto3" json:"cur"` // 0 本周奖励 1 历史奖励
Rewardkey int32 `protobuf:"varint,2,opt,name=rewardkey,proto3" json:"rewardkey"` // 奖励key
Cur bool `protobuf:"varint,1,opt,name=cur,proto3" json:"cur"` // 0 本周奖励 1 历史奖励
}
func (x *JielongRewardReq) Reset() {
@ -248,20 +247,13 @@ func (x *JielongRewardReq) GetCur() bool {
return false
}
func (x *JielongRewardReq) GetRewardkey() int32 {
if x != nil {
return x.Rewardkey
}
return 0
}
type JielongRewardResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data *DBJielongData `protobuf:"bytes,1,opt,name=data,proto3" json:"data"`
Res *UserAtno `protobuf:"bytes,2,opt,name=res,proto3" json:"res"`
Res []*UserAtno `protobuf:"bytes,2,rep,name=res,proto3" json:"res"`
}
func (x *JielongRewardResp) Reset() {
@ -303,7 +295,7 @@ func (x *JielongRewardResp) GetData() *DBJielongData {
return nil
}
func (x *JielongRewardResp) GetRes() *UserAtno {
func (x *JielongRewardResp) GetRes() []*UserAtno {
if x != nil {
return x.Res
}
@ -328,17 +320,15 @@ var file_jielong_jielong_msg_proto_rawDesc = []byte{
0x6f, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x22, 0x0a,
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42,
0x4a, 0x69, 0x65, 0x6c, 0x6f, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74,
0x61, 0x22, 0x42, 0x0a, 0x10, 0x4a, 0x69, 0x65, 0x6c, 0x6f, 0x6e, 0x67, 0x52, 0x65, 0x77, 0x61,
0x61, 0x22, 0x24, 0x0a, 0x10, 0x4a, 0x69, 0x65, 0x6c, 0x6f, 0x6e, 0x67, 0x52, 0x65, 0x77, 0x61,
0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x75, 0x72, 0x18, 0x01, 0x20, 0x01,
0x28, 0x08, 0x52, 0x03, 0x63, 0x75, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x77, 0x61, 0x72,
0x64, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x72, 0x65, 0x77, 0x61,
0x72, 0x64, 0x6b, 0x65, 0x79, 0x22, 0x54, 0x0a, 0x11, 0x4a, 0x69, 0x65, 0x6c, 0x6f, 0x6e, 0x67,
0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x22, 0x0a, 0x04, 0x64, 0x61,
0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42, 0x4a, 0x69, 0x65,
0x6c, 0x6f, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1b,
0x0a, 0x03, 0x72, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x55, 0x73,
0x65, 0x72, 0x41, 0x74, 0x6e, 0x6f, 0x52, 0x03, 0x72, 0x65, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e,
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x28, 0x08, 0x52, 0x03, 0x63, 0x75, 0x72, 0x22, 0x54, 0x0a, 0x11, 0x4a, 0x69, 0x65, 0x6c, 0x6f,
0x6e, 0x67, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x22, 0x0a, 0x04,
0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42, 0x4a,
0x69, 0x65, 0x6c, 0x6f, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 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, 0x42, 0x06, 0x5a,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (