diff --git a/comm/const.go b/comm/const.go index ecbe81bfb..26ebc1008 100644 --- a/comm/const.go +++ b/comm/const.go @@ -128,6 +128,7 @@ const ( ModuleMonkey core.M_Modules = "monkey" //猴拳 ModuleIntegral core.M_Modules = "integral" // 积分boss ModulePlunder core.M_Modules = "plunder" //掠夺 + ModuleMergeGroup core.M_Modules = "mergegroup" //合区模块 ) // 数据表名定义处 diff --git a/comm/imodule.go b/comm/imodule.go index 8899e6c09..a810fb174 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -3,6 +3,7 @@ package comm import ( "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" + "time" ) type ( @@ -658,7 +659,7 @@ type ( } //战斗记录模块 IBattleRecord interface { - WrietBattleRecord(uid string, report *pb.BattleReport, expire int64) + WrietBattleRecord(uid string, report *pb.BattleReport, expire time.Time) } IDragon interface { //获取玩家坐骑列表 diff --git a/modules/battlerecord/core.go b/modules/battlerecord/core.go new file mode 100644 index 000000000..9af2ee0da --- /dev/null +++ b/modules/battlerecord/core.go @@ -0,0 +1,12 @@ +package battlerecord + +import ( + "time" +) + +//战斗记录 +type DBBattlePlayRecord struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //唯一ID + Record []byte `protobuf:"bytes,3,opt,name=record,proto3" json:"record"` //BattleReport 的序列化数据 + ExpireAt time.Time `json:"expireAt" bson:"expireAt"` //过期时间 +} diff --git a/modules/battlerecord/model.go b/modules/battlerecord/model.go index 8ec304d67..21995d9d2 100644 --- a/modules/battlerecord/model.go +++ b/modules/battlerecord/model.go @@ -82,7 +82,7 @@ func (this *recordModel) inquire(bid string) (result *pb.DBBattlePlayRecord, err } //插入记录 -func (this *recordModel) addRecord(result *pb.DBBattlePlayRecord) (err error) { +func (this *recordModel) addRecord(result *DBBattlePlayRecord) (err error) { if _, err = this.model.DB.InsertOne(core.SqlTable(this.model.TableName), result); err != nil { this.module.Errorln(err) return diff --git a/modules/battlerecord/module.go b/modules/battlerecord/module.go index 4007c3fc8..04e2668c6 100644 --- a/modules/battlerecord/module.go +++ b/modules/battlerecord/module.go @@ -5,6 +5,7 @@ import ( "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" + "time" "google.golang.org/protobuf/proto" ) @@ -54,9 +55,9 @@ func (this *BattleRecord) Start() (err error) { } //写入战斗记录 -func (this *BattleRecord) WrietBattleRecord(uid string, report *pb.BattleReport, expire int64) { +func (this *BattleRecord) WrietBattleRecord(uid string, report *pb.BattleReport, expire time.Time) { var ( - result *pb.DBBattlePlayRecord + result *DBBattlePlayRecord model *recordModel data []byte err error @@ -65,7 +66,7 @@ func (this *BattleRecord) WrietBattleRecord(uid string, report *pb.BattleReport, this.Errorln(err) return } - result = &pb.DBBattlePlayRecord{ + result = &DBBattlePlayRecord{ Id: report.Info.Id, Record: data, ExpireAt: expire, diff --git a/modules/guildgve/api_challengefinish.go b/modules/guildgve/api_challengefinish.go index 89395bb50..fa0383b1b 100644 --- a/modules/guildgve/api_challengefinish.go +++ b/modules/guildgve/api_challengefinish.go @@ -195,7 +195,7 @@ func (this *apiComp) ChallengeFinish(session comm.IUserSession, req *pb.GuildGve } } //写入战斗记录 - go this.module.battlerecord.WrietBattleRecord(session.GetUserId(), req.Report, time.Now().Add(time.Hour*24*8).Unix()) + go this.module.battlerecord.WrietBattleRecord(session.GetUserId(), req.Report, time.Now().Add(time.Hour*24*8)) session.SendMsg(string(this.module.GetType()), "challengefinish", &pb.GuildGveChallengeFinishResp{ Guildid: req.Guildid, Boosid: req.Boosid, diff --git a/modules/mergegroup/module.go b/modules/mergegroup/module.go new file mode 100644 index 000000000..557b42d9c --- /dev/null +++ b/modules/mergegroup/module.go @@ -0,0 +1,60 @@ +package mergegroup + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/core" + "go_dreamfactory/lego/core/cbase" + "go_dreamfactory/lego/sys/cron" + "go_dreamfactory/lego/sys/log" + "go_dreamfactory/sys/db" +) + +/* +模块名称:动态合服模块 +运行服务:mainte +运行区服:跨服环境下运行 +开发:李伟 +*/ + +func NewModule() core.IModule { + m := new(MergeGroup) + return m +} + +type MergeGroup struct { + cbase.ModuleBase +} + +func (this *MergeGroup) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { + if err = this.ModuleBase.Init(service, module, options); err != nil { + return + } + + return +} + +func (this *MergeGroup) GetType() core.M_Modules { + return comm.ModuleMergeGroup +} + +func (this *MergeGroup) OnInstallComp() { + this.ModuleBase.OnInstallComp() + +} + +func (this *MergeGroup) Start() (err error) { + if err = this.ModuleBase.Start(); err != nil { + return + } + if db.IsCross() { + if _, err = cron.AddFunc("0 59 23 ? * SAT", this.CheckMerge); err != nil { + log.Errorln(err) + } + } + return +} + +//检查合并 +func (this *MergeGroup) CheckMerge() { + +} diff --git a/services/mainte/main.go b/services/mainte/main.go index cd4ef0f04..0fe842345 100644 --- a/services/mainte/main.go +++ b/services/mainte/main.go @@ -4,6 +4,7 @@ import ( "flag" "fmt" "go_dreamfactory/modules/matchpool" + "go_dreamfactory/modules/mergegroup" "go_dreamfactory/modules/mgolog" "go_dreamfactory/modules/timer" "go_dreamfactory/modules/web" @@ -40,6 +41,7 @@ func main() { web.NewModule(), timer.NewModule(), matchpool.NewModule(), + mergegroup.NewModule(), ) }