上传成就和辉月任务红点
This commit is contained in:
parent
a9ff376422
commit
e22d5b1511
@ -740,6 +740,11 @@ const (
|
||||
Reddot39101 ReddotType = 39101 //猜颜色奖励可领取
|
||||
//捉虫子
|
||||
Reddot41101 ReddotType = 41101 //捉虫子奖励可领取
|
||||
//成就可领取
|
||||
Reddot34101 ReddotType = 34101 //成就奖励可领取
|
||||
//辉月
|
||||
Reddot36101 ReddotType = 36101 //当有辉月等级可以升级时,触发辉月系统红点。
|
||||
|
||||
// 主线
|
||||
Reddot24101 ReddotType = 24101 // 主线章节有奖励没领取
|
||||
// 好友
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"sync"
|
||||
)
|
||||
@ -23,36 +22,10 @@ type configureComp struct {
|
||||
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
err = this.MCompConfigure.Init(service, module, comp, options)
|
||||
this.module = module.(*Achieve)
|
||||
configure.RegisterConfigure(game_achievetask, cfg.NewGameAchieveTask, this.updateconfigure)
|
||||
this.LoadConfigure(game_achievetask, cfg.NewGameAchieveTask)
|
||||
return
|
||||
}
|
||||
|
||||
// 更新任务配置表
|
||||
func (this *configureComp) updateconfigure() {
|
||||
var (
|
||||
v interface{}
|
||||
conf *cfg.GameAchieveTask
|
||||
ok bool
|
||||
err error
|
||||
)
|
||||
if v, err = this.GetConfigure(game_achievetask); err != nil {
|
||||
return
|
||||
}
|
||||
if conf, ok = v.(*cfg.GameAchieveTask); !ok {
|
||||
this.module.Error("通用成就配置错误!")
|
||||
return
|
||||
}
|
||||
tasksConf := make([]int32, 0)
|
||||
|
||||
for _, v := range conf.GetDataList() {
|
||||
tasksConf = append(tasksConf, v.TaskBuried)
|
||||
}
|
||||
|
||||
this.lock.Lock()
|
||||
this.tasksConf = tasksConf
|
||||
this.lock.Unlock()
|
||||
}
|
||||
|
||||
//查询积分段位信息
|
||||
func (this *configureComp) getAchieveTaskById(id int32) (result *cfg.GameAchieveTaskData, err error) {
|
||||
var (
|
||||
@ -69,3 +42,16 @@ func (this *configureComp) getAchieveTaskById(id int32) (result *cfg.GameAchieve
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//查询积分段位信息
|
||||
func (this *configureComp) getAchieveTaskAll() (confs []*cfg.GameAchieveTaskData, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
)
|
||||
if v, err = this.GetConfigure(game_achievetask); err != nil {
|
||||
this.module.Errorln(err)
|
||||
} else {
|
||||
confs = v.(*cfg.GameAchieveTask).GetDataList()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -3,7 +3,10 @@ package achieve
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
)
|
||||
|
||||
type Achieve struct {
|
||||
@ -49,3 +52,83 @@ func (this *Achieve) OnInstallComp() {
|
||||
this.model = this.RegisterComp(new(modelComp)).(*modelComp)
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
}
|
||||
|
||||
// 任务条件达成通知
|
||||
func (this *Achieve) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIProgress) {
|
||||
this.Debug("成就任务通知",
|
||||
log.Field{Key: "uid", Value: session.GetUserId()},
|
||||
log.Field{Key: "condIds", Value: conds})
|
||||
ok := false
|
||||
for _, v := range conds {
|
||||
if v.State == pb.BuriedItemFinishState_buried_finish {
|
||||
ok = true
|
||||
}
|
||||
}
|
||||
if ok {
|
||||
session.SendMsg(string(comm.ModuleReddot), "change", &pb.ReddotChangePush{Rids: []*pb.ReddotItem{
|
||||
{
|
||||
Rid: int32(comm.Reddot34101),
|
||||
Activated: true,
|
||||
},
|
||||
}})
|
||||
}
|
||||
}
|
||||
|
||||
// 红点需求
|
||||
func (this *Achieve) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) {
|
||||
var (
|
||||
selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot34101}
|
||||
confs []*cfg.GameAchieveTaskData
|
||||
info *pb.DBAchieveData
|
||||
comdi []int32
|
||||
condisProgress []*pb.ConIProgress
|
||||
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.getAchieveTaskAll(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if info, err = this.model.getmodel(session.GetUserId()); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range selfrid {
|
||||
if _, ok = rid[v]; ok {
|
||||
switch v {
|
||||
case comm.Reddot34101:
|
||||
for _, v := range confs {
|
||||
comdi = append(comdi, v.Key)
|
||||
}
|
||||
if _, condisProgress, err = this.ModuleBuried.CheckCondition(session, comdi...); err != nil {
|
||||
this.Errorln(err)
|
||||
return
|
||||
}
|
||||
for _, v := range condisProgress {
|
||||
if v.State == pb.BuriedItemFinishState_buried_finish {
|
||||
if value, ok := info.Receive[v.Conid]; !ok || !value {
|
||||
items[comm.Reddot34101] = &pb.ReddotItem{
|
||||
Rid: int32(comm.Reddot34101),
|
||||
Activated: true,
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -3,8 +3,10 @@ package moonlv
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
)
|
||||
|
||||
type Moonlv struct {
|
||||
@ -38,78 +40,6 @@ func (this *Moonlv) OnInstallComp() {
|
||||
this.modelMoonlv = this.RegisterComp(new(modelMoonlv)).(*modelMoonlv)
|
||||
}
|
||||
|
||||
func (this *Moonlv) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIProgress) {
|
||||
// var groupID int32
|
||||
// this.Debug("护月任务通知", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "conds", Value: conds})
|
||||
// dt, err := this.modelMoonlv.getMoonlvList(session)
|
||||
// if c, e := this.configure.GetMoonLvConf(dt.Lv); e == nil {
|
||||
// groupID = c.TaskGroupId
|
||||
// }
|
||||
// confList, err := this.configure.GetMoonLvTaskConf(groupID)
|
||||
// if err != nil {
|
||||
// this.Error(err.Error())
|
||||
// return
|
||||
// }
|
||||
// condMap := make(map[int32]*pb.ConIProgress)
|
||||
// for _, conf := range confList {
|
||||
// for _, cond := range conds {
|
||||
// if cond.Conid == conf.TaskId {
|
||||
// condMap[conf.TaskId] = cond
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// update := make(map[string]interface{})
|
||||
|
||||
// if dt.Tasks == nil {
|
||||
// for k, v := range condMap {
|
||||
// tt := &pb.MoonTask{
|
||||
// TaskId: k,
|
||||
// }
|
||||
// if v.State == pb.BuriedItemFinishState_buried_finish {
|
||||
// tt.Received = 1
|
||||
// }
|
||||
// dt.Tasks = append(dt.Tasks, tt)
|
||||
// }
|
||||
// update["tasks"] = dt.Tasks
|
||||
// if err := this.modelMoonlv.modifyMoonlvList(session.GetUserId(), update); err != nil {
|
||||
// this.Error(err.Error())
|
||||
// return
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
|
||||
// var newTask []*pb.MoonTask
|
||||
// existTaskMap := make(map[int32]*pb.MoonTask)
|
||||
// for _, task := range dt.Tasks {
|
||||
// existTaskMap[task.TaskId] = task
|
||||
// }
|
||||
|
||||
// for k, v := range condMap {
|
||||
// if task, ok := existTaskMap[k]; ok {
|
||||
// if v.State == pb.BuriedItemFinishState_buried_finish {
|
||||
// task.Received = 1
|
||||
// }
|
||||
// } else {
|
||||
// nt := &pb.MoonTask{
|
||||
// TaskId: k,
|
||||
// }
|
||||
// if v.State == pb.BuriedItemFinishState_buried_finish {
|
||||
// nt.Received = 1
|
||||
// }
|
||||
// newTask = append(newTask, nt)
|
||||
// }
|
||||
// }
|
||||
// dt.Tasks = append(dt.Tasks, newTask...)
|
||||
// update["tasks"] = dt.Tasks
|
||||
|
||||
// if len(update) > 0 {
|
||||
// if err := this.modelMoonlv.modifyMoonlvList(session.GetUserId(), update); err != nil {
|
||||
// this.Error(err.Error())
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
func (this *Moonlv) GMCreateMoonlv(session comm.IUserSession, lv int32) {
|
||||
if lv <= 0 {
|
||||
return
|
||||
@ -118,3 +48,85 @@ func (this *Moonlv) GMCreateMoonlv(session comm.IUserSession, lv int32) {
|
||||
this.modelMoonlv.modifyMoonlvList(session.GetUserId(), map[string]interface{}{"cid": lv + 1})
|
||||
}
|
||||
}
|
||||
|
||||
// 任务条件达成通知
|
||||
func (this *Moonlv) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIProgress) {
|
||||
this.Debug("辉月任务通知",
|
||||
log.Field{Key: "uid", Value: session.GetUserId()},
|
||||
log.Field{Key: "condIds", Value: conds})
|
||||
ok := false
|
||||
for _, v := range conds {
|
||||
if v.State == pb.BuriedItemFinishState_buried_finish {
|
||||
ok = true
|
||||
}
|
||||
}
|
||||
if ok {
|
||||
session.SendMsg(string(comm.ModuleReddot), "change", &pb.ReddotChangePush{Rids: []*pb.ReddotItem{
|
||||
{
|
||||
Rid: int32(comm.Reddot36101),
|
||||
Activated: true,
|
||||
},
|
||||
}})
|
||||
}
|
||||
}
|
||||
|
||||
// 红点需求
|
||||
func (this *Moonlv) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) {
|
||||
var (
|
||||
selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot36101}
|
||||
info *pb.DBMoonLv
|
||||
conf *cfg.GameMoonLvData
|
||||
tconfs []*cfg.GameMoonTaskData
|
||||
comdi []int32
|
||||
condisProgress []*pb.ConIProgress
|
||||
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 info, err = this.modelMoonlv.getMoonlvList(session); err != nil {
|
||||
return
|
||||
}
|
||||
if conf, err = this.configure.GetMoonLvConf(info.Cid); err != nil {
|
||||
return
|
||||
}
|
||||
if tconfs, err = this.configure.GetMoonLvTaskConf(conf.TaskGroupId); err != nil {
|
||||
return
|
||||
}
|
||||
for _, v := range selfrid {
|
||||
if _, ok = rid[v]; ok {
|
||||
switch v {
|
||||
case comm.Reddot36101:
|
||||
for _, v := range tconfs {
|
||||
comdi = append(comdi, v.TaskId)
|
||||
}
|
||||
if _, condisProgress, err = this.ModuleBuried.CheckCondition(session, comdi...); err != nil {
|
||||
this.Errorln(err)
|
||||
return
|
||||
}
|
||||
for _, v := range condisProgress {
|
||||
if v.State == pb.BuriedItemFinishState_buried_finish {
|
||||
if value, ok := info.Tasks[v.Conid]; !ok || value == 0 {
|
||||
items[comm.Reddot34101] = &pb.ReddotItem{
|
||||
Rid: int32(comm.Reddot34101),
|
||||
Activated: true,
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user