Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
5b1ac18386
@ -360,7 +360,7 @@ type (
|
||||
// 设置工会活跃度
|
||||
BingoSetActivity(session IUserSession, activity int32) error
|
||||
// 任务条件达成通知
|
||||
// TaskcondNotify(uid string, condIds []int32) error
|
||||
IBuriedUpdateNotify
|
||||
// 红点
|
||||
IGetReddot
|
||||
}
|
||||
@ -461,6 +461,7 @@ type (
|
||||
|
||||
ISmithy interface {
|
||||
CheckActivateAtlasCollect(uid string, id string)
|
||||
IBuriedUpdateNotify
|
||||
IGetReddot // 铁匠铺红点
|
||||
}
|
||||
|
||||
@ -540,5 +541,6 @@ type (
|
||||
IWtask interface {
|
||||
IBuriedUpdateNotify
|
||||
IOpenCmdNotice
|
||||
AcceptCaravanTask(session IUserSession, groupId int32) (tid, groud int32, errdata *pb.ErrorData)
|
||||
}
|
||||
)
|
||||
|
@ -26,6 +26,9 @@ const moduleName = "埋点统计中心"
|
||||
type Buried struct {
|
||||
modules.ModuleBase
|
||||
service comm.IService
|
||||
wtask comm.IWtask //世界任务
|
||||
smithy comm.ISmithy //铁匠朴
|
||||
sociaty comm.ISociaty //工会
|
||||
configure *configureComp
|
||||
modelBuried *modelBuried
|
||||
}
|
||||
@ -46,6 +49,20 @@ func (this *Buried) Init(service core.IService, module core.IModule, options cor
|
||||
|
||||
func (this *Buried) Start() (err error) {
|
||||
err = this.ModuleBase.Start()
|
||||
|
||||
var module core.IModule
|
||||
if module, err = this.service.GetModule(comm.ModuleWtask); err != nil {
|
||||
return
|
||||
}
|
||||
this.wtask = module.(comm.IWtask)
|
||||
if module, err = this.service.GetModule(comm.ModuleSmithy); err != nil {
|
||||
return
|
||||
}
|
||||
this.smithy = module.(comm.ISmithy)
|
||||
if module, err = this.service.GetModule(comm.ModuleSociaty); err != nil {
|
||||
return
|
||||
}
|
||||
this.sociaty = module.(comm.ISociaty)
|
||||
this.service.RegisterFunctionName(string(comm.Rpc_ModuleBuriedTrigger), this.Rpc_ModuleBuriedTrigger)
|
||||
return
|
||||
}
|
||||
@ -64,6 +81,8 @@ func (this *Buried) Rpc_ModuleBuriedTrigger(ctx context.Context, req *pb.Rpc_Mod
|
||||
session := this.service.GetUserSession()
|
||||
session.SetSession(req.Ip, req.UserSessionId, req.ServiceTag, req.GatewayServiceId, req.UserId)
|
||||
this.trigger(session, req.Burieds...)
|
||||
session.Push()
|
||||
this.service.PutUserSession(session)
|
||||
return
|
||||
}
|
||||
|
||||
@ -434,6 +453,8 @@ func (this *Buried) TriggerBuried(session comm.IUserSession, burieds ...*pb.Buri
|
||||
} else {
|
||||
this.trigger(session, burieds...)
|
||||
}
|
||||
session.Push()
|
||||
this.service.PutUserSession(session)
|
||||
}
|
||||
|
||||
func (this *Buried) trigger(session comm.IUserSession, burieds ...*pb.BuriedParam) {
|
||||
@ -447,10 +468,11 @@ func (this *Buried) trigger(session comm.IUserSession, burieds ...*pb.BuriedPara
|
||||
change bool
|
||||
changes []*pb.ConIProgress
|
||||
notify map[string][]*pb.ConIProgress
|
||||
module core.IModule
|
||||
nmodule comm.IBuriedUpdateNotify
|
||||
// module core.IModule
|
||||
// nmodule comm.IBuriedUpdateNotify
|
||||
err error
|
||||
)
|
||||
|
||||
this.Debug("触发埋点!", log.Field{Key: "burieds", Value: burieds})
|
||||
lock, _ := this.modelBuried.userlock(session.GetUserId())
|
||||
err = lock.Lock()
|
||||
@ -537,20 +559,23 @@ func (this *Buried) trigger(session comm.IUserSession, burieds ...*pb.BuriedPara
|
||||
}
|
||||
}
|
||||
|
||||
if len(notify) > 0 {
|
||||
for k, v := range notify {
|
||||
if module, err = this.service.GetModule(core.M_Modules(k)); err != nil {
|
||||
this.Error("通知条件变化异常 目标模块未找到!", log.Field{Key: "module", Value: k}, log.Field{Key: "err", Value: err.Error()})
|
||||
continue
|
||||
}
|
||||
if nmodule, ok = module.(comm.IBuriedUpdateNotify); !ok {
|
||||
this.Error("通知条件变化异常 目标模块未实现 IBuriedUpdateNotify 接口 !", log.Field{Key: "module", Value: k})
|
||||
continue
|
||||
}
|
||||
//异步通知指定模块
|
||||
nmodule.BuriedsNotify(session, v)
|
||||
}
|
||||
}
|
||||
this.wtask.BuriedsNotify(session, changes)
|
||||
this.smithy.BuriedsNotify(session, changes)
|
||||
this.sociaty.BuriedsNotify(session, changes)
|
||||
// if len(notify) > 0 {
|
||||
// for k, v := range notify {
|
||||
// if module, err = this.service.GetModule(core.M_Modules(k)); err != nil {
|
||||
// this.Error("通知条件变化异常 目标模块未找到!", log.Field{Key: "module", Value: k}, log.Field{Key: "err", Value: err.Error()})
|
||||
// continue
|
||||
// }
|
||||
// if nmodule, ok = module.(comm.IBuriedUpdateNotify); !ok {
|
||||
// this.Error("通知条件变化异常 目标模块未实现 IBuriedUpdateNotify 接口 !", log.Field{Key: "module", Value: k})
|
||||
// continue
|
||||
// }
|
||||
// //异步通知指定模块
|
||||
// nmodule.BuriedsNotify(session, v)
|
||||
// }
|
||||
// }
|
||||
|
||||
// //通知事件
|
||||
// if len(changes) > 0 {
|
||||
|
@ -3,7 +3,6 @@ package smithy
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
@ -35,117 +34,6 @@ func (this *modelTask) getTaskRecord(uid string) (*pb.DBTujianTask, error) {
|
||||
return tt, nil
|
||||
}
|
||||
|
||||
func (this *modelTask) TCondFinishNotify(uid string, conds []*pb.ConIProgress) {
|
||||
session, ok := this.module.GetUserSession(uid)
|
||||
if !ok {
|
||||
this.module.Errorln("TCondFinishNotify 获取session失败")
|
||||
return
|
||||
}
|
||||
this.module.Debug("铁匠铺任务通知", log.Field{Key: "uid", Value: uid}, log.Field{Key: "conds", Value: conds})
|
||||
confList, err := this.module.configure.GetSmithyTasks()
|
||||
if err != nil {
|
||||
this.module.Error(err.Error())
|
||||
return
|
||||
}
|
||||
condMap := make(map[int32]*pb.ConIProgress)
|
||||
for _, conf := range confList {
|
||||
for _, cond := range conds {
|
||||
if cond.Conid == conf.TypeId {
|
||||
condMap[conf.Key] = cond
|
||||
}
|
||||
}
|
||||
}
|
||||
update := make(map[string]interface{})
|
||||
dt, err := this.getTaskRecord(uid)
|
||||
if err != nil {
|
||||
if err == mongo.ErrNoDocuments {
|
||||
for k, v := range condMap {
|
||||
tt := &pb.TujianTask{
|
||||
TaskId: k,
|
||||
Cond: v,
|
||||
}
|
||||
if v.State == pb.BuriedItemFinishState_buried_finish {
|
||||
tt.Received = 1
|
||||
i, err := this.module.service.GetModule(comm.ModuleReddot)
|
||||
if err != nil {
|
||||
this.module.Error(err.Error())
|
||||
return
|
||||
}
|
||||
if b, y := i.(comm.IReddot); y {
|
||||
b.PushReddot(session, &pb.ReddotItem{
|
||||
Rid: int32(comm.Reddot17107),
|
||||
Activated: true,
|
||||
Nextchanagetime: 0,
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
dt.Tasks = append(dt.Tasks, tt)
|
||||
if err := this.Add(uid, dt); err != nil {
|
||||
this.module.Error(err.Error())
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
} else {
|
||||
this.module.Error(err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if dt.Tasks == nil {
|
||||
for k, v := range condMap {
|
||||
tt := &pb.TujianTask{
|
||||
TaskId: k,
|
||||
Cond: v,
|
||||
}
|
||||
if v.State == pb.BuriedItemFinishState_buried_finish {
|
||||
tt.Received = 1
|
||||
}
|
||||
dt.Tasks = append(dt.Tasks, tt)
|
||||
}
|
||||
update["tasks"] = dt.Tasks
|
||||
if err := this.Change(uid, update); err != nil {
|
||||
this.module.Error(err.Error())
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var newTask []*pb.TujianTask
|
||||
existTaskMap := make(map[int32]*pb.TujianTask)
|
||||
for _, task := range dt.Tasks {
|
||||
existTaskMap[task.TaskId] = task
|
||||
}
|
||||
|
||||
for k, v := range condMap {
|
||||
if task, ok := existTaskMap[k]; ok {
|
||||
task.Cond = v
|
||||
if v.State == pb.BuriedItemFinishState_buried_finish {
|
||||
task.Received = 1
|
||||
}
|
||||
} else {
|
||||
nt := &pb.TujianTask{
|
||||
TaskId: k,
|
||||
Cond: v,
|
||||
}
|
||||
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.Change(uid, update); err != nil {
|
||||
this.module.Error(err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (this *modelTask) updateTaskRecord(uid string, taskId int32) error {
|
||||
dt, err := this.getTaskRecord(uid)
|
||||
if err != nil {
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/base"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
@ -17,6 +18,8 @@ import (
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
var _ comm.ISmithy = (*Smithy)(nil)
|
||||
|
||||
type Smithy struct {
|
||||
modules.ModuleBase
|
||||
service base.IRPCXService
|
||||
@ -149,3 +152,109 @@ func (this *Smithy) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (r
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Smithy) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIProgress) {
|
||||
this.Debug("铁匠铺任务通知", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "conds", Value: conds})
|
||||
confList, err := this.configure.GetSmithyTasks()
|
||||
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.TypeId {
|
||||
condMap[conf.Key] = cond
|
||||
}
|
||||
}
|
||||
}
|
||||
update := make(map[string]interface{})
|
||||
dt, err := this.modelTask.getTaskRecord(session.GetUserId())
|
||||
if err != nil {
|
||||
if err == mongo.ErrNoDocuments {
|
||||
for k, v := range condMap {
|
||||
tt := &pb.TujianTask{
|
||||
TaskId: k,
|
||||
Cond: v,
|
||||
}
|
||||
if v.State == pb.BuriedItemFinishState_buried_finish {
|
||||
tt.Received = 1
|
||||
i, err := this.service.GetModule(comm.ModuleReddot)
|
||||
if err != nil {
|
||||
this.Error(err.Error())
|
||||
return
|
||||
}
|
||||
if b, y := i.(comm.IReddot); y {
|
||||
b.PushReddot(session, &pb.ReddotItem{
|
||||
Rid: int32(comm.Reddot17107),
|
||||
Activated: true,
|
||||
Nextchanagetime: 0,
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
dt.Tasks = append(dt.Tasks, tt)
|
||||
if err := this.modelTask.Add(session.GetUserId(), dt); err != nil {
|
||||
this.Error(err.Error())
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
} else {
|
||||
this.Error(err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if dt.Tasks == nil {
|
||||
for k, v := range condMap {
|
||||
tt := &pb.TujianTask{
|
||||
TaskId: k,
|
||||
Cond: v,
|
||||
}
|
||||
if v.State == pb.BuriedItemFinishState_buried_finish {
|
||||
tt.Received = 1
|
||||
}
|
||||
dt.Tasks = append(dt.Tasks, tt)
|
||||
}
|
||||
update["tasks"] = dt.Tasks
|
||||
if err := this.modelTask.Change(session.GetUserId(), update); err != nil {
|
||||
this.Error(err.Error())
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var newTask []*pb.TujianTask
|
||||
existTaskMap := make(map[int32]*pb.TujianTask)
|
||||
for _, task := range dt.Tasks {
|
||||
existTaskMap[task.TaskId] = task
|
||||
}
|
||||
|
||||
for k, v := range condMap {
|
||||
if task, ok := existTaskMap[k]; ok {
|
||||
task.Cond = v
|
||||
if v.State == pb.BuriedItemFinishState_buried_finish {
|
||||
task.Received = 1
|
||||
}
|
||||
} else {
|
||||
nt := &pb.TujianTask{
|
||||
TaskId: k,
|
||||
Cond: v,
|
||||
}
|
||||
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.modelTask.Change(session.GetUserId(), update); err != nil {
|
||||
this.Error(err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ type TaskParams struct {
|
||||
}
|
||||
|
||||
// 任务条件达成通知
|
||||
func (this *Sociaty) TCondFinishNotify(session comm.IUserSession, conds []*pb.ConIProgress) {
|
||||
func (this *Sociaty) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIProgress) {
|
||||
log.Debug("公会任务通知",
|
||||
log.Field{Key: "uid", Value: session.GetUserId()},
|
||||
log.Field{Key: "condIds", Value: conds})
|
||||
|
@ -19,6 +19,7 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.WTaskAcceptReq) (
|
||||
wtask *pb.DBWTask
|
||||
conf *cfg.GameWorldTaskData
|
||||
progress []*pb.DBWTaskItem
|
||||
update map[string]interface{} = make(map[string]interface{})
|
||||
ok bool
|
||||
err error
|
||||
)
|
||||
@ -44,12 +45,18 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.WTaskAcceptReq) (
|
||||
return
|
||||
}
|
||||
ok = false
|
||||
if conf.Des != 5 {
|
||||
for _, v := range wtask.Activations {
|
||||
if req.Tid == v {
|
||||
ok = true
|
||||
}
|
||||
}
|
||||
if conf.Des == 5 { //商队任务 接取任务时 移除下一个任务的完成条件 方便顺序获取任务
|
||||
for i, v := range wtask.Completes {
|
||||
if conf.IdAfter != 0 && conf.IdAfter == v {
|
||||
wtask.Completes = append(wtask.Completes[0:i], wtask.Completes[i+1:]...)
|
||||
update["completes"] = wtask.Completes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !ok {
|
||||
@ -68,15 +75,14 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.WTaskAcceptReq) (
|
||||
}
|
||||
}
|
||||
wtask.Accepts = append(wtask.Accepts, req.Tid)
|
||||
update["activations"] = wtask.Activations
|
||||
update["accepts"] = wtask.Accepts
|
||||
if progress, errdata = this.module.pushtaskprogress(session, wtask, false); errdata != nil {
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "accept", &pb.WTaskAcceptResp{Tid: req.Tid, Activations: wtask.Activations, Accepts: progress})
|
||||
|
||||
if err = this.module.modelwtask.Change(session.GetUserId(), map[string]interface{}{
|
||||
"activations": wtask.Activations,
|
||||
"accepts": wtask.Accepts,
|
||||
}); err != nil {
|
||||
if err = this.module.modelwtask.Change(session.GetUserId(), update); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
|
@ -176,7 +176,7 @@ func (this *WTask) OpenCmdNotice(uid string, keys ...string) {
|
||||
}
|
||||
|
||||
// 获取商队任务
|
||||
func (this *WTask) AcceptCaravanTask(session comm.IUserSession, groupId int32) (task *pb.Worldtask, errdata *pb.ErrorData) {
|
||||
func (this *WTask) AcceptCaravanTask(session comm.IUserSession, groupId int32) (tid, groud int32, errdata *pb.ErrorData) {
|
||||
var (
|
||||
alltasks []*cfg.GameWorldTaskData
|
||||
grouptask []*cfg.GameWorldTaskData = make([]*cfg.GameWorldTaskData, 0)
|
||||
@ -185,8 +185,6 @@ func (this *WTask) AcceptCaravanTask(session comm.IUserSession, groupId int32) (
|
||||
wtask *pb.DBWTask
|
||||
err error
|
||||
ok bool
|
||||
changeActiva bool
|
||||
changeAccept bool
|
||||
)
|
||||
alltasks = this.configure.getdesTask(5)
|
||||
for _, v := range alltasks {
|
||||
@ -234,27 +232,9 @@ func (this *WTask) AcceptCaravanTask(session comm.IUserSession, groupId int32) (
|
||||
}
|
||||
|
||||
//有新任务接取
|
||||
|
||||
if target.AutoAccept == 0 {
|
||||
wtask.Activations = append(wtask.Activations, target.Key)
|
||||
changeActiva = true
|
||||
|
||||
} else if target.AutoAccept == 1 { //自动接取任务
|
||||
wtask.Accepts = append(wtask.Accepts, target.Key)
|
||||
changeAccept = true
|
||||
}
|
||||
|
||||
//有新任务接取
|
||||
if changeActiva {
|
||||
session.SendMsg(string(this.GetType()), "activations", &pb.WTaskActivationsChangePush{Activations: wtask.Activations})
|
||||
}
|
||||
|
||||
if changeAccept {
|
||||
if _, errdata = this.pushtaskprogress(session, wtask, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err = this.modelwtask.updateUserWTasks(session.GetUserId(), wtask); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
@ -263,7 +243,8 @@ func (this *WTask) AcceptCaravanTask(session comm.IUserSession, groupId int32) (
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
tid = target.Key
|
||||
groud = target.Group
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user