Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
d3ce4a2073
@ -3,7 +3,9 @@ package pagoda
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/db"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@ -37,18 +39,24 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PagodaGetListReq
|
||||
}
|
||||
} else {
|
||||
season, _ := this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
|
||||
if season == nil { // 创建一条新的数据
|
||||
seasonPagoda := &pb.DBSeasonPagoda{}
|
||||
seasonPagoda.Id = primitive.NewObjectID().Hex()
|
||||
|
||||
seasonPagoda.Uid = session.GetUserId()
|
||||
seasonPagoda.PagodaId = 0 // 初始数据0层
|
||||
seasonPagoda.Type = 201 // TODO 新的塔数据根据配置文件获取
|
||||
this.module.modelSeasonPagoda.addNewSeasonPagoda(session.GetUserId(), seasonPagoda)
|
||||
} else {
|
||||
list.PagodaId = season.PagodaId
|
||||
list.Type = season.Type
|
||||
list.Reward = season.Reward
|
||||
if season.PagodaId == 0 { // 创建一条新的数据
|
||||
season.Id = primitive.NewObjectID().Hex()
|
||||
season.Uid = session.GetUserId()
|
||||
season.PagodaId = 0 // 初始数据0层
|
||||
if conn, err := db.Cross(); err == nil {
|
||||
rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{})
|
||||
server := &pb.DBServerData{}
|
||||
rst.Decode(server)
|
||||
season.Type = server.SeasonType
|
||||
}
|
||||
this.module.modelSeasonPagoda.addNewSeasonPagoda(session.GetUserId(), season)
|
||||
}
|
||||
list = &pb.DBPagoda{
|
||||
Id: season.Id,
|
||||
Uid: season.Uid,
|
||||
PagodaId: season.PagodaId,
|
||||
Reward: season.Reward,
|
||||
Type: season.Type,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
package timer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/sys/db"
|
||||
"time"
|
||||
|
||||
"go_dreamfactory/lego/core"
|
||||
@ -54,6 +54,14 @@ func (this *SeasonPagoda) Start() (err error) {
|
||||
// for i := 0; i < 10000; 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()
|
||||
return
|
||||
}
|
||||
@ -87,44 +95,40 @@ func (this *SeasonPagoda) GetSeasonLoop(id int32) *cfg.GameSeasonLoopData {
|
||||
// // 赛季塔结束
|
||||
func (this *SeasonPagoda) TimerSeasonOver() {
|
||||
this.module.Debugf("TimerSeasonOver:%d", time.Now().Unix())
|
||||
conf := this.GetSeasonLoop(comm.SeasonType) // 获取赛季塔重置配置
|
||||
rest, err := this.DB.Find(comm.TableServerData, bson.M{}) // 查询服务器记录的赛季塔信息
|
||||
if err != nil {
|
||||
serverData := &pb.DBServerData{}
|
||||
for rest.Next(context.TODO()) {
|
||||
rest.Decode(serverData)
|
||||
if serverData.FixedLoop == 0 {
|
||||
if len(conf.DisposableLoop) >= int(serverData.DisposableLoop) && len(conf.FixedLoop) > 0 { // 开始执行循环逻辑
|
||||
serverData.FixedLoop = 1
|
||||
serverData.DisposableLoop = 0
|
||||
|
||||
if db.IsCross() {
|
||||
if conn, err := db.Cross(); err == nil {
|
||||
if rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{}); rst != nil {
|
||||
serverData := &pb.DBServerData{}
|
||||
rst.Decode(serverData)
|
||||
conf := this.GetSeasonLoop(comm.SeasonType) // 获取赛季塔重置配置
|
||||
if serverData.FixedLoop == 0 {
|
||||
if len(conf.DisposableLoop) >= int(serverData.DisposableLoop) && len(conf.FixedLoop) > 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]
|
||||
} 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]
|
||||
this.DB.UpdateOne(comm.TableServerData, bson.M{}, serverData)
|
||||
fmt.Printf("%v", serverData)
|
||||
}
|
||||
|
||||
fmt.Printf("%v", serverData)
|
||||
break
|
||||
}
|
||||
|
||||
this.DB.UpdateOne(comm.TableServerData, bson.M{}, serverData)
|
||||
}
|
||||
|
||||
//star := time.Now()
|
||||
this.DB.DeleteMany(comm.TableSeasonPagoda, bson.M{}, options.Delete())
|
||||
//this.module.Debugf("=====%d,", time.Since(star).Milliseconds())
|
||||
|
||||
//清除redis
|
||||
|
||||
}
|
||||
|
||||
// 赛季塔开始
|
||||
|
Loading…
Reference in New Issue
Block a user