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
|
BingoSetActivity(session IUserSession, activity int32) error
|
||||||
// 任务条件达成通知
|
// 任务条件达成通知
|
||||||
// TaskcondNotify(uid string, condIds []int32) error
|
IBuriedUpdateNotify
|
||||||
// 红点
|
// 红点
|
||||||
IGetReddot
|
IGetReddot
|
||||||
}
|
}
|
||||||
@ -461,6 +461,7 @@ type (
|
|||||||
|
|
||||||
ISmithy interface {
|
ISmithy interface {
|
||||||
CheckActivateAtlasCollect(uid string, id string)
|
CheckActivateAtlasCollect(uid string, id string)
|
||||||
|
IBuriedUpdateNotify
|
||||||
IGetReddot // 铁匠铺红点
|
IGetReddot // 铁匠铺红点
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,5 +541,6 @@ type (
|
|||||||
IWtask interface {
|
IWtask interface {
|
||||||
IBuriedUpdateNotify
|
IBuriedUpdateNotify
|
||||||
IOpenCmdNotice
|
IOpenCmdNotice
|
||||||
|
AcceptCaravanTask(session IUserSession, groupId int32) (tid, groud int32, errdata *pb.ErrorData)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -26,6 +26,9 @@ const moduleName = "埋点统计中心"
|
|||||||
type Buried struct {
|
type Buried struct {
|
||||||
modules.ModuleBase
|
modules.ModuleBase
|
||||||
service comm.IService
|
service comm.IService
|
||||||
|
wtask comm.IWtask //世界任务
|
||||||
|
smithy comm.ISmithy //铁匠朴
|
||||||
|
sociaty comm.ISociaty //工会
|
||||||
configure *configureComp
|
configure *configureComp
|
||||||
modelBuried *modelBuried
|
modelBuried *modelBuried
|
||||||
}
|
}
|
||||||
@ -46,6 +49,20 @@ func (this *Buried) Init(service core.IService, module core.IModule, options cor
|
|||||||
|
|
||||||
func (this *Buried) Start() (err error) {
|
func (this *Buried) Start() (err error) {
|
||||||
err = this.ModuleBase.Start()
|
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)
|
this.service.RegisterFunctionName(string(comm.Rpc_ModuleBuriedTrigger), this.Rpc_ModuleBuriedTrigger)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -64,6 +81,8 @@ func (this *Buried) Rpc_ModuleBuriedTrigger(ctx context.Context, req *pb.Rpc_Mod
|
|||||||
session := this.service.GetUserSession()
|
session := this.service.GetUserSession()
|
||||||
session.SetSession(req.Ip, req.UserSessionId, req.ServiceTag, req.GatewayServiceId, req.UserId)
|
session.SetSession(req.Ip, req.UserSessionId, req.ServiceTag, req.GatewayServiceId, req.UserId)
|
||||||
this.trigger(session, req.Burieds...)
|
this.trigger(session, req.Burieds...)
|
||||||
|
session.Push()
|
||||||
|
this.service.PutUserSession(session)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,6 +453,8 @@ func (this *Buried) TriggerBuried(session comm.IUserSession, burieds ...*pb.Buri
|
|||||||
} else {
|
} else {
|
||||||
this.trigger(session, burieds...)
|
this.trigger(session, burieds...)
|
||||||
}
|
}
|
||||||
|
session.Push()
|
||||||
|
this.service.PutUserSession(session)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Buried) trigger(session comm.IUserSession, burieds ...*pb.BuriedParam) {
|
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
|
change bool
|
||||||
changes []*pb.ConIProgress
|
changes []*pb.ConIProgress
|
||||||
notify map[string][]*pb.ConIProgress
|
notify map[string][]*pb.ConIProgress
|
||||||
module core.IModule
|
// module core.IModule
|
||||||
nmodule comm.IBuriedUpdateNotify
|
// nmodule comm.IBuriedUpdateNotify
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
this.Debug("触发埋点!", log.Field{Key: "burieds", Value: burieds})
|
this.Debug("触发埋点!", log.Field{Key: "burieds", Value: burieds})
|
||||||
lock, _ := this.modelBuried.userlock(session.GetUserId())
|
lock, _ := this.modelBuried.userlock(session.GetUserId())
|
||||||
err = lock.Lock()
|
err = lock.Lock()
|
||||||
@ -537,20 +559,23 @@ func (this *Buried) trigger(session comm.IUserSession, burieds ...*pb.BuriedPara
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(notify) > 0 {
|
this.wtask.BuriedsNotify(session, changes)
|
||||||
for k, v := range notify {
|
this.smithy.BuriedsNotify(session, changes)
|
||||||
if module, err = this.service.GetModule(core.M_Modules(k)); err != nil {
|
this.sociaty.BuriedsNotify(session, changes)
|
||||||
this.Error("通知条件变化异常 目标模块未找到!", log.Field{Key: "module", Value: k}, log.Field{Key: "err", Value: err.Error()})
|
// if len(notify) > 0 {
|
||||||
continue
|
// for k, v := range notify {
|
||||||
}
|
// if module, err = this.service.GetModule(core.M_Modules(k)); err != nil {
|
||||||
if nmodule, ok = module.(comm.IBuriedUpdateNotify); !ok {
|
// this.Error("通知条件变化异常 目标模块未找到!", log.Field{Key: "module", Value: k}, log.Field{Key: "err", Value: err.Error()})
|
||||||
this.Error("通知条件变化异常 目标模块未实现 IBuriedUpdateNotify 接口 !", log.Field{Key: "module", Value: k})
|
// continue
|
||||||
continue
|
// }
|
||||||
}
|
// if nmodule, ok = module.(comm.IBuriedUpdateNotify); !ok {
|
||||||
//异步通知指定模块
|
// this.Error("通知条件变化异常 目标模块未实现 IBuriedUpdateNotify 接口 !", log.Field{Key: "module", Value: k})
|
||||||
nmodule.BuriedsNotify(session, v)
|
// continue
|
||||||
}
|
// }
|
||||||
}
|
// //异步通知指定模块
|
||||||
|
// nmodule.BuriedsNotify(session, v)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// //通知事件
|
// //通知事件
|
||||||
// if len(changes) > 0 {
|
// if len(changes) > 0 {
|
||||||
|
@ -3,7 +3,6 @@ package smithy
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/sys/log"
|
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
@ -35,117 +34,6 @@ func (this *modelTask) getTaskRecord(uid string) (*pb.DBTujianTask, error) {
|
|||||||
return tt, nil
|
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 {
|
func (this *modelTask) updateTaskRecord(uid string, taskId int32) error {
|
||||||
dt, err := this.getTaskRecord(uid)
|
dt, err := this.getTaskRecord(uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/base"
|
"go_dreamfactory/lego/base"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
@ -17,6 +18,8 @@ import (
|
|||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var _ comm.ISmithy = (*Smithy)(nil)
|
||||||
|
|
||||||
type Smithy struct {
|
type Smithy struct {
|
||||||
modules.ModuleBase
|
modules.ModuleBase
|
||||||
service base.IRPCXService
|
service base.IRPCXService
|
||||||
@ -149,3 +152,109 @@ func (this *Smithy) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (r
|
|||||||
}
|
}
|
||||||
return
|
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.Debug("公会任务通知",
|
||||||
log.Field{Key: "uid", Value: session.GetUserId()},
|
log.Field{Key: "uid", Value: session.GetUserId()},
|
||||||
log.Field{Key: "condIds", Value: conds})
|
log.Field{Key: "condIds", Value: conds})
|
||||||
|
@ -19,6 +19,7 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.WTaskAcceptReq) (
|
|||||||
wtask *pb.DBWTask
|
wtask *pb.DBWTask
|
||||||
conf *cfg.GameWorldTaskData
|
conf *cfg.GameWorldTaskData
|
||||||
progress []*pb.DBWTaskItem
|
progress []*pb.DBWTaskItem
|
||||||
|
update map[string]interface{} = make(map[string]interface{})
|
||||||
ok bool
|
ok bool
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
@ -44,12 +45,18 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.WTaskAcceptReq) (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
ok = false
|
ok = false
|
||||||
if conf.Des != 5 {
|
|
||||||
for _, v := range wtask.Activations {
|
for _, v := range wtask.Activations {
|
||||||
if req.Tid == v {
|
if req.Tid == v {
|
||||||
ok = true
|
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 {
|
if !ok {
|
||||||
@ -68,15 +75,14 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.WTaskAcceptReq) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
wtask.Accepts = append(wtask.Accepts, req.Tid)
|
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 {
|
if progress, errdata = this.module.pushtaskprogress(session, wtask, false); errdata != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), "accept", &pb.WTaskAcceptResp{Tid: req.Tid, Activations: wtask.Activations, Accepts: progress})
|
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{}{
|
if err = this.module.modelwtask.Change(session.GetUserId(), update); err != nil {
|
||||||
"activations": wtask.Activations,
|
|
||||||
"accepts": wtask.Accepts,
|
|
||||||
}); err != nil {
|
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_DBError,
|
Code: pb.ErrorCode_DBError,
|
||||||
Title: pb.ErrorCode_DBError.ToString(),
|
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 (
|
var (
|
||||||
alltasks []*cfg.GameWorldTaskData
|
alltasks []*cfg.GameWorldTaskData
|
||||||
grouptask []*cfg.GameWorldTaskData = make([]*cfg.GameWorldTaskData, 0)
|
grouptask []*cfg.GameWorldTaskData = make([]*cfg.GameWorldTaskData, 0)
|
||||||
@ -185,8 +185,6 @@ func (this *WTask) AcceptCaravanTask(session comm.IUserSession, groupId int32) (
|
|||||||
wtask *pb.DBWTask
|
wtask *pb.DBWTask
|
||||||
err error
|
err error
|
||||||
ok bool
|
ok bool
|
||||||
changeActiva bool
|
|
||||||
changeAccept bool
|
|
||||||
)
|
)
|
||||||
alltasks = this.configure.getdesTask(5)
|
alltasks = this.configure.getdesTask(5)
|
||||||
for _, v := range alltasks {
|
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)
|
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})
|
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 {
|
if err = this.modelwtask.updateUserWTasks(session.GetUserId(), wtask); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_DBError,
|
Code: pb.ErrorCode_DBError,
|
||||||
@ -263,7 +243,8 @@ func (this *WTask) AcceptCaravanTask(session comm.IUserSession, groupId int32) (
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
tid = target.Key
|
||||||
|
groud = target.Group
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user