上传小游戏红点
This commit is contained in:
parent
667f0fd694
commit
2750f4c4c9
@ -733,6 +733,10 @@ const (
|
||||
Reddot19109 ReddotType = 19109 // 当存在好感度羁绊可以激活的时候
|
||||
Reddot19110 ReddotType = 19110 // 当存在好感度羁绊可以升级的时候,好感度羁绊界面激活
|
||||
|
||||
//猜颜色
|
||||
Reddot39101 ReddotType = 39101 //猜颜色奖励可领取
|
||||
//捉虫子
|
||||
Reddot41101 ReddotType = 41101 //捉虫子奖励可领取
|
||||
// 主线
|
||||
Reddot24101 ReddotType = 24101 // 主线章节有奖励没领取
|
||||
// 好友
|
||||
|
@ -707,6 +707,7 @@ type (
|
||||
}
|
||||
//游戏邀请
|
||||
IDColor interface {
|
||||
IGetReddot
|
||||
CreateRoom(sessions []IUserSession, rulesStr string) (roomid string, err error)
|
||||
UserOffline(roomid string, uid string) (err error)
|
||||
//主动认输
|
||||
@ -738,6 +739,7 @@ type (
|
||||
}
|
||||
//捉虫子
|
||||
ICatchBugs interface {
|
||||
IGetReddot
|
||||
CreateRoom(sessions []IUserSession, rulesStr string) (roomid string, err error)
|
||||
//用户离线
|
||||
UserOffline(roomid string, uid string) (err error)
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/db"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
@ -45,3 +46,32 @@ func (this *modelComp) getModel(uid string) (info *pb.DBCatchBugs, err error) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 获取用户全部的埋点数据
|
||||
func (this *modelComp) getCorssModel(uid string) (info *pb.DBCatchBugs, err error) {
|
||||
var (
|
||||
model *db.DBModel
|
||||
)
|
||||
info = &pb.DBCatchBugs{}
|
||||
if !this.module.IsCross() {
|
||||
if model, err = this.module.GetCrossDBModel(this.TableName); err != nil {
|
||||
this.module.Errorln(err)
|
||||
} else {
|
||||
if err = model.Get(uid, info); err != nil && err != mgo.MongodbNil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
}
|
||||
if err == mgo.MongodbNil {
|
||||
info = &pb.DBCatchBugs{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Uid: uid,
|
||||
Books: make(map[int32]int32),
|
||||
Weekaward: make(map[int32]bool),
|
||||
Allaward: make(map[int32]bool),
|
||||
}
|
||||
err = model.Add(uid, info)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -193,3 +193,59 @@ func (this *CatchBugs) AdmitDefeat(roomid string, uid string) (err error) {
|
||||
err = room.PlayerOffline(uid)
|
||||
return
|
||||
}
|
||||
|
||||
// 红点需求
|
||||
func (this *CatchBugs) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) {
|
||||
var (
|
||||
selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot41101}
|
||||
confs []*cfg.GameCatchbugRewardData
|
||||
info *pb.DBCatchBugs
|
||||
err error
|
||||
ok bool
|
||||
)
|
||||
items = make(map[comm.ReddotType]*pb.ReddotItem)
|
||||
for _, v := range selfrid {
|
||||
if _, ok = rid[v]; ok {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if confs, err = this.configure.getGameGColorRewardDatas(); err != nil {
|
||||
return
|
||||
}
|
||||
if info, err = this.model.getCorssModel(session.GetUserId()); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range selfrid {
|
||||
if _, ok = rid[v]; ok {
|
||||
switch v {
|
||||
case comm.Reddot41101:
|
||||
for _, conf := range confs {
|
||||
if conf.Type == 1 {
|
||||
if _, ok = info.Weekaward[conf.Key]; !ok && info.Integral >= conf.Condition {
|
||||
items[comm.Reddot41101] = &pb.ReddotItem{
|
||||
Rid: int32(comm.Reddot41101),
|
||||
Activated: true,
|
||||
}
|
||||
break
|
||||
}
|
||||
} else {
|
||||
if _, ok = info.Allaward[conf.Key]; !ok && info.Accruedintegral >= conf.Condition {
|
||||
items[comm.Reddot41101] = &pb.ReddotItem{
|
||||
Rid: int32(comm.Reddot41101),
|
||||
Activated: true,
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
"go_dreamfactory/sys/db"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
@ -47,3 +48,33 @@ func (this *modelComp) getModel(uid string) (info *pb.DBDColor, err error) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 获取用户全部的埋点数据
|
||||
func (this *modelComp) getCorssModel(uid string) (info *pb.DBDColor, err error) {
|
||||
var (
|
||||
model *db.DBModel
|
||||
)
|
||||
info = &pb.DBDColor{}
|
||||
if !this.module.IsCross() {
|
||||
if model, err = this.module.GetCrossDBModel(this.TableName); err != nil {
|
||||
this.module.Errorln(err)
|
||||
} else {
|
||||
if err = model.Get(uid, info); err != nil && err != mgo.MongodbNil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
}
|
||||
if err == mgo.MongodbNil {
|
||||
info = &pb.DBDColor{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Uid: uid,
|
||||
Integral: 0,
|
||||
Weekaward: make(map[int32]bool),
|
||||
Allaward: make(map[int32]bool),
|
||||
Weektime: configure.Now().Unix(),
|
||||
}
|
||||
err = model.Add(uid, info)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
@ -147,3 +148,59 @@ func (this *DColor) AdmitDefeat(roomid string, uid string) (err error) {
|
||||
err = room.PlayerOffline(uid)
|
||||
return
|
||||
}
|
||||
|
||||
// 红点需求
|
||||
func (this *DColor) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) {
|
||||
var (
|
||||
selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot39101}
|
||||
confs []*cfg.GameGColorRewardData
|
||||
info *pb.DBDColor
|
||||
err error
|
||||
ok bool
|
||||
)
|
||||
items = make(map[comm.ReddotType]*pb.ReddotItem)
|
||||
for _, v := range selfrid {
|
||||
if _, ok = rid[v]; ok {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if confs, err = this.configure.getGameGColorRewardDatas(); err != nil {
|
||||
return
|
||||
}
|
||||
if info, err = this.model.getCorssModel(session.GetUserId()); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range selfrid {
|
||||
if _, ok = rid[v]; ok {
|
||||
switch v {
|
||||
case comm.Reddot39101:
|
||||
for _, conf := range confs {
|
||||
if conf.Type == 1 {
|
||||
if _, ok = info.Weekaward[conf.Key]; !ok && info.Integral >= conf.Condition {
|
||||
items[comm.Reddot39101] = &pb.ReddotItem{
|
||||
Rid: int32(comm.Reddot39101),
|
||||
Activated: true,
|
||||
}
|
||||
break
|
||||
}
|
||||
} else {
|
||||
if _, ok = info.Allaward[conf.Key]; !ok && info.Accruedintegral >= conf.Condition {
|
||||
items[comm.Reddot39101] = &pb.ReddotItem{
|
||||
Rid: int32(comm.Reddot39101),
|
||||
Activated: true,
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -74,6 +74,13 @@ func (this *apiComp) Get(session comm.IUserSession, req *pb.ReddotGetReq) (errda
|
||||
for _, v := range this.module.atlas.Reddot(session, reds) {
|
||||
reddotItem = append(reddotItem, v)
|
||||
}
|
||||
for _, v := range this.module.color.Reddot(session, reds) {
|
||||
reddotItem = append(reddotItem, v)
|
||||
}
|
||||
for _, v := range this.module.catchbugs.Reddot(session, reds) {
|
||||
reddotItem = append(reddotItem, v)
|
||||
}
|
||||
|
||||
if len(reddotItem) > 0 {
|
||||
session.SendMsg(string(this.module.GetType()), "change", &pb.ReddotChangePush{Rids: reddotItem})
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ type Reddot struct {
|
||||
api_comp *apiComp
|
||||
mainline comm.IMainline
|
||||
atlas comm.IPandaAtlas
|
||||
color comm.IDColor
|
||||
catchbugs comm.ICatchBugs
|
||||
}
|
||||
|
||||
// 模块名
|
||||
@ -133,6 +135,15 @@ func (this *Reddot) Start() (err error) {
|
||||
return
|
||||
}
|
||||
this.atlas = module.(comm.IPandaAtlas)
|
||||
if module, err = this.service.GetModule(comm.ModuleDcolor); err != nil {
|
||||
return
|
||||
}
|
||||
this.color = module.(comm.IDColor)
|
||||
if module, err = this.service.GetModule(comm.ModuleCatchbugs); err != nil {
|
||||
return
|
||||
}
|
||||
this.catchbugs = module.(comm.ICatchBugs)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user