From 8ed57d862cb28335cd1fdfd3ea735508e88e46f8 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 29 May 2023 16:22:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=9F=8B=E7=82=B9=E4=B8=AD?= =?UTF-8?q?=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 7 +++-- comm/imodule.go | 9 ++++++ modules/buried/core.go | 2 +- modules/buried/module.go | 31 +++++++++++++------ modules/modulebase.go | 5 ++++ modules/worldtask/module.go | 6 ++++ pb/buried_db.pb.go | 60 ++++++++++++++++++------------------- services/worker/main.go | 2 ++ 8 files changed, 79 insertions(+), 43 deletions(-) diff --git a/comm/const.go b/comm/const.go index 81e6f6bac..ca3f718ec 100644 --- a/comm/const.go +++ b/comm/const.go @@ -461,9 +461,10 @@ type TaskParam struct { Params []int32 } type BuriedParam struct { - Btype TaskType - Value int32 - Filter []int32 + Btype TaskType + Value int32 //累加或者覆盖参数 + Statistics string //统计类型 传递参数 + Filter []int32 } // 日常任务事件类型 diff --git a/comm/imodule.go b/comm/imodule.go index 028ce07b6..044c848f0 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -501,4 +501,13 @@ type ( ITaskComplete TestFunc(session IUserSession) } + //埋点中心 + IBuried interface { + //埋点中心触发 + TriggerBuried(uid string, burieds ...*BuriedParam) + //校验条件是否达成 + CheckCondition(uid string, condiIds ...int32) (condIds []int32) + //激活条件 + ActiveCondition(uid string, condiIds ...int32) + } ) diff --git a/modules/buried/core.go b/modules/buried/core.go index 5a9db5b57..8bde1a95e 100644 --- a/modules/buried/core.go +++ b/modules/buried/core.go @@ -19,7 +19,7 @@ const ( //累加 overlay = 2 //统计 - stats = 3 + statistics = 3 ) const ( diff --git a/modules/buried/module.go b/modules/buried/module.go index 40c36350f..8e556d92d 100644 --- a/modules/buried/module.go +++ b/modules/buried/module.go @@ -58,11 +58,16 @@ func (this *Buried) OnInstallComp() { } //激活数据采集点 -func (this *Buried) ActivationBuried(uid string, conids ...int32) (err error) { +func (this *Buried) ActiveCondition(uid string, condiIds ...int32) { return } +//激活数据采集点 +func (this *Buried) CheckCondition(uid string, condiIds ...int32) (condIds []int32) { + return +} + //触发埋点 func (this *Buried) TriggerBuried(uid string, burieds ...*comm.BuriedParam) { var ( @@ -151,11 +156,11 @@ func (this *Buried) updateAndCheckBuried(bconf *cfg.GameBuriedTypeData, bdata *p if bitem, ok = bdata.Items[int32(cond.Id)]; !ok { if autoActivated { //自动激活 bitem = &pb.DBBuriedItem{ - Conid: cond.Id, - State: pb.BuriedItemState_Activated, - Value: 0, - Stats: make([]string, 0), - Timestamp: time.Now().Unix(), + Conid: cond.Id, + State: pb.BuriedItemState_Activated, + Value: 0, + Statistics: make([]string, 0), + Timestamp: time.Now().Unix(), } } else { return @@ -171,9 +176,17 @@ func (this *Buried) updateAndCheckBuried(bconf *cfg.GameBuriedTypeData, bdata *p bitem.Value += collec.Value case cover: bitem.Value = collec.Value - case stats: - bitem.Stats = append(bitem.Stats, "") - bitem.Value = int32(len(bitem.Stats)) + case statistics: + ok = true + for _, v := range bitem.Statistics { + if v == collec.Statistics { //已统计过 + ok = false + } + } + if ok { + bitem.Statistics = append(bitem.Statistics, "") + bitem.Value = int32(len(bitem.Statistics)) + } default: err = fmt.Errorf("未知的埋点数据处理类型:%d", bconf.Insert) return diff --git a/modules/modulebase.go b/modules/modulebase.go index 24b7d5ab3..ac950ed5d 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -42,6 +42,7 @@ type ModuleBase struct { ModulePractice comm.IPractice //练功房 ModuleParkour comm.IParkour //捕羊大赛 ModuleTools comm.ITools //工具类 获取一些通用配置 + ModuleBuried comm.IBuried //触发埋点中心 } // 重构模块配置对象 @@ -135,6 +136,10 @@ func (this *ModuleBase) Start() (err error) { return } this.ModuleTools = module.(comm.ITools) + if module, err = this.service.GetModule(comm.ModuleBuried); err != nil { + return + } + this.ModuleBuried = module.(comm.IBuried) return } diff --git a/modules/worldtask/module.go b/modules/worldtask/module.go index f548731ef..cc0593196 100644 --- a/modules/worldtask/module.go +++ b/modules/worldtask/module.go @@ -4,6 +4,7 @@ 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" @@ -45,6 +46,7 @@ func (this *Worldtask) GetType() core.M_Modules { func (this *Worldtask) Start() (err error) { err = this.ModuleBase.Start() + event.RegisterGO(comm.EventBuriedComplete, this.ConditionFinishNotify) if this.worldtaskConf, err = this.configure.getWorldtaskCfg(); err != nil { return err } @@ -331,3 +333,7 @@ func (this *Worldtask) UpdateTaskStatus(uid string, taskId int32) { } } + +func (this *Worldtask) ConditionFinishNotify(uid string, condIds []int32) { + +} diff --git a/pb/buried_db.pb.go b/pb/buried_db.pb.go index f266bff11..a37f2f6f6 100644 --- a/pb/buried_db.pb.go +++ b/pb/buried_db.pb.go @@ -79,11 +79,11 @@ type DBBuriedItem struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Conid int32 `protobuf:"varint,1,opt,name=conid,proto3" json:"conid" bson:"conid"` //条件id - State BuriedItemState `protobuf:"varint,2,opt,name=state,proto3,enum=BuriedItemState" json:"state" bson:"state"` //状态 - Value int32 `protobuf:"varint,3,opt,name=value,proto3" json:"value" bson:"value"` //条件值 - Stats []string `protobuf:"bytes,4,rep,name=stats,proto3" json:"stats" bson:"stats"` //统计值 - Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp" bson:"timestamp"` //最后一次操作时间 + Conid int32 `protobuf:"varint,1,opt,name=conid,proto3" json:"conid" bson:"conid"` //条件id + State BuriedItemState `protobuf:"varint,2,opt,name=state,proto3,enum=BuriedItemState" json:"state" bson:"state"` //状态 + Value int32 `protobuf:"varint,3,opt,name=value,proto3" json:"value" bson:"value"` //条件值 + Statistics []string `protobuf:"bytes,4,rep,name=statistics,proto3" json:"statistics" bson:"stats"` //统计值 + Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp" bson:"timestamp"` //最后一次操作时间 } func (x *DBBuriedItem) Reset() { @@ -139,9 +139,9 @@ func (x *DBBuriedItem) GetValue() int32 { return 0 } -func (x *DBBuriedItem) GetStats() []string { +func (x *DBBuriedItem) GetStatistics() []string { if x != nil { - return x.Stats + return x.Statistics } return nil } @@ -229,34 +229,34 @@ var File_buried_buried_db_proto protoreflect.FileDescriptor var file_buried_buried_db_proto_rawDesc = []byte{ 0x0a, 0x16, 0x62, 0x75, 0x72, 0x69, 0x65, 0x64, 0x2f, 0x62, 0x75, 0x72, 0x69, 0x65, 0x64, 0x5f, - 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x96, 0x01, 0x0a, 0x0c, 0x44, 0x42, 0x42, + 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa0, 0x01, 0x0a, 0x0c, 0x44, 0x42, 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6e, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x6e, 0x69, 0x64, 0x12, 0x26, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x14, 0x0a, - 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, - 0x61, 0x74, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x22, 0xb7, 0x01, 0x0a, 0x08, 0x44, 0x42, 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, - 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, - 0x12, 0x14, 0x0a, 0x05, 0x62, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x05, 0x62, 0x74, 0x79, 0x70, 0x65, 0x12, 0x2a, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, - 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x44, 0x42, 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, - 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x69, 0x74, 0x65, - 0x6d, 0x73, 0x1a, 0x47, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x23, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, 0x48, 0x0a, 0x0f, 0x42, - 0x75, 0x72, 0x69, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0f, - 0x0a, 0x0b, 0x49, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x64, 0x10, 0x00, 0x12, - 0x0d, 0x0a, 0x09, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x64, 0x10, 0x01, 0x12, 0x0a, - 0x0a, 0x06, 0x46, 0x72, 0x65, 0x65, 0x7a, 0x65, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6c, - 0x65, 0x65, 0x70, 0x10, 0x03, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1e, 0x0a, + 0x0a, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x12, 0x1c, 0x0a, + 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xb7, 0x01, 0x0a, 0x08, + 0x44, 0x42, 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x62, 0x74, 0x79, 0x70, 0x65, + 0x12, 0x2a, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x14, 0x2e, 0x44, 0x42, 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x73, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x1a, 0x47, 0x0a, 0x0a, + 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x23, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, + 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, 0x48, 0x0a, 0x0f, 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, 0x49, + 0x74, 0x65, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x49, 0x6e, 0x61, 0x63, + 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x64, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x41, 0x63, 0x74, + 0x69, 0x76, 0x61, 0x74, 0x65, 0x64, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x72, 0x65, 0x65, + 0x7a, 0x65, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6c, 0x65, 0x65, 0x70, 0x10, 0x03, 0x42, + 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/services/worker/main.go b/services/worker/main.go index 5ab8caa3c..a6ab385fc 100644 --- a/services/worker/main.go +++ b/services/worker/main.go @@ -7,6 +7,7 @@ import ( "go_dreamfactory/modules/arena" "go_dreamfactory/modules/atlas" "go_dreamfactory/modules/battle" + "go_dreamfactory/modules/buried" "go_dreamfactory/modules/caravan" "go_dreamfactory/modules/chat" "go_dreamfactory/modules/combat" @@ -122,6 +123,7 @@ func main() { reputation.NewModule(), oldtimes.NewModule(), caravan.NewModule(), + buried.NewModule(), ) }