上传任务代码
This commit is contained in:
parent
62d0e300fc
commit
afe33770fd
@ -365,8 +365,8 @@ const (
|
|||||||
|
|
||||||
EventOpenCond core.Event_Key = "event_open_cond" //功能开放事件
|
EventOpenCond core.Event_Key = "event_open_cond" //功能开放事件
|
||||||
|
|
||||||
EventBuriedComplete core.Event_Key = "event_buried_complete" //埋点系统条件完成事件批处理接口 接口样例 func(uid string,conids []int32)
|
//EventBuriedComplete core.Event_Key = "event_buried_complete" //埋点系统条件完成事件批处理接口 接口样例 func(uid string,conids []int32)
|
||||||
EventFriendChange core.Event_Key = "event_friend_change" //加好友
|
EventFriendChange core.Event_Key = "event_friend_change" //加好友
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -12,7 +12,7 @@ type (
|
|||||||
}
|
}
|
||||||
//埋点中心更新通知
|
//埋点中心更新通知
|
||||||
IBuriedUpdateNotify interface {
|
IBuriedUpdateNotify interface {
|
||||||
BuriedsNotify(uid string, condis []*pb.ConIProgress)
|
BuriedsNotify(session IUserSession, condis []*pb.ConIProgress)
|
||||||
}
|
}
|
||||||
//任务完成
|
//任务完成
|
||||||
ITaskComplete interface {
|
ITaskComplete interface {
|
||||||
@ -538,6 +538,7 @@ type (
|
|||||||
}
|
}
|
||||||
// 世界任务
|
// 世界任务
|
||||||
IWtask interface {
|
IWtask interface {
|
||||||
|
IBuriedUpdateNotify
|
||||||
IOpenCmdNotice
|
IOpenCmdNotice
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/sys/event"
|
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
@ -549,15 +548,15 @@ func (this *Buried) trigger(session comm.IUserSession, burieds ...*pb.BuriedPara
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//异步通知指定模块
|
//异步通知指定模块
|
||||||
go nmodule.BuriedsNotify(session.GetUserId(), v)
|
nmodule.BuriedsNotify(session, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//通知事件
|
// //通知事件
|
||||||
if len(changes) > 0 {
|
// if len(changes) > 0 {
|
||||||
this.Debug("条件变化通知", log.Field{Key: "ConIds", Value: changes})
|
// this.Debug("条件变化通知", log.Field{Key: "ConIds", Value: changes})
|
||||||
event.TriggerEvent(comm.EventBuriedComplete, session.GetUserId(), changes)
|
// event.TriggerEvent(comm.EventBuriedComplete, session.GetUserId(), changes)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新并校验完成
|
// 更新并校验完成
|
||||||
|
@ -7,9 +7,6 @@ import (
|
|||||||
"go_dreamfactory/lego/sys/event"
|
"go_dreamfactory/lego/sys/event"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
|
||||||
|
|
||||||
"go_dreamfactory/lego/sys/log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -76,124 +73,3 @@ func (this *Combat) GetLevels(uid string) (levels map[int32]*pb.DBCombatLevel) {
|
|||||||
levels = combat.Level
|
levels = combat.Level
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//任务埋点通知
|
|
||||||
func (this *Combat) BuriedsNotify(uid string, condis []*pb.ConIProgress) {
|
|
||||||
this.Debug("收到埋点中心 进度改变通知", log.Field{Key: "uid", Value: uid}, log.Field{Key: "condis", Value: condis})
|
|
||||||
//废弃 采用主动询问机制
|
|
||||||
return
|
|
||||||
|
|
||||||
var (
|
|
||||||
err error
|
|
||||||
session comm.IUserSession
|
|
||||||
online bool
|
|
||||||
info *pb.DBCombatUser
|
|
||||||
lvconf *cfg.GameCombatLevelData
|
|
||||||
progress []*pb.LevelProgressItem
|
|
||||||
pitem *pb.LevelProgressItem
|
|
||||||
ok bool
|
|
||||||
pass bool
|
|
||||||
)
|
|
||||||
session, online = this.GetUserSession(uid)
|
|
||||||
defer func() {
|
|
||||||
if online {
|
|
||||||
session.Push()
|
|
||||||
}
|
|
||||||
this.PutUserSession(session)
|
|
||||||
}()
|
|
||||||
if info, err = this.modelCombat.queryInfo(uid); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
progress = make([]*pb.LevelProgressItem, 0)
|
|
||||||
for _, l := range info.Level {
|
|
||||||
l.Progress = 0
|
|
||||||
pitem = &pb.LevelProgressItem{
|
|
||||||
Level: l.Id,
|
|
||||||
Passmaintask: l.Passmaintask,
|
|
||||||
Passpertask: l.Passpertask,
|
|
||||||
Progress: l.Progress,
|
|
||||||
Pass: l.Pass,
|
|
||||||
Mainaward: make([]*pb.UserAssets, 0),
|
|
||||||
Peraward: make([]*pb.UserAssets, 0),
|
|
||||||
}
|
|
||||||
if l.Pass != 2 {
|
|
||||||
ok = false
|
|
||||||
pass = true
|
|
||||||
for _, v := range l.Passmaintask {
|
|
||||||
for _, v1 := range condis {
|
|
||||||
if v.Conid == v1.Conid {
|
|
||||||
ok = true
|
|
||||||
v.Value = v1.Value
|
|
||||||
v.State = v1.State
|
|
||||||
}
|
|
||||||
}
|
|
||||||
l.Progress += v.Value
|
|
||||||
if v.State != 1 {
|
|
||||||
pass = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if l.Pass == 0 && pass { //基础通关达成
|
|
||||||
l.Pass = 1
|
|
||||||
pitem.Pass = l.Pass
|
|
||||||
if lvconf, err = this.configure.getCombatLevel(l.Id); err != nil {
|
|
||||||
this.Error("BuriedsNotify 执行错误!", log.Field{Key: "err", Value: err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.DispenseRes(session, lvconf.Award, true)
|
|
||||||
atns := make([]*pb.UserAssets, len(lvconf.Award))
|
|
||||||
for i, v := range lvconf.Award {
|
|
||||||
atns[i] = &pb.UserAssets{
|
|
||||||
A: v.A,
|
|
||||||
T: v.T,
|
|
||||||
N: v.N,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pitem.Mainaward = atns
|
|
||||||
|
|
||||||
}
|
|
||||||
pass = true
|
|
||||||
for _, v := range l.Passpertask {
|
|
||||||
for _, v1 := range condis {
|
|
||||||
if v.Conid == v1.Conid {
|
|
||||||
ok = true
|
|
||||||
v.Value = v1.Value
|
|
||||||
v.State = v1.State
|
|
||||||
}
|
|
||||||
}
|
|
||||||
l.Progress += v.Value
|
|
||||||
if v.State != 1 {
|
|
||||||
pass = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if l.Pass == 1 && pass { //完美通关完成
|
|
||||||
l.Pass = 2
|
|
||||||
pitem.Pass = l.Pass
|
|
||||||
if lvconf, err = this.configure.getCombatLevel(l.Id); err != nil {
|
|
||||||
this.Error("BuriedsNotify 执行错误!", log.Field{Key: "err", Value: err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.DispenseRes(session, lvconf.Profectaward, true)
|
|
||||||
atns := make([]*pb.UserAssets, len(lvconf.Profectaward))
|
|
||||||
for i, v := range lvconf.Profectaward {
|
|
||||||
atns[i] = &pb.UserAssets{
|
|
||||||
A: v.A,
|
|
||||||
T: v.T,
|
|
||||||
N: v.N,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pitem.Peraward = atns
|
|
||||||
}
|
|
||||||
pitem.Progress = l.Progress
|
|
||||||
if ok {
|
|
||||||
progress = append(progress, pitem)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(progress) > 0 {
|
|
||||||
session.SendMsg(string(this.GetType()), "progress", &pb.CombatProgressPush{Levels: progress})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -24,7 +24,7 @@ func (this *apiComp) ClearCD(session comm.IUserSession, req *pb.PassonClearCDReq
|
|||||||
if errdata = this.ClearCDCheck(session, req); errdata != nil {
|
if errdata = this.ClearCDCheck(session, req); errdata != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if conf, err = this.module.configure.GetPassonConf(req.Index); err != nil {
|
if conf, err = this.module.configure.GetPassonConf(req.Index + 1); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_ConfigNoFound,
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
@ -87,7 +87,7 @@ func (this *apiComp) InRoom(session comm.IUserSession, req *pb.PassonInRoomReq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if passon.Student[req.Index].State != 2 {
|
if passon.Student[req.Index].State != 2 {
|
||||||
if conf, err = this.module.configure.GetPassonConf(req.Index); err != nil {
|
if conf, err = this.module.configure.GetPassonConf(req.Index + 1); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_ConfigNoFound,
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
@ -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/event"
|
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
@ -24,7 +23,7 @@ func (this *modelTask) Init(service core.IService, module core.IModule, comp cor
|
|||||||
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
||||||
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
||||||
})
|
})
|
||||||
event.Register(comm.EventBuriedComplete, this.TCondFinishNotify)
|
// event.Register(comm.EventBuriedComplete, this.TCondFinishNotify)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ 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/event"
|
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
@ -61,7 +60,7 @@ func (this *Sociaty) OnInstallComp() {
|
|||||||
this.modelSociatyLog = this.RegisterComp(new(ModelSociatyLog)).(*ModelSociatyLog)
|
this.modelSociatyLog = this.RegisterComp(new(ModelSociatyLog)).(*ModelSociatyLog)
|
||||||
this.modelSociatyBoss = this.RegisterComp(new(ModelSociatyBoss)).(*ModelSociatyBoss)
|
this.modelSociatyBoss = this.RegisterComp(new(ModelSociatyBoss)).(*ModelSociatyBoss)
|
||||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||||
event.Register(comm.EventBuriedComplete, this.TCondFinishNotify)
|
// event.Register(comm.EventBuriedComplete, this.TCondFinishNotify)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Sociaty) Start() (err error) {
|
func (this *Sociaty) Start() (err error) {
|
||||||
@ -275,12 +274,12 @@ type TaskParams struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 任务条件达成通知
|
// 任务条件达成通知
|
||||||
func (this *Sociaty) TCondFinishNotify(uid string, conds []*pb.ConIProgress) {
|
func (this *Sociaty) TCondFinishNotify(session comm.IUserSession, conds []*pb.ConIProgress) {
|
||||||
log.Debug("公会任务通知",
|
log.Debug("公会任务通知",
|
||||||
log.Field{Key: "uid", Value: uid},
|
log.Field{Key: "uid", Value: session.GetUserId()},
|
||||||
log.Field{Key: "condIds", Value: conds})
|
log.Field{Key: "condIds", Value: conds})
|
||||||
|
|
||||||
sociaty := this.modelSociaty.getUserSociaty(uid)
|
sociaty := this.modelSociaty.getUserSociaty(session.GetUserId())
|
||||||
if sociaty == nil {
|
if sociaty == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -290,7 +289,7 @@ func (this *Sociaty) TCondFinishNotify(uid string, conds []*pb.ConIProgress) {
|
|||||||
dt := &pb.DBSociatyTask{}
|
dt := &pb.DBSociatyTask{}
|
||||||
err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
|
err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
|
||||||
comm.Service_Worker, string(comm.Rpc_ModuleSociatyGetTask),
|
comm.Service_Worker, string(comm.Rpc_ModuleSociatyGetTask),
|
||||||
&pb.RPCGeneralReqA2{Param1: sociatyId, Param2: uid}, dt)
|
&pb.RPCGeneralReqA2{Param1: sociatyId, Param2: session.GetUserId()}, dt)
|
||||||
|
|
||||||
var flag bool
|
var flag bool
|
||||||
for _, v := range dt.TaskList {
|
for _, v := range dt.TaskList {
|
||||||
@ -312,7 +311,7 @@ func (this *Sociaty) TCondFinishNotify(uid string, conds []*pb.ConIProgress) {
|
|||||||
|
|
||||||
err = this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
|
err = this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
|
||||||
comm.Service_Worker, string(comm.Rpc_ModuleSociatyTask),
|
comm.Service_Worker, string(comm.Rpc_ModuleSociatyTask),
|
||||||
&TaskParams{SociatyId: sociatyId, Uid: uid, Data: update}, &pb.EmptyResp{})
|
&TaskParams{SociatyId: sociatyId, Uid: session.GetUserId(), Data: update}, &pb.EmptyResp{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/sys/event"
|
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
@ -48,7 +47,7 @@ func (this *WTask) Start() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.modelSys = module.(comm.ISys)
|
this.modelSys = module.(comm.ISys)
|
||||||
event.Register(comm.EventBuriedComplete, this.BuriedsNotify)
|
// event.Register(comm.EventBuriedComplete, this.BuriedsNotify)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,9 +60,8 @@ func (this *WTask) OnInstallComp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 埋点通知
|
// 埋点通知
|
||||||
func (this *WTask) BuriedsNotify(uid string, condis []*pb.ConIProgress) {
|
func (this *WTask) BuriedsNotify(session comm.IUserSession, condis []*pb.ConIProgress) {
|
||||||
var (
|
var (
|
||||||
session comm.IUserSession
|
|
||||||
condisMap map[int32]*pb.ConIProgress = make(map[int32]*pb.ConIProgress)
|
condisMap map[int32]*pb.ConIProgress = make(map[int32]*pb.ConIProgress)
|
||||||
utask *pb.DBWTask
|
utask *pb.DBWTask
|
||||||
accepttaskMap map[int32]struct{} = make(map[int32]struct{})
|
accepttaskMap map[int32]struct{} = make(map[int32]struct{})
|
||||||
@ -78,8 +76,8 @@ func (this *WTask) BuriedsNotify(uid string, condis []*pb.ConIProgress) {
|
|||||||
|
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
this.Debug("收到子任务进度变化推送", log.Field{Key: "uid", Value: uid}, log.Field{Key: "condis", Value: condis})
|
this.Debug("收到子任务进度变化推送", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "condis", Value: condis})
|
||||||
if utask, err = this.modelwtask.getUserWTasks(uid); err != nil {
|
if utask, err = this.modelwtask.getUserWTasks(session.GetUserId()); err != nil {
|
||||||
this.Error("读取玩家世界任务数据 失败", log.Field{Key: "err", Value: err.Error()})
|
this.Error("读取玩家世界任务数据 失败", log.Field{Key: "err", Value: err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -119,7 +117,7 @@ func (this *WTask) BuriedsNotify(uid string, condis []*pb.ConIProgress) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if needcheck { //校验有变化的任务 的完成条件
|
if needcheck { //校验有变化的任务 的完成条件
|
||||||
if condis, err = this.ModuleBuried.CheckCondition(uid, checkcondls...); err != nil {
|
if condis, err = this.ModuleBuried.CheckCondition(session.GetUserId(), checkcondls...); err != nil {
|
||||||
this.Error("校验玩家子任务进度数据 失败", log.Field{Key: "err", Value: err.Error()})
|
this.Error("校验玩家子任务进度数据 失败", log.Field{Key: "err", Value: err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -139,12 +137,6 @@ func (this *WTask) BuriedsNotify(uid string, condis []*pb.ConIProgress) {
|
|||||||
}
|
}
|
||||||
detailstasks = append(detailstasks, task)
|
detailstasks = append(detailstasks, task)
|
||||||
}
|
}
|
||||||
|
|
||||||
session, _ = this.GetUserSession(uid)
|
|
||||||
defer func() {
|
|
||||||
session.Push()
|
|
||||||
this.PutUserSession(session)
|
|
||||||
}()
|
|
||||||
//发送进度变化消息
|
//发送进度变化消息
|
||||||
session.SendMsg(string(this.GetType()), "acceptchange", &pb.WTaskAcceptChangePush{Accepts: detailstasks})
|
session.SendMsg(string(this.GetType()), "acceptchange", &pb.WTaskAcceptChangePush{Accepts: detailstasks})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user