上传颜色游戏

This commit is contained in:
liwei1dao 2023-11-06 10:03:20 +08:00
parent 8ad90274dd
commit 592503d08d
4 changed files with 32 additions and 70 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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,