Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
ae2747e484
@ -365,8 +365,8 @@ const (
|
||||
|
||||
EventOpenCond core.Event_Key = "event_open_cond" //功能开放事件
|
||||
|
||||
EventBuriedComplete core.Event_Key = "event_buried_complete" //埋点系统条件完成事件批处理接口 接口样例 func(uid string,conids []int32)
|
||||
EventFriendChange core.Event_Key = "event_friend_change" //加好友
|
||||
//EventBuriedComplete core.Event_Key = "event_buried_complete" //埋点系统条件完成事件批处理接口 接口样例 func(uid string,conids []int32)
|
||||
EventFriendChange core.Event_Key = "event_friend_change" //加好友
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -12,7 +12,7 @@ type (
|
||||
}
|
||||
//埋点中心更新通知
|
||||
IBuriedUpdateNotify interface {
|
||||
BuriedsNotify(uid string, condis []*pb.ConIProgress)
|
||||
BuriedsNotify(session IUserSession, condis []*pb.ConIProgress)
|
||||
}
|
||||
//任务完成
|
||||
ITaskComplete interface {
|
||||
@ -538,6 +538,7 @@ type (
|
||||
}
|
||||
// 世界任务
|
||||
IWtask interface {
|
||||
IBuriedUpdateNotify
|
||||
IOpenCmdNotice
|
||||
}
|
||||
)
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
@ -549,15 +548,15 @@ func (this *Buried) trigger(session comm.IUserSession, burieds ...*pb.BuriedPara
|
||||
continue
|
||||
}
|
||||
//异步通知指定模块
|
||||
go nmodule.BuriedsNotify(session.GetUserId(), v)
|
||||
nmodule.BuriedsNotify(session, v)
|
||||
}
|
||||
}
|
||||
|
||||
//通知事件
|
||||
if len(changes) > 0 {
|
||||
this.Debug("条件变化通知", log.Field{Key: "ConIds", Value: changes})
|
||||
event.TriggerEvent(comm.EventBuriedComplete, session.GetUserId(), changes)
|
||||
}
|
||||
// //通知事件
|
||||
// if len(changes) > 0 {
|
||||
// this.Debug("条件变化通知", log.Field{Key: "ConIds", Value: changes})
|
||||
// event.TriggerEvent(comm.EventBuriedComplete, session.GetUserId(), changes)
|
||||
// }
|
||||
}
|
||||
|
||||
// 更新并校验完成
|
||||
|
@ -7,9 +7,6 @@ import (
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
"go_dreamfactory/modules"
|
||||
"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
|
||||
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 {
|
||||
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{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
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 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{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
@ -113,6 +113,10 @@ func (this *apiComp) InRoom(session comm.IUserSession, req *pb.PassonInRoomReq)
|
||||
if errdata = this.module.ModuleHero.PassonHero(session, map[string]bool{hero.Id: true}); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
passon.Student[req.Index].State = 1
|
||||
passon.Student[req.Index].Heroid = hero.Id
|
||||
|
||||
if err = this.module.modelPasson.updateUserPasson(session.GetUserId(), passon); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
|
@ -36,12 +36,12 @@ func (this *apiComp) OutRoom(session comm.IUserSession, req *pb.PassonOutRoomReq
|
||||
}
|
||||
return
|
||||
}
|
||||
passon.Student[req.Index].State = 2
|
||||
passon.Student[req.Index].Cdtime = configure.Now().Unix()
|
||||
|
||||
if errdata = this.module.ModuleHero.PassonHero(session, map[string]bool{req.Heroid: false}); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
passon.Student[req.Index].State = 2
|
||||
passon.Student[req.Index].Cdtime = configure.Now().Unix()
|
||||
if err = this.module.modelPasson.updateUserPasson(session.GetUserId(), passon); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
|
@ -3,7 +3,6 @@ package smithy
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"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{
|
||||
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
||||
})
|
||||
event.Register(comm.EventBuriedComplete, this.TCondFinishNotify)
|
||||
// event.Register(comm.EventBuriedComplete, this.TCondFinishNotify)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/base"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
@ -61,7 +60,7 @@ func (this *Sociaty) OnInstallComp() {
|
||||
this.modelSociatyLog = this.RegisterComp(new(ModelSociatyLog)).(*ModelSociatyLog)
|
||||
this.modelSociatyBoss = this.RegisterComp(new(ModelSociatyBoss)).(*ModelSociatyBoss)
|
||||
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) {
|
||||
@ -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.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "uid", Value: session.GetUserId()},
|
||||
log.Field{Key: "condIds", Value: conds})
|
||||
|
||||
sociaty := this.modelSociaty.getUserSociaty(uid)
|
||||
sociaty := this.modelSociaty.getUserSociaty(session.GetUserId())
|
||||
if sociaty == nil {
|
||||
return
|
||||
}
|
||||
@ -290,7 +289,7 @@ func (this *Sociaty) TCondFinishNotify(uid string, conds []*pb.ConIProgress) {
|
||||
dt := &pb.DBSociatyTask{}
|
||||
err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
|
||||
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
|
||||
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(),
|
||||
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 {
|
||||
return
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
@ -48,7 +47,7 @@ func (this *WTask) Start() (err error) {
|
||||
return
|
||||
}
|
||||
this.modelSys = module.(comm.ISys)
|
||||
event.Register(comm.EventBuriedComplete, this.BuriedsNotify)
|
||||
// event.Register(comm.EventBuriedComplete, this.BuriedsNotify)
|
||||
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 (
|
||||
session comm.IUserSession
|
||||
condisMap map[int32]*pb.ConIProgress = make(map[int32]*pb.ConIProgress)
|
||||
utask *pb.DBWTask
|
||||
accepttaskMap map[int32]struct{} = make(map[int32]struct{})
|
||||
@ -78,8 +76,8 @@ func (this *WTask) BuriedsNotify(uid string, condis []*pb.ConIProgress) {
|
||||
|
||||
err error
|
||||
)
|
||||
this.Debug("收到子任务进度变化推送", log.Field{Key: "uid", Value: uid}, log.Field{Key: "condis", Value: condis})
|
||||
if utask, err = this.modelwtask.getUserWTasks(uid); err != nil {
|
||||
this.Debug("收到子任务进度变化推送", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "condis", Value: condis})
|
||||
if utask, err = this.modelwtask.getUserWTasks(session.GetUserId()); err != nil {
|
||||
this.Error("读取玩家世界任务数据 失败", log.Field{Key: "err", Value: err.Error()})
|
||||
return
|
||||
}
|
||||
@ -119,7 +117,7 @@ func (this *WTask) BuriedsNotify(uid string, condis []*pb.ConIProgress) {
|
||||
}
|
||||
}
|
||||
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()})
|
||||
return
|
||||
}
|
||||
@ -139,12 +137,6 @@ func (this *WTask) BuriedsNotify(uid string, condis []*pb.ConIProgress) {
|
||||
}
|
||||
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})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user