From 592503d08dbb7a1330f194b03d004d9ce2091c01 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 6 Nov 2023 10:03:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E9=A2=9C=E8=89=B2=E6=B8=B8?= =?UTF-8?q?=E6=88=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/dcolor/api_award.go | 58 ++++++++++++-------------------- modules/dcolor/api_singleover.go | 7 ++-- modules/dcolor/configure.go | 11 ++---- pb/dcolor_msg.pb.go | 26 +++----------- 4 files changed, 32 insertions(+), 70 deletions(-) diff --git a/modules/dcolor/api_award.go b/modules/dcolor/api_award.go index 37ef6a277..12211f917 100644 --- a/modules/dcolor/api_award.go +++ b/modules/dcolor/api_award.go @@ -14,17 +14,18 @@ func (this *apiComp) AwardCheck(session comm.IUserSession, req *pb.DColorAwardRe func (this *apiComp) Award(session comm.IUserSession, req *pb.DColorAwardReq) (errdata *pb.ErrorData) { var ( - info *pb.DBDColor - conf *cfg.GameGColorRewardData - atno []*pb.UserAtno - ok bool - err error + info *pb.DBDColor + confs []*cfg.GameGColorRewardData + res []*cfg.Gameatn + atno []*pb.UserAtno + ok bool + err error ) if errdata = this.AwardCheck(session, req); errdata != nil { return } - if conf, err = this.module.configure.getGameGColorRewardData(req.Id); err != nil { + if confs, err = this.module.configure.getGameGColorRewardDatas(); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Message: err.Error(), @@ -44,43 +45,27 @@ func (this *apiComp) Award(session comm.IUserSession, req *pb.DColorAwardReq) (e info.Weekaward = make(map[int32]bool) } - if _, ok = info.Weekaward[req.Id]; req.Atype == 0 && ok { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_ReqParameterError, - Message: "Weekaward Claimed!", + for _, conf := range confs { + if req.Atype == 0 && conf.Type == 1 { + if _, ok = info.Weekaward[conf.Key]; !ok && info.Integral >= conf.Condition { + res = append(res, conf.Reward...) + info.Weekaward[conf.Key] = true + } } - return - } - if _, ok = info.Allaward[req.Id]; req.Atype == 1 && ok { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_ReqParameterError, - Message: "Allaward Claimed!", + if req.Atype == 1 && conf.Type == 2 { + if _, ok = info.Allaward[conf.Key]; !ok && info.Accruedintegral >= conf.Condition { + res = append(res, conf.Reward...) + info.Allaward[conf.Key] = true + } } - return - } - if req.Atype == 0 && info.Integral < conf.Condition { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_ReqParameterError, - Message: "Integral Not enough points!", - } - return - } - if req.Atype == 0 && info.Accruedintegral < conf.Condition { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_ReqParameterError, - Message: "Accruedintegral Not enough points!", - } - return + } - if errdata, atno = this.module.DispenseAtno(session, conf.Reward, true); errdata != nil { + if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil { return } if req.Atype == 0 { - info.Weekaward[req.Id] = true info.Weektime = configure.Now().Unix() - } else { - info.Allaward[req.Id] = true } this.module.model.Change(session.GetUserId(), map[string]interface{}{ @@ -88,7 +73,6 @@ func (this *apiComp) Award(session comm.IUserSession, req *pb.DColorAwardReq) (e "allaward": info.Allaward, "weektime": info.Weektime, }) - - session.SendMsg(string(this.module.GetType()), "info", &pb.DColorAwardResp{Id: req.Id, Atype: req.Atype, Award: atno}) + session.SendMsg(string(this.module.GetType()), "award", &pb.DColorAwardResp{Atype: req.Atype, Award: atno}) return } diff --git a/modules/dcolor/api_singleover.go b/modules/dcolor/api_singleover.go index 9d33c1784..9644fafac 100644 --- a/modules/dcolor/api_singleover.go +++ b/modules/dcolor/api_singleover.go @@ -17,6 +17,7 @@ func (this *apiComp) SingleOverCheck(session comm.IUserSession, req *pb.DColorSi func (this *apiComp) SingleOver(session comm.IUserSession, req *pb.DColorSingleOverReq) (errdata *pb.ErrorData) { var ( info *pb.DBDColor + score int32 conf *cfg.GameGColorGetfractionData tconf *cfg.GameGColortTmedecayData err error @@ -45,8 +46,8 @@ func (this *apiComp) SingleOver(session comm.IUserSession, req *pb.DColorSingleO } return } - - info.Integral += int32(math.Floor(float64(conf.Fraction) * float64(tconf.Pro) / float64(1000))) + score = int32(math.Floor(float64(conf.Fraction) * float64(tconf.Pro) / float64(1000))) + info.Integral += score if err = this.module.model.Change(session.GetUserId(), map[string]interface{}{ "integral": info.Integral, }); err != nil { @@ -56,6 +57,6 @@ func (this *apiComp) SingleOver(session comm.IUserSession, req *pb.DColorSingleO } return } - session.SendMsg(string(this.module.GetType()), "singleover", &pb.DColorSingleOverResp{Integral: info.Integral}) + session.SendMsg(string(this.module.GetType()), "singleover", &pb.DColorSingleOverResp{Integral: score}) return } diff --git a/modules/dcolor/configure.go b/modules/dcolor/configure.go index 70ab62486..b7e671b9d 100644 --- a/modules/dcolor/configure.go +++ b/modules/dcolor/configure.go @@ -115,18 +115,13 @@ func (this *configureComp) getGameGColortTmedecayData(time int32) (conf *cfg.Gam } // 获取奖励列表 -func (this *configureComp) getGameGColorRewardData(id int32) (conf *cfg.GameGColorRewardData, err error) { +func (this *configureComp) getGameGColorRewardDatas() (confs []*cfg.GameGColorRewardData, err error) { var ( - v interface{} - ok bool + v interface{} ) if v, err = this.GetConfigure(game_gcolorreward); err != nil { return } - if conf, ok = v.(*cfg.GameGColorReward).GetDataMap()[id]; !ok { - err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_gcolorreward, id) - this.module.Errorln(err) - return - } + confs = v.(*cfg.GameGColorReward).GetDataList() return } diff --git a/pb/dcolor_msg.pb.go b/pb/dcolor_msg.pb.go index 3338deac7..259a39f22 100644 --- a/pb/dcolor_msg.pb.go +++ b/pb/dcolor_msg.pb.go @@ -1178,7 +1178,6 @@ type DColorAwardReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id"` Atype int32 `protobuf:"varint,2,opt,name=atype,proto3" json:"atype"` //0 周奖励 1 累计奖励 } @@ -1214,13 +1213,6 @@ func (*DColorAwardReq) Descriptor() ([]byte, []int) { return file_dcolor_dcolor_msg_proto_rawDescGZIP(), []int{21} } -func (x *DColorAwardReq) GetId() int32 { - if x != nil { - return x.Id - } - return 0 -} - func (x *DColorAwardReq) GetAtype() int32 { if x != nil { return x.Atype @@ -1233,7 +1225,6 @@ type DColorAwardResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id"` Atype int32 `protobuf:"varint,2,opt,name=atype,proto3" json:"atype"` //0 周奖励 1 累计奖励 Award []*UserAtno `protobuf:"bytes,3,rep,name=award,proto3" json:"award"` //获取资源 } @@ -1270,13 +1261,6 @@ func (*DColorAwardResp) Descriptor() ([]byte, []int) { return file_dcolor_dcolor_msg_proto_rawDescGZIP(), []int{22} } -func (x *DColorAwardResp) GetId() int32 { - if x != nil { - return x.Id - } - return 0 -} - func (x *DColorAwardResp) GetAtype() int32 { if x != nil { return x.Atype @@ -1398,13 +1382,11 @@ var file_dcolor_dcolor_msg_proto_rawDesc = []byte{ 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x72, 0x65, 0x64, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x12, 0x22, 0x0a, 0x0c, 0x62, 0x6c, 0x75, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x62, 0x6c, 0x75, 0x65, - 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x22, 0x36, 0x0a, 0x0e, 0x44, 0x43, 0x6f, 0x6c, - 0x6f, 0x72, 0x41, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x74, + 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x22, 0x26, 0x0a, 0x0e, 0x44, 0x43, 0x6f, 0x6c, + 0x6f, 0x72, 0x41, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x61, 0x74, 0x79, 0x70, 0x65, - 0x22, 0x58, 0x0a, 0x0f, 0x44, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x41, 0x77, 0x61, 0x72, 0x64, 0x52, - 0x65, 0x73, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x22, 0x48, 0x0a, 0x0f, 0x44, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x41, 0x77, 0x61, 0x72, 0x64, 0x52, + 0x65, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x61, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x74, 0x6e, 0x6f, 0x52, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b,