修复战斗记录过期机制
This commit is contained in:
parent
6f40d053ff
commit
d2ea61c01e
@ -128,6 +128,7 @@ const (
|
|||||||
ModuleMonkey core.M_Modules = "monkey" //猴拳
|
ModuleMonkey core.M_Modules = "monkey" //猴拳
|
||||||
ModuleIntegral core.M_Modules = "integral" // 积分boss
|
ModuleIntegral core.M_Modules = "integral" // 积分boss
|
||||||
ModulePlunder core.M_Modules = "plunder" //掠夺
|
ModulePlunder core.M_Modules = "plunder" //掠夺
|
||||||
|
ModuleMergeGroup core.M_Modules = "mergegroup" //合区模块
|
||||||
)
|
)
|
||||||
|
|
||||||
// 数据表名定义处
|
// 数据表名定义处
|
||||||
|
@ -3,6 +3,7 @@ package comm
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -658,7 +659,7 @@ type (
|
|||||||
}
|
}
|
||||||
//战斗记录模块
|
//战斗记录模块
|
||||||
IBattleRecord interface {
|
IBattleRecord interface {
|
||||||
WrietBattleRecord(uid string, report *pb.BattleReport, expire int64)
|
WrietBattleRecord(uid string, report *pb.BattleReport, expire time.Time)
|
||||||
}
|
}
|
||||||
IDragon interface {
|
IDragon interface {
|
||||||
//获取玩家坐骑列表
|
//获取玩家坐骑列表
|
||||||
|
12
modules/battlerecord/core.go
Normal file
12
modules/battlerecord/core.go
Normal file
@ -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"` //过期时间
|
||||||
|
}
|
@ -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 {
|
if _, err = this.model.DB.InsertOne(core.SqlTable(this.model.TableName), result); err != nil {
|
||||||
this.module.Errorln(err)
|
this.module.Errorln(err)
|
||||||
return
|
return
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"time"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"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 (
|
var (
|
||||||
result *pb.DBBattlePlayRecord
|
result *DBBattlePlayRecord
|
||||||
model *recordModel
|
model *recordModel
|
||||||
data []byte
|
data []byte
|
||||||
err error
|
err error
|
||||||
@ -65,7 +66,7 @@ func (this *BattleRecord) WrietBattleRecord(uid string, report *pb.BattleReport,
|
|||||||
this.Errorln(err)
|
this.Errorln(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
result = &pb.DBBattlePlayRecord{
|
result = &DBBattlePlayRecord{
|
||||||
Id: report.Info.Id,
|
Id: report.Info.Id,
|
||||||
Record: data,
|
Record: data,
|
||||||
ExpireAt: expire,
|
ExpireAt: expire,
|
||||||
|
@ -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{
|
session.SendMsg(string(this.module.GetType()), "challengefinish", &pb.GuildGveChallengeFinishResp{
|
||||||
Guildid: req.Guildid,
|
Guildid: req.Guildid,
|
||||||
Boosid: req.Boosid,
|
Boosid: req.Boosid,
|
||||||
|
60
modules/mergegroup/module.go
Normal file
60
modules/mergegroup/module.go
Normal file
@ -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() {
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,7 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go_dreamfactory/modules/matchpool"
|
"go_dreamfactory/modules/matchpool"
|
||||||
|
"go_dreamfactory/modules/mergegroup"
|
||||||
"go_dreamfactory/modules/mgolog"
|
"go_dreamfactory/modules/mgolog"
|
||||||
"go_dreamfactory/modules/timer"
|
"go_dreamfactory/modules/timer"
|
||||||
"go_dreamfactory/modules/web"
|
"go_dreamfactory/modules/web"
|
||||||
@ -40,6 +41,7 @@ func main() {
|
|||||||
web.NewModule(),
|
web.NewModule(),
|
||||||
timer.NewModule(),
|
timer.NewModule(),
|
||||||
matchpool.NewModule(),
|
matchpool.NewModule(),
|
||||||
|
mergegroup.NewModule(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user