This commit is contained in:
liwei1dao 2022-10-21 15:00:16 +08:00
commit 04b0c315ab
3 changed files with 56 additions and 46 deletions

View File

@ -88,8 +88,7 @@ func (this *Battle) CreatePveBattle(session comm.IUserSession, req *pb.BattlePVE
this.Errorf("session:%v err:", session, err) this.Errorf("session:%v err:", session, err)
return return
} }
if req.Ptype < 0 || req.Ptype > 4 || if req.Format == nil || req.Format.Format == nil || len(req.Format.Format) != 5 {
req.Format == nil || req.Format.Format == nil || len(req.Format.Format) != 5 {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
return return
} }
@ -119,8 +118,7 @@ func (this *Battle) CreatePvbBattle(session comm.IUserSession, req *pb.BattlePVE
this.Errorf("session:%v err:", session, err) this.Errorf("session:%v err:", session, err)
return return
} }
if req.Ptype < 0 || req.Ptype > 4 || if req.Format == nil || req.Format.Format == nil || len(req.Format.Format) != 5 {
req.Format == nil || req.Format.Format == nil || len(req.Format.Format) != 5 {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
return return
} }

View File

@ -3,7 +3,9 @@ package pagoda
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/db"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@ -37,18 +39,24 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PagodaGetListReq
} }
} else { } else {
season, _ := this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId()) season, _ := this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
if season == nil { // 创建一条新的数据 if season.PagodaId == 0 { // 创建一条新的数据
seasonPagoda := &pb.DBSeasonPagoda{} season.Id = primitive.NewObjectID().Hex()
seasonPagoda.Id = primitive.NewObjectID().Hex() season.Uid = session.GetUserId()
season.PagodaId = 0 // 初始数据0层
seasonPagoda.Uid = session.GetUserId() if conn, err := db.Cross(); err == nil {
seasonPagoda.PagodaId = 0 // 初始数据0层 rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{})
seasonPagoda.Type = 201 // TODO 新的塔数据根据配置文件获取 server := &pb.DBServerData{}
this.module.modelSeasonPagoda.addNewSeasonPagoda(session.GetUserId(), seasonPagoda) rst.Decode(server)
} else { season.Type = server.SeasonType
list.PagodaId = season.PagodaId }
list.Type = season.Type this.module.modelSeasonPagoda.addNewSeasonPagoda(session.GetUserId(), season)
list.Reward = season.Reward }
list = &pb.DBPagoda{
Id: season.Id,
Uid: season.Uid,
PagodaId: season.PagodaId,
Reward: season.Reward,
Type: season.Type,
} }
} }

View File

@ -1,13 +1,13 @@
package timer package timer
import ( import (
"context"
"fmt" "fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure" "go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/sys/db"
"time" "time"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
@ -54,6 +54,14 @@ func (this *SeasonPagoda) Start() (err error) {
// for i := 0; i < 10000; i++ { // for i := 0; i < 10000; i++ {
// this.CreatTestData(i) // this.CreatTestData(i)
// } // }
// if conn, err := db.Cross(); err == nil {
// rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{})
// server := &pb.DBServerData{}
// rst.Decode(server)
// fmt.Printf("%v", server)
// }
this.TimerSeasonOver() this.TimerSeasonOver()
return return
} }
@ -87,44 +95,40 @@ func (this *SeasonPagoda) GetSeasonLoop(id int32) *cfg.GameSeasonLoopData {
// // 赛季塔结束 // // 赛季塔结束
func (this *SeasonPagoda) TimerSeasonOver() { func (this *SeasonPagoda) TimerSeasonOver() {
this.module.Debugf("TimerSeasonOver:%d", time.Now().Unix()) this.module.Debugf("TimerSeasonOver:%d", time.Now().Unix())
conf := this.GetSeasonLoop(comm.SeasonType) // 获取赛季塔重置配置
rest, err := this.DB.Find(comm.TableServerData, bson.M{}) // 查询服务器记录的赛季塔信息 if db.IsCross() {
if err != nil { if conn, err := db.Cross(); err == nil {
serverData := &pb.DBServerData{} if rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{}); rst != nil {
for rest.Next(context.TODO()) { serverData := &pb.DBServerData{}
rest.Decode(serverData) rst.Decode(serverData)
if serverData.FixedLoop == 0 { conf := this.GetSeasonLoop(comm.SeasonType) // 获取赛季塔重置配置
if len(conf.DisposableLoop) >= int(serverData.DisposableLoop) && len(conf.FixedLoop) > 0 { // 开始执行循环逻辑 if serverData.FixedLoop == 0 {
serverData.FixedLoop = 1 if len(conf.DisposableLoop) >= int(serverData.DisposableLoop) && len(conf.FixedLoop) > 0 { // 开始执行循环逻辑
serverData.DisposableLoop = 0 serverData.FixedLoop = 1
serverData.DisposableLoop = 0
serverData.SeasonType = conf.FixedLoop[int(serverData.FixedLoop)-1]
} else {
serverData.DisposableLoop++
serverData.SeasonType = conf.DisposableLoop[int(serverData.DisposableLoop)-1]
}
} else { // 循环
if len(conf.FixedLoop) >= int(serverData.FixedLoop) {
serverData.FixedLoop = 1
} else {
serverData.FixedLoop++
}
serverData.SeasonType = conf.FixedLoop[int(serverData.FixedLoop)-1] serverData.SeasonType = conf.FixedLoop[int(serverData.FixedLoop)-1]
} else {
serverData.DisposableLoop++
serverData.SeasonType = conf.DisposableLoop[int(serverData.DisposableLoop)-1]
} }
this.DB.UpdateOne(comm.TableServerData, bson.M{}, serverData)
} else { // 循环 fmt.Printf("%v", serverData)
if len(conf.FixedLoop) >= int(serverData.FixedLoop) {
serverData.FixedLoop = 1
} else {
serverData.FixedLoop++
}
serverData.SeasonType = conf.FixedLoop[int(serverData.FixedLoop)-1]
} }
fmt.Printf("%v", serverData)
break
} }
this.DB.UpdateOne(comm.TableServerData, bson.M{}, serverData)
} }
//star := time.Now() //star := time.Now()
this.DB.DeleteMany(comm.TableSeasonPagoda, bson.M{}, options.Delete()) this.DB.DeleteMany(comm.TableSeasonPagoda, bson.M{}, options.Delete())
//this.module.Debugf("=====%d,", time.Since(star).Milliseconds()) //this.module.Debugf("=====%d,", time.Since(star).Milliseconds())
//清除redis
} }
// 赛季塔开始 // 赛季塔开始