赛季结束刷新

This commit is contained in:
meixiongfeng 2024-01-29 18:46:41 +08:00
parent 9721eacc5e
commit d64dc44390
2 changed files with 40 additions and 1 deletions

View File

@ -1,10 +1,14 @@
package plunder package plunder
import ( import (
"fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure" "go_dreamfactory/sys/configure"
"go_dreamfactory/utils" "go_dreamfactory/utils"
"go.mongodb.org/mongo-driver/bson"
) )
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.PlunderGetListReq) (errdata *pb.ErrorData) { func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.PlunderGetListReq) (errdata *pb.ErrorData) {
@ -42,10 +46,34 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PlunderGetListRe
list.Landid = land.Id list.Landid = land.Id
update["landid"] = land.Id update["landid"] = land.Id
} else { } else {
var uids []string
etime := this.module.modelLand.GetEndTime()
// 清理岛数据
if land.Etime > configure.Now().Unix() {
land.Etime = etime
for _, v := range land.Uinfo { // 重置成员信息
uids = append(uids, v.Uid)
}
if _, err = this.module.modelPlunder.DB.UpdateMany(core.SqlTable(comm.TablePlunder), bson.M{"uid": bson.M{"$in": uids}}, bson.M{"$set": bson.M{"landid": land.Id}}); err != nil {
fmt.Printf("err:%v", err)
return
}
}
// 校验是否过期 // 校验是否过期
if list.Etime > configure.Now().Unix() { if list.Etime > configure.Now().Unix() {
if land, err = this.module.modelLand.createPlunderLandData(list); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Message: err.Error(),
}
return
}
list.Landid = land.Id
update["landid"] = land.Id
list.Etime = etime
update["etime"] = land.Etime
} }
if land, err = this.module.modelLand.getPlunderLandData(list.Landid); err != nil { if land, err = this.module.modelLand.getPlunderLandData(list.Landid); err != nil {
errdata = &pb.ErrorData{ errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError, Code: pb.ErrorCode_DBError,

View File

@ -60,6 +60,7 @@ func (this *modelLand) createPlunderLandData(user *pb.DBPlunder) (land *pb.DBPlu
Score: make(map[string]int32, 0), Score: make(map[string]int32, 0),
Etime: utils.GetTodayZeroTime(configure.Now().Unix()) + 48*3600, // 临时处理 后面走配置 Etime: utils.GetTodayZeroTime(configure.Now().Unix()) + 48*3600, // 临时处理 后面走配置
} }
socre = user.Score - 100 socre = user.Score - 100
if socre < 0 { if socre < 0 {
socre = 0 socre = 0
@ -101,3 +102,13 @@ func (this *modelLand) createPlunderLandData(user *pb.DBPlunder) (land *pb.DBPlu
func (this *modelLand) landMutexLock(oid string) (result *redis.RedisMutex, err error) { func (this *modelLand) landMutexLock(oid string) (result *redis.RedisMutex, err error) {
return this.module.modelLand.NewRedisMutex(fmt.Sprintf("%s-%s_lock", this.TableName, oid), 5) return this.module.modelLand.NewRedisMutex(fmt.Sprintf("%s-%s_lock", this.TableName, oid), 5)
} }
// 获取结束时间
func (this *modelLand) GetEndTime() (newTime int64) {
opentime := this.module.service.GetOpentime().Unix() // 开服时间
subTime := (configure.Now().Unix() - opentime) % int64(this.module.ModuleTools.GetGlobalConf().PlunderPvpSeasontime)
st := 24 - this.module.ModuleTools.GetGlobalConf().PlunderPvpEndtime
newTime = utils.GetZeroTime(configure.Now().Unix()) + subTime*24*3600 - int64(st*3600)
return
}