This commit is contained in:
liwei1dao 2023-05-11 17:43:16 +08:00
commit d48c8d4c16
16 changed files with 99 additions and 621 deletions

View File

@ -148,7 +148,7 @@ const (
TableSmithyTrade = "smithytrade"
TableSmithyTask = "smithytask"
/// 赛季塔数据表
TableSeasonPagoda = "seasonpagoda"
//TableSeasonPagoda = "seasonpagoda"
//
TableViking = "viking"
// 维京远征排行榜
@ -171,8 +171,6 @@ const (
TableCrossSession = "crosssession"
TableSeasonData = "seasondata" // 跨服服务器相关数据
///竞技场
TableArena = "arena"
TableArenaRank = "arenarank" //排名

View File

@ -291,7 +291,6 @@ type (
// 修改爬塔
IPagoda interface {
ModifyPagodaFloor(session IUserSession, level int32) (code pb.ErrorCode)
ModifySeasonPagodaFloor(session IUserSession, level int32) (code pb.ErrorCode)
CheckUserBasePagodaInfo(uid string) (data *pb.DBPagodaRecord) // 查询玩家最佳通关记录
// Check Rtype84 Rtype85 Rtype86

View File

@ -174,21 +174,8 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
log.Field{Key: "0", Value: datas[0]},
)
} else if len(datas) == 2 && (datas[0] == "season") { // 赛季塔跳转
module1, err := this.service.GetModule(comm.ModulePagoda)
if err != nil {
return
}
num, err := strconv.Atoi(datas[1])
if err != nil {
code = pb.ErrorCode_ReqParameterError
return
}
code = module1.(comm.IPagoda).ModifySeasonPagodaFloor(session, int32(num))
this.Debug("使用bingo命令:uid = %s ",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "0", Value: datas[0]},
log.Field{Key: "N", Value: int32(num)},
)
code = pb.ErrorCode_ConfigNoFound
return
} else if len(datas) == 1 && (datas[0] == "viking") { // 解锁远征所有难度
module1, err := this.service.GetModule(comm.ModuleViking)
if err != nil {
@ -285,7 +272,7 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "0", Value: datas[1]},
)
} else if len(datas) == 1 && (datas[0] == "allgrowtask") { // 完成所有成长任务
} else if len(datas) == 1 && (datas[0] == "allgrowtask") { // 完成所有成长任务
module, err := this.service.GetModule(comm.ModuleGrowtask)
if err != nil {
return

View File

@ -80,8 +80,8 @@ func TimerStar() {
if !db.IsCross() {
conn, err := db.Cross()
if err == nil {
model := db.NewDBModel(comm.TableSeasonData, 0, conn)
model.DB.DeleteMany(comm.TableSeasonPagoda, bson.M{}, options.Delete())
model := db.NewDBModel(comm.TablePagodaRecord, 0, conn)
//model.DB.DeleteMany(comm.TableSeasonPagoda, bson.M{}, options.Delete())
model.DB.DeleteMany(comm.TablePagodaRecord, bson.M{}, options.Delete())
for pos := 0; pos < comm.MaxRankNum; pos++ {
key1 := fmt.Sprintf("pagodaList%d", pos)

View File

@ -49,7 +49,7 @@ func (this *apiComp) FetterLvUp(session comm.IUserSession, req *pb.LibraryFetter
return
}
if _, ok := fetter.Prize[fetter.Fidlv]; !ok {
if _, ok := fetter.Prize[fetter.Fidlv]; ok {
code = pb.ErrorCode_LibraryReward
return
}

View File

@ -23,11 +23,10 @@ func (this *apiComp) ChallengeOverCheck(session comm.IUserSession, req *pb.Pagod
///挑战主线关卡
func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChallengeOverReq) (code pb.ErrorCode, data *pb.ErrorData) {
var (
mapData map[string]interface{}
pagoda *pb.DBPagoda
costTime int32 // 本次战斗消耗的时间
isWin bool
err error
mapData map[string]interface{}
pagoda *pb.DBPagoda
isWin bool
err error
)
mapData = make(map[string]interface{}, 0)
code = this.ChallengeOverCheck(session, req)
@ -75,7 +74,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal
code = pb.ErrorCode_BattleNoWin
return
}
costTime = req.Report.Costtime
// 加经验
if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 {
for _, v := range req.Report.Info.Redflist[0].Team {
@ -86,16 +84,11 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal
}
pagoda.Data[conf.Tab] += 1
pagoda.PagodaId = conf.Key
mapData["pagodaId"] = pagoda.PagodaId
mapData["type"] = pagoda.Type
mapData["data"] = pagoda.Data
this.module.modulerank.AddPagodaRecord(session.GetUserId(), costTime, pagoda.PagodaId, conf.PagodaType)
if conf.LayerNum > pagoda.PagodaId {
pagoda.PagodaId = conf.LayerNum // 更新层数
}
code = this.module.ModifyPagodaData(session.GetUserId(), mapData)
session.SendMsg(string(this.module.GetType()), PagodaChallengeOverResp, &pb.PagodaChallengeOverResp{Data: pagoda})
if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { // 发系统公告
@ -131,19 +124,18 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal
Leadpos: leadpos,
Line: szLine,
CostTime: req.Report.Costtime,
Tab: conf.Tab,
}
costTime = newData.CostTime
// 数据写到跨服中
conn_, err := db.Cross()
dbModel := db.NewDBModel(comm.TablePagodaRecord, time.Hour, conn_)
dbModel.AddList(uid, newData.Id, newData)
this.module.SetPagodaRankList("pagodaList"+strconv.Itoa(int(newData.PagodaId)), int64(math.MaxInt32-newData.CostTime), newData.Id)
dbModelTable := db.NewDBModel(comm.TableSeasonPagoda, time.Hour, conn_)
if err = dbModelTable.Get(session.GetUserId(), pagoda); err == nil {
dbModelTable.Change(session.GetUserId(), mapData) // 修改跨服数据
score := int64(pagoda.PagodaId)<<31 + int64(math.MaxInt32-costTime)
this.module.SetPagodaRankList("pagodaSeasonRank", score, session.GetUserId())
if conn_, err := db.Cross(); err == nil {
dbModel := db.NewDBModel(comm.TablePagodaRecord, time.Hour, conn_)
dbModel.AddList(uid, newData.Id, newData)
} else {
this.module.Errorf("db crosserr :%v", err)
}
this.module.SetPagodaRankList("pagodaList"+strconv.Itoa(int(newData.PagodaId)), int64(math.MaxInt32-newData.CostTime), newData.Id)
}
// 通关奖励
@ -152,9 +144,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal
return
}
// 任务相关
// this.module.ModuleRtask.SendToRtask(session, comm.Rtype58, 1)
// this.module.ModuleRtask.SendToRtask(session, comm.Rtype59, pagoda.PagodaId)
go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype58, 1), comm.GettaskParam(comm.Rtype59, pagoda.PagodaId))
this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype58, 1), comm.GettaskParam(comm.Rtype59, pagoda.PagodaId))
return
}

View File

@ -13,82 +13,42 @@ func (this *apiComp) GetRewardCheck(session comm.IUserSession, req *pb.PagodaGet
return
}
///获取主线关卡信息
func (this *apiComp) GetReward(session comm.IUserSession, req *pb.PagodaGetRewardReq) (code pb.ErrorCode, data *pb.ErrorData) {
code = this.GetRewardCheck(session, req)
if code != pb.ErrorCode_Success {
return // 参数校验失败直接返回
}
// 获取 奖励信息
list, err := this.module.modelPagoda.getPagodaList(session.GetUserId())
if err != nil || list == nil {
code = pb.ErrorCode_DBError
return
}
season, _ := this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
if season != nil {
if pagoda, err := this.module.modelPagoda.getPagodaList(session.GetUserId()); err != nil {
_cfg := this.module.configure.GetPagodaRewardconfig(req.Id)
if _cfg == nil {
code = pb.ErrorCode_ConfigNoFound
return
}
// 校验是否能领取
if _cfg.LayerNum > season.PagodaId {
if _cfg.LayerNum > pagoda.PagodaId {
code = pb.ErrorCode_PagodaConditionErr
return
}
if _, ok := season.Reward[req.Id]; ok { // 校验是否重复领取
if _, ok := pagoda.Reward[req.Id]; ok { // 校验是否重复领取
code = pb.ErrorCode_PagodaGetRewardErr
return
}
if season.Reward == nil {
season.Reward = make(map[int32]bool, 0)
if pagoda.Reward == nil {
pagoda.Reward = make(map[int32]bool, 0)
}
// 发奖励
if code = this.module.DispenseRes(session, _cfg.Reward, true); code != pb.ErrorCode_Success {
return
}
season.Reward[req.Id] = true
pagoda.Reward[req.Id] = true
mapData := make(map[string]interface{}, 0)
mapData["reward"] = season.Reward
code = this.module.ModifySeasonPagodaData(session.GetUserId(), mapData)
session.SendMsg(string(this.module.GetType()), PagodaGetRewardResp, &pb.PagodaGetRewardResp{Data: &pb.DBPagoda{
PagodaId: season.PagodaId,
Reward: season.Reward,
Type: season.Type,
}})
} else {
_cfg := this.module.configure.GetPagodaRewardconfig(req.Id)
if _cfg == nil {
code = pb.ErrorCode_ConfigNoFound
return
}
// 校验是否能领取
if _cfg.LayerNum > list.PagodaId {
code = pb.ErrorCode_PagodaConditionErr
return
}
if _, ok := list.Reward[req.Id]; ok { // 校验是否重复领取
code = pb.ErrorCode_PagodaGetRewardErr
return
}
if list.Reward == nil {
list.Reward = make(map[int32]bool, 0)
}
// 发奖励
if code = this.module.DispenseRes(session, _cfg.Reward, true); code != pb.ErrorCode_Success {
return
}
list.Reward[req.Id] = true
mapData := make(map[string]interface{}, 0)
mapData["reward"] = list.Reward
mapData["reward"] = pagoda.Reward
code = this.module.ModifyPagodaData(session.GetUserId(), mapData)
session.SendMsg(string(this.module.GetType()), PagodaGetRewardResp, &pb.PagodaGetRewardResp{Data: list})
}
session.SendMsg(string(this.module.GetType()), PagodaGetRewardResp, &pb.PagodaGetRewardResp{Data: pagoda})
}
return
}

View File

@ -3,8 +3,6 @@ package pagoda
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go.mongodb.org/mongo-driver/bson/primitive"
)
//参数校验
@ -12,23 +10,12 @@ func (this *apiComp) QueryRecordCheck(session comm.IUserSession, req *pb.PagodaQ
return
}
///获取主线关卡信息
func (this *apiComp) QueryRecord(session comm.IUserSession, req *pb.PagodaQueryRecordReq) (code pb.ErrorCode, data *pb.ErrorData) {
var (
record *pb.DBPagodaRecord
)
list, _ := this.module.modelPagoda.getPagodaList(session.GetUserId())
if list == nil { // redis没有数据
list = &pb.DBPagoda{}
list.Id = primitive.NewObjectID().Hex()
list.Uid = session.GetUserId()
list.PagodaId = 0 // 初始数据0层
list.Type = comm.PagodaType
this.module.modelPagoda.addNewPagoda(session.GetUserId(), list)
} else {
if list, err := this.module.modelPagoda.getPagodaList(session.GetUserId()); err == nil {
record = this.module.modulerank.getPagodaRankListByFloorid(session.GetUserId(), list.PagodaId)
}
session.SendMsg(string(this.module.GetType()), PagodaQueryRecordResp, &pb.PagodaQueryRecordResp{Data: record})

View File

@ -5,7 +5,6 @@ import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/redis/pipe"
"go_dreamfactory/pb"
"go_dreamfactory/sys/db"
"strconv"
"github.com/go-redis/redis/v8"
@ -27,31 +26,29 @@ func (this *apiComp) RankList(session comm.IUserSession, req *pb.PagodaRankListR
return
}
if !req.Friend {
if !this.module.IsCross() {
if conn, err := db.Cross(); err == nil {
var (
pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
)
if req.Cid == 0 {
rd = pipe.ZRevRange("pagodaSeasonRank", 0, comm.MaxRankList)
} else {
rd = pipe.ZRange("pagodaList"+strconv.Itoa(int(req.Cid)), 0, comm.MaxRankList)
}
if this.module.IsCross() {
//if conn, err := db.Cross(); err == nil {
var (
pipe *pipe.RedisPipe = this.module.modelPagoda.Redis.RedisPipe(context.TODO())
)
if req.Cid != 0 {
rd = pipe.ZRange("pagodaList"+strconv.Itoa(int(req.Cid)), 0, comm.MaxRankList)
}
if _, err = pipe.Exec(); err != nil {
this.module.Errorln(err)
return
}
_dataList := rd.Val()
for _, v := range _dataList {
//conn_, err := db.Cross()
dbModel := db.NewDBModel(comm.TablePagodaRecord, 0, conn)
result := &pb.DBPagodaRecord{}
if err = dbModel.GetListObj(session.GetUserId(), v, result); err == nil {
szRank = append(szRank, result)
}
if _, err := pipe.Exec(); err != nil {
this.module.Errorln(err)
return
}
_dataList := rd.Val()
for _, v := range _dataList {
//conn_, err := db.Cross()
//dbModel := db.NewDBModel(comm.TablePagodaRecord, 0, conn)
result := &pb.DBPagodaRecord{}
if err := this.module.modulerank.GetListObj(session.GetUserId(), v, result); err == nil {
szRank = append(szRank, result)
}
}
//}
}
} else {
uids := this.module.friend.GetFriendList(session.GetUserId())

View File

@ -27,7 +27,7 @@ func (this *apiComp) WarOrder(session comm.IUserSession, req *pb.PagodaWarOrderR
mapData = make(map[string]interface{}, 0)
//this.WarOrderCheck(session, req)
list, _ = this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
list, _ = this.module.modelPagoda.getPagodaList(session.GetUserId())
if list.Id == "" {
code = pb.ErrorCode_PagodaConditionErr // 领取条件没达到
return
@ -115,7 +115,7 @@ func (this *apiComp) WarOrder(session comm.IUserSession, req *pb.PagodaWarOrderR
})
}
code = this.module.ModifySeasonPagodaData(session.GetUserId(), mapData)
code = this.module.ModifyPagodaData(session.GetUserId(), mapData)
session.SendMsg(string(this.module.GetType()), PagodaWarOrderResp, &pb.PagodaWarOrderResp{
Data: list,
Itmes: res,

View File

@ -4,6 +4,7 @@ import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/sys/db"
//"go_dreamfactory/lego/sys/redis"
"go_dreamfactory/lego/sys/redis/pipe"
@ -11,7 +12,6 @@ import (
"go_dreamfactory/pb"
"github.com/go-redis/redis/v8"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/bsonx"
)
@ -35,53 +35,28 @@ func (this *ModelRank) Init(service core.IService, module core.IModule, comp cor
return
}
// func (this *ModelRank) GetRankData() (data []*pb.DBPagodaRecord, err error) {
// data = make([]*pb.DBPagodaRecord, 0)
// if conn, err := db.Cross(); err == nil {
// err = conn.Redis.LRange(comm.TableSeasonRankList, 0, -1, &data)
// }
// //err = this.Redis.LRange(comm.TablePagodaRankList, 0, -1, &data)
// return
// }
// 写记录
func (this *ModelRank) AddPagodaRecord(uid string, costTime, pagodaId, pagodaType int32) (err error) {
userinfo := this.modulePagoda.ModuleUser.GetUser(uid)
newData := &pb.DBPagodaRecord{
Id: primitive.NewObjectID().Hex(),
Uid: uid,
PagodaId: pagodaId,
Type: pagodaType,
Nickname: userinfo.Name,
Icon: "", // icon 暂无
Lv: userinfo.Lv,
CostTime: costTime,
}
err = this.AddList(uid, newData.Id, newData)
return
}
func (this *ModelRank) getPagodaRankList(uid string) []*pb.DBPagodaRecord {
func (this *ModelRank) getPagodaRankListByFloorid(uid string, cid int32) *pb.DBPagodaRecord {
pagodaRank := make([]*pb.DBPagodaRecord, 0)
err := this.GetList(uid, &pagodaRank)
if err != nil {
return nil
}
return pagodaRank
}
func (this *ModelRank) getPagodaRankListByFloorid(uid string, floorid int32) *pb.DBPagodaRecord {
pagodaRank := make([]*pb.DBPagodaRecord, 0)
err := this.GetList(uid, &pagodaRank)
if err != nil {
return nil
}
for _, v := range pagodaRank {
if v.PagodaId == floorid {
return v
if db.IsCross() {
if err := this.GetList(uid, &pagodaRank); err != nil {
return nil
}
} else {
if conn, err := db.Cross(); err == nil {
dbModel := db.NewDBModel(comm.TablePagodaRecord, 0, conn)
if err = dbModel.GetList(uid, &pagodaRank); err == nil {
return nil
}
}
}
for _, v := range pagodaRank {
if conf := this.modulePagoda.configure.GetPagodaConfigData(cid); conf == nil {
if v.PagodaId == conf.LayerNum && v.Tab == conf.Tab {
return v
}
}
}
return nil
}

View File

@ -1,87 +0,0 @@
package pagoda
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"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/mongo"
"go.mongodb.org/mongo-driver/x/bsonx"
)
/// 赛季塔
type ModelSeasonPagoda struct {
modules.MCompModel
module *Pagoda
}
func (this *ModelSeasonPagoda) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.TableName = string(comm.TableSeasonPagoda)
err = this.MCompModel.Init(service, module, comp, options)
this.module = module.(*Pagoda)
//创建uid索引
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
})
return
}
// 获取爬塔信息
func (this *ModelSeasonPagoda) getSeasonPagodaList(uid string) (result *pb.DBPagoda, err error) {
result = &pb.DBPagoda{}
if err = this.Get(uid, result); err != nil {
return
}
err = nil
return result, err
}
// 修改爬塔数据信息
func (this *ModelSeasonPagoda) modifySeasonPagodaDataByObjId(uid string, data map[string]interface{}) error {
return this.Change(uid, data)
}
// 创建一个新的赛季塔数据
func (this *ModelSeasonPagoda) addNewSeasonPagoda(uId string, data *pb.DBPagoda) (err error) {
//err = this.InsertModelLogs(this.TableName, uId, []interface{}{data}) // 不需要经过redis
if err = this.Add(uId, data); err != nil {
this.module.Errorf("err:%v", err)
return
}
if !this.module.IsCross() {
if conn, err := db.Cross(); err == nil {
data1 := &comm.Autogenerated{
ID: primitive.NewObjectID().Hex(),
UID: uId,
Act: string(comm.LogHandleType_Update),
}
table := comm.TablePagodaRecord //, uid, , data)
data1.D = append(data1.D, table) // D[0]
data1.D = append(data1.D, bson.M{"uid": uId}) // D[1]
data1.D = append(data1.D, data) // D[2]
_, err = conn.Mgo.InsertOne("model_log", data1)
if err != nil {
log.Errorf("insert model db err %v", err)
}
}
}
return nil
}
// 赛季结束 清理所有塔数据
func (this *ModelSeasonPagoda) DleAllSeasonData() {
this.DB.DeleteMany(core.SqlTable(this.TableName), bson.M{})
err := this.Redis.Ltrim(comm.TablePagodaRecord, 0, -1)
if err != nil {
log.Errorf("delete failed")
}
return
}

View File

@ -2,7 +2,6 @@ package pagoda
import (
"context"
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
@ -13,21 +12,19 @@ import (
"go_dreamfactory/sys/db"
"github.com/go-redis/redis/v8"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type Pagoda struct {
modules.ModuleBase
modelPagoda *ModelPagoda
modelSeasonPagoda *ModelSeasonPagoda
api *apiComp
modulerank *ModelRank
configure *configureComp
battle comm.IBattle
service base.IRPCXService
mail comm.Imail
friend comm.IFriend
modelPagoda *ModelPagoda
//modelSeasonPagoda *ModelSeasonPagoda
api *apiComp
modulerank *ModelRank
configure *configureComp
battle comm.IBattle
service base.IRPCXService
mail comm.Imail
friend comm.IFriend
}
func NewModule() core.IModule {
@ -48,7 +45,7 @@ func (this *Pagoda) OnInstallComp() {
this.ModuleBase.OnInstallComp()
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelPagoda = this.RegisterComp(new(ModelPagoda)).(*ModelPagoda)
this.modelSeasonPagoda = this.RegisterComp(new(ModelSeasonPagoda)).(*ModelSeasonPagoda)
//this.modelSeasonPagoda = this.RegisterComp(new(ModelSeasonPagoda)).(*ModelSeasonPagoda)
this.modulerank = this.RegisterComp(new(ModelRank)).(*ModelRank)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
}
@ -62,14 +59,6 @@ func (this *Pagoda) ModifyPagodaData(uid string, data map[string]interface{}) (c
return
}
// 修改赛季塔信息
func (this *Pagoda) ModifySeasonPagodaData(uid string, data map[string]interface{}) (code pb.ErrorCode) {
err := this.modelSeasonPagoda.modifySeasonPagodaDataByObjId(uid, data)
if err != nil {
code = pb.ErrorCode_DBError
}
return
}
func (this *Pagoda) Start() (err error) {
err = this.ModuleBase.Start()
var module core.IModule
@ -122,19 +111,6 @@ func (this *Pagoda) CheckUserBasePagodaInfo(uid string) (data *pb.DBPagodaRecord
return
}
// 清除赛季塔信息
func (this *Pagoda) CleanSeasonPagodaData() (code pb.ErrorCode) {
seasonMaxCount := this.modelPagoda.module.configure.GetPagodaFloor(201)
for iPos := 0; iPos < int(seasonMaxCount); iPos++ {
key := fmt.Sprintf("%s-%d-rank", floorRankKey, iPos+1)
if err := this.modelSeasonPagoda.Redis.Ltrim(key, 0, -1); err != nil {
log.Errorf("delete failed")
}
}
return
}
// redis 排序 tableName:"pagodaList"
func (this *Pagoda) SetPagodaRankList(tableName string, score int64, uid string) {
if !this.IsCross() {
@ -169,9 +145,7 @@ func (this *Pagoda) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (r
case comm.Reddot6:
reddot[comm.Reddot6] = this.CheckPoint6(session.GetUserId())
break
case comm.Reddot7:
reddot[comm.Reddot7] = this.CheckPoint7(session.GetUserId())
break
}
}
@ -189,15 +163,6 @@ func (this *Pagoda) CheckPoint6(uid string) bool {
return true
}
// 检测赛季塔
season, err := this.modelSeasonPagoda.getSeasonPagodaList(uid)
if err != nil {
return false
}
maxFloor = this.configure.GetPagodaFloor(list.Type)
if season.PagodaId < maxFloor { // 层数不够 显示红点
return true
}
return true
}
@ -206,24 +171,6 @@ func (this *Pagoda) Rpc_ModuleSeasonPagodaReward(ctx context.Context, args *pb.E
// this.modulerank.seasonSettlement()
}
func (this *Pagoda) CheckPoint7(uid string) bool {
list, _ := this.modelPagoda.getPagodaList(uid)
if list.Id == "" { // 普通塔
return false
}
if len(list.Reward) > 0 {
return true
}
season, _ := this.modelSeasonPagoda.getSeasonPagodaList(uid)
if season.Id == "" { // 普通塔
return false
}
if len(season.Reward) > 0 {
return true
}
return true
}
// 给随机任务提供的接口查询当前塔的通关层数
func (this *Pagoda) CheckPagodaMaxFloor(uid string, pagodaType int32) int32 {
if pagodaType == 1 {
@ -237,31 +184,3 @@ func (this *Pagoda) CheckPagodaMaxFloor(uid string, pagodaType int32) int32 {
}
return 0
}
// 赛季塔跳转
func (this *Pagoda) ModifySeasonPagodaFloor(session comm.IUserSession, level int32) (code pb.ErrorCode) {
list, _ := this.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
if list.Id == "" {
list.Id = primitive.NewObjectID().Hex()
list.Uid = session.GetUserId()
list.PagodaId = level
if conn, err := db.Cross(); err == nil {
rst := conn.Mgo.FindOne(comm.TableSeasonData, bson.M{})
server := &pb.DBServerData{}
rst.Decode(server)
list.Type = server.SeasonType
}
this.modelSeasonPagoda.addNewSeasonPagoda(session.GetUserId(), list)
session.SendMsg(string(this.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list})
} else {
list.PagodaId = level
mapData := make(map[string]interface{}, 0)
mapData["pagodaId"] = level
code = this.ModifySeasonPagodaData(session.GetUserId(), mapData)
session.SendMsg(string(this.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list})
}
return
}

View File

@ -1,255 +0,0 @@
package timer
import (
"context"
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/sys/db"
"math"
"strconv"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/sys/redis/pipe"
"github.com/go-redis/redis/v8"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo/options"
)
var (
game_seasonloop = "game_seasonloop.json"
game_seasonreward = "game_pagodaseasonreward.json"
)
type SeasonPagoda struct {
cbase.ModuleCompBase
modules.MCompConfigure
modules.MCompModel
service base.IRPCXService
module *Timer
mail comm.Imail
}
//组件初始化接口
func (this *SeasonPagoda) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.MCompConfigure.Init(service, module, comp, options)
this.TableName = comm.TableSeasonPagoda
this.MCompModel.Init(service, module, comp, options)
this.service = service.(base.IRPCXService)
this.module = module.(*Timer)
if module1, err := this.service.GetModule(comm.ModuleMail); err == nil {
this.mail = module1.(comm.Imail)
}
return
}
func (this *SeasonPagoda) Start() (err error) {
err = this.MCompModel.Start()
err = this.MCompConfigure.Start()
// configure.RegisterConfigure(game_seasonloop, cfg.NewGameSeasonLoop, nil)
// configure.RegisterConfigure(game_seasonreward, cfg.NewGamePagodaSeasonReward, nil)
// cron.AddFunc("0 0 23 L * ?", this.TimerSeasonOver) //每月最后一天23点执行一次
// cron.AddFunc("0 0 5 /* * ?", this.TimerSeasonStar) //每月第一天5点执行一次
// if db.IsCross() {
// return
// }
// //time.Sleep(time.Second * 1)
// //this.DbTest()
// conn, err := db.Cross()
// if err == nil {
// //this.DbTest()
// model := db.NewDBModel(comm.TableSeasonData, 0, conn)
// _len, err1 := model.DB.CountDocuments(comm.TableSeasonData, bson.M{})
// if err1 == nil && _len == 0 {
// fmt.Printf("%v,%v", _len, err1)
// server := &pb.DBServerData{
// Id: primitive.NewObjectID().Hex(),
// ServerState: 1,
// DisposableLoop: 1,
// FixedLoop: 0,
// SeasonType: 201,
// OpenTime: time.Now().Unix(),
// }
// conf := this.GetSeasonLoop(comm.SeasonType)
// if len(conf.DisposableLoop) > 0 {
// server.SeasonType = conf.DisposableLoop[0]
// }
// model.DB.InsertOne(comm.TableSeasonData, server)
// }
// }
return
}
// func (this *SeasonPagoda) GetSeasonReward() []int32 {
// sz := make([]int32, 0)
// if v, err := this.GetConfigure(game_seasonreward); err != nil {
// log.Errorf("get global conf err:%v", err)
// return sz
// } else {
// if configure, ok := v.(*cfg.GamePagodaSeasonReward); ok {
// for _, v := range configure.GetDataList() {
// sz = append(sz, v.Ranking[0])
// }
// }
// log.Errorf("%T no is *cfg.Game_global", v)
// return sz
// }
// }
// // 赛季塔结束
// func (this *SeasonPagoda) TimerSeasonOver() {
// this.module.Debugf("TimerSeasonOver:%d", configure.Now().Unix())
// if db.IsCross() {
// if conn, err := db.Cross(); err == nil {
// if rst := conn.Mgo.FindOne(comm.TableSeasonData, 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]
// }
// this.DB.UpdateOne(comm.TableSeasonData, bson.M{}, serverData)
// fmt.Printf("%v", serverData)
// }
// }
// }
// if _, err := this.service.RpcGo(context.Background(),
// comm.Service_Worker,
// string(comm.Rpc_ModuleSeasonPagodaReward),
// pb.EmptyReq{},
// nil,
// ); err != nil {
// this.module.Errorln(err)
// }
//}
// 赛季塔开始
func (this *SeasonPagoda) TimerSeasonStar() {
this.module.Debugf("TimerSeasonStar:%d", configure.Now().Unix())
//star := configure.Now()
if !db.IsCross() { // 删除本服的赛季塔数据
conn, err := db.Cross() // 获取跨服的链接对象
if err == nil {
model := db.NewDBModel(comm.TableSeasonData, 0, conn)
model.DB.DeleteMany(comm.TableSeasonPagoda, bson.M{}, options.Delete())
model.DB.DeleteMany(comm.TablePagodaRecord, bson.M{}, options.Delete())
for pos := 0; pos < comm.MaxRankNum; pos++ {
key1 := fmt.Sprintf("pagodaList%d", pos)
if err := model.Redis.Delete(key1); err != nil {
log.Errorf("delete failed")
}
}
if err := model.Redis.Delete("pagodaSeasonRank"); err != nil {
log.Errorf("delete failed")
}
}
this.DB.DeleteMany(comm.TablePagodaRecord, bson.M{}, options.Delete())
}
//this.module.Debugf("=====%d,", time.Since(star).Milliseconds())
}
func (this *SeasonPagoda) DbTest() {
conn, _ := db.Cross()
model1 := db.NewDBModel(comm.TableVikingRank, 0, conn)
model1.Redis.Delete("vikingRank2")
_d, err := model1.Redis.Keys("vikingrank:*")
if err == nil {
for _, v := range _d {
model1.Redis.Delete(v)
}
fmt.Printf("%v", _d)
}
//star := configure.Now()
for i := 1; i < 10; i++ {
new := &pb.DBVikingRank{
Id: primitive.NewObjectID().Hex(),
Uid: "mmmxxx" + strconv.Itoa(i),
Difficulty: int32(i) % 10,
Bosstype: 2,
Nickname: "helo",
Icon: "",
Lv: 120,
Leadpos: 1,
Line: make([]*pb.LineUp, 5),
CostTime: 12000 + int32(i),
}
model1.AddList(new.Uid, new.Id, new)
//model1.Add(new.Uid, new)
var (
pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
menbers *redis.Z
tableName string
score int64
)
score = int64(i)<<31 + int64(math.MaxInt32-new.CostTime)
tableName = "vikingRank" + strconv.Itoa(int(new.Bosstype))
strKey := "vikingrank:" + new.Uid + "-" + new.Id // 自定义key new.Uid //
menbers = &redis.Z{Score: float64(score), Member: strKey}
if cmd := pipe.ZAdd(tableName, menbers); cmd != nil {
dock, err1 := cmd.Result()
if err1 != nil {
this.module.Errorln(dock, err1)
}
}
if _, err := pipe.Exec(); err != nil {
this.module.Errorln(err)
}
}
//this.module.Debugf("=====%d,", time.Since(star).Milliseconds())
if true {
var (
pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
szRank []*pb.DBVikingRank
)
// 降序
rd := pipe.ZRevRange("vikingRank"+strconv.Itoa(2), 0, -1)
if _, err := pipe.Exec(); err != nil {
this.module.Errorln(err)
return
}
_dataList := rd.Val()
for _, v := range _dataList {
result := &pb.DBVikingRank{}
if err := model1.Redis.HGetAll(v, result); err == nil {
szRank = append(szRank, result)
}
}
this.module.Debugf("%v", szRank)
}
}

View File

@ -147,6 +147,7 @@ type DBPagodaRecord struct {
Leadpos int32 `protobuf:"varint,8,opt,name=leadpos,proto3" json:"leadpos"` //队长位置
Line []*LineUp `protobuf:"bytes,9,rep,name=line,proto3" json:"line"` // 阵容数据
CostTime int32 `protobuf:"varint,10,opt,name=costTime,proto3" json:"costTime" bson:"costTime"` //闯关耗时 单位s
Tab int32 `protobuf:"varint,11,opt,name=tab,proto3" json:"tab"` // 页签
}
func (x *DBPagodaRecord) Reset() {
@ -251,6 +252,13 @@ func (x *DBPagodaRecord) GetCostTime() int32 {
return 0
}
func (x *DBPagodaRecord) GetTab() int32 {
if x != nil {
return x.Tab
}
return 0
}
var File_pagoda_pagoda_db_proto protoreflect.FileDescriptor
var file_pagoda_pagoda_db_proto_rawDesc = []byte{
@ -282,7 +290,7 @@ var file_pagoda_pagoda_db_proto_rawDesc = []byte{
0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20,
0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02,
0x38, 0x01, 0x22, 0xf5, 0x01, 0x0a, 0x0e, 0x44, 0x42, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52,
0x38, 0x01, 0x22, 0x87, 0x02, 0x0a, 0x0e, 0x44, 0x42, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52,
0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x6f, 0x64,
@ -297,8 +305,9 @@ var file_pagoda_pagoda_db_proto_rawDesc = []byte{
0x73, 0x12, 0x1b, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x07, 0x2e, 0x4c, 0x69, 0x6e, 0x65, 0x55, 0x70, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x1a,
0x0a, 0x08, 0x63, 0x6f, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05,
0x52, 0x08, 0x63, 0x6f, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b,
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x52, 0x08, 0x63, 0x6f, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61,
0x62, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x61, 0x62, 0x42, 0x06, 0x5a, 0x04,
0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -2731,7 +2731,7 @@ func (x *UserSellResReq) GetAtno() []*UserAtno {
return nil
}
//出售道具请求 回应
//出售资源 回应
type UserSellResResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache