上传颜色游戏
This commit is contained in:
parent
8ad90274dd
commit
592503d08d
@ -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) {
|
func (this *apiComp) Award(session comm.IUserSession, req *pb.DColorAwardReq) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
info *pb.DBDColor
|
info *pb.DBDColor
|
||||||
conf *cfg.GameGColorRewardData
|
confs []*cfg.GameGColorRewardData
|
||||||
atno []*pb.UserAtno
|
res []*cfg.Gameatn
|
||||||
ok bool
|
atno []*pb.UserAtno
|
||||||
err error
|
ok bool
|
||||||
|
err error
|
||||||
)
|
)
|
||||||
if errdata = this.AwardCheck(session, req); errdata != nil {
|
if errdata = this.AwardCheck(session, req); errdata != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if conf, err = this.module.configure.getGameGColorRewardData(req.Id); err != nil {
|
if confs, err = this.module.configure.getGameGColorRewardDatas(); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_ConfigNoFound,
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
Message: err.Error(),
|
Message: err.Error(),
|
||||||
@ -44,43 +45,27 @@ func (this *apiComp) Award(session comm.IUserSession, req *pb.DColorAwardReq) (e
|
|||||||
info.Weekaward = make(map[int32]bool)
|
info.Weekaward = make(map[int32]bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok = info.Weekaward[req.Id]; req.Atype == 0 && ok {
|
for _, conf := range confs {
|
||||||
errdata = &pb.ErrorData{
|
if req.Atype == 0 && conf.Type == 1 {
|
||||||
Code: pb.ErrorCode_ReqParameterError,
|
if _, ok = info.Weekaward[conf.Key]; !ok && info.Integral >= conf.Condition {
|
||||||
Message: "Weekaward Claimed!",
|
res = append(res, conf.Reward...)
|
||||||
|
info.Weekaward[conf.Key] = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
if req.Atype == 1 && conf.Type == 2 {
|
||||||
}
|
if _, ok = info.Allaward[conf.Key]; !ok && info.Accruedintegral >= conf.Condition {
|
||||||
if _, ok = info.Allaward[req.Id]; req.Atype == 1 && ok {
|
res = append(res, conf.Reward...)
|
||||||
errdata = &pb.ErrorData{
|
info.Allaward[conf.Key] = true
|
||||||
Code: pb.ErrorCode_ReqParameterError,
|
}
|
||||||
Message: "Allaward Claimed!",
|
|
||||||
}
|
}
|
||||||
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
|
return
|
||||||
}
|
}
|
||||||
if req.Atype == 0 {
|
if req.Atype == 0 {
|
||||||
info.Weekaward[req.Id] = true
|
|
||||||
info.Weektime = configure.Now().Unix()
|
info.Weektime = configure.Now().Unix()
|
||||||
} else {
|
|
||||||
info.Allaward[req.Id] = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.module.model.Change(session.GetUserId(), map[string]interface{}{
|
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,
|
"allaward": info.Allaward,
|
||||||
"weektime": info.Weektime,
|
"weektime": info.Weektime,
|
||||||
})
|
})
|
||||||
|
session.SendMsg(string(this.module.GetType()), "award", &pb.DColorAwardResp{Atype: req.Atype, Award: atno})
|
||||||
session.SendMsg(string(this.module.GetType()), "info", &pb.DColorAwardResp{Id: req.Id, Atype: req.Atype, Award: atno})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
func (this *apiComp) SingleOver(session comm.IUserSession, req *pb.DColorSingleOverReq) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
info *pb.DBDColor
|
info *pb.DBDColor
|
||||||
|
score int32
|
||||||
conf *cfg.GameGColorGetfractionData
|
conf *cfg.GameGColorGetfractionData
|
||||||
tconf *cfg.GameGColortTmedecayData
|
tconf *cfg.GameGColortTmedecayData
|
||||||
err error
|
err error
|
||||||
@ -45,8 +46,8 @@ func (this *apiComp) SingleOver(session comm.IUserSession, req *pb.DColorSingleO
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
score = int32(math.Floor(float64(conf.Fraction) * float64(tconf.Pro) / float64(1000)))
|
||||||
info.Integral += 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{}{
|
if err = this.module.model.Change(session.GetUserId(), map[string]interface{}{
|
||||||
"integral": info.Integral,
|
"integral": info.Integral,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@ -56,6 +57,6 @@ func (this *apiComp) SingleOver(session comm.IUserSession, req *pb.DColorSingleO
|
|||||||
}
|
}
|
||||||
return
|
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
|
return
|
||||||
}
|
}
|
||||||
|
@ -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 (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
ok bool
|
|
||||||
)
|
)
|
||||||
if v, err = this.GetConfigure(game_gcolorreward); err != nil {
|
if v, err = this.GetConfigure(game_gcolorreward); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if conf, ok = v.(*cfg.GameGColorReward).GetDataMap()[id]; !ok {
|
confs = v.(*cfg.GameGColorReward).GetDataList()
|
||||||
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_gcolorreward, id)
|
|
||||||
this.module.Errorln(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1178,7 +1178,6 @@ type DColorAwardReq struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
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 累计奖励
|
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}
|
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 {
|
func (x *DColorAwardReq) GetAtype() int32 {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Atype
|
return x.Atype
|
||||||
@ -1233,7 +1225,6 @@ type DColorAwardResp struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
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 累计奖励
|
Atype int32 `protobuf:"varint,2,opt,name=atype,proto3" json:"atype"` //0 周奖励 1 累计奖励
|
||||||
Award []*UserAtno `protobuf:"bytes,3,rep,name=award,proto3" json:"award"` //获取资源
|
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}
|
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 {
|
func (x *DColorAwardResp) GetAtype() int32 {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Atype
|
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,
|
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, 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,
|
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,
|
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, 0x0e, 0x0a, 0x02, 0x69, 0x64,
|
0x6f, 0x72, 0x41, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x74,
|
||||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x74,
|
|
||||||
0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x61, 0x74, 0x79, 0x70, 0x65,
|
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,
|
0x22, 0x48, 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,
|
0x65, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01,
|
||||||
0x02, 0x69, 0x64, 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,
|
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,
|
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,
|
0x74, 0x6e, 0x6f, 0x52, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b,
|
||||||
|
Loading…
Reference in New Issue
Block a user