重置返还已学习的天赋点数

This commit is contained in:
meixiongfeng 2022-11-11 15:49:07 +08:00
parent 88d9094e1f
commit 9eeab31149
7 changed files with 113 additions and 36 deletions

View File

@ -228,10 +228,13 @@ const ( //Rpc
Rpc_ModuleArenaRaceSettlement core.Rpc_Key = "Rpc_ModuleArenaRaceSettlement" //竞技场比赛结算信息 Rpc_ModuleArenaRaceSettlement core.Rpc_Key = "Rpc_ModuleArenaRaceSettlement" //竞技场比赛结算信息
// 充值发货 // 充值发货
Rpc_ModulePayDelivery core.Rpc_Key = "Rpc_ModuleArenaRaceSettlement" //充值发货 Rpc_ModulePayDelivery core.Rpc_Key = "Rpc_ModulePayDelivery" //充值发货
// 羁绊信息 // 羁绊信息
Rpc_ModuleFetter core.Rpc_Key = "Rpc_ModuleFetter" Rpc_ModuleFetter core.Rpc_Key = "Rpc_ModuleFetter"
// 赛季塔计算邮件奖励
Rpc_ModuleSeasonPagodaReward core.Rpc_Key = "Rpc_ModuleSeasonPagodaReward"
) )
//事件类型定义处 //事件类型定义处

View File

@ -3,6 +3,7 @@ package hero
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@ -19,6 +20,7 @@ func (this *apiComp) TalentReset(session comm.IUserSession, req *pb.HeroTalentRe
var ( var (
heroList []*pb.DBHero heroList []*pb.DBHero
chanegCard []*pb.DBHero // 推送属性变化 chanegCard []*pb.DBHero // 推送属性变化
talentPoint int32 // 已经消耗的天赋点数
) )
if code = this.TalentResetCheck(session, req); code != pb.ErrorCode_Success { if code = this.TalentResetCheck(session, req); code != pb.ErrorCode_Success {
return return
@ -41,6 +43,19 @@ func (this *apiComp) TalentReset(session comm.IUserSession, req *pb.HeroTalentRe
return return
} }
for k := range _talent.Talent {
if conf := this.module.configure.GetHeroTalent(k); conf != nil {
talentPoint += conf.Point // 获取当前英雄的天赋点数
}
res := &cfg.Gameatn{
A: "item",
T: _talent.HeroId,
N: talentPoint,
}
if code = this.module.DispenseRes(session, []*cfg.Gameatn{res}, true); code != pb.ErrorCode_Success {
this.module.Errorf("DispenseRes err,uid:%s,item:%v", session.GetUserId(), res)
} // 返还升级的天赋点数
}
if len(_talent.Talent) > 0 { if len(_talent.Talent) > 0 {
update := make(map[string]interface{}, 0) update := make(map[string]interface{}, 0)
szTalent := map[int32]int32{} szTalent := map[int32]int32{}

View File

@ -45,8 +45,6 @@ func (this *apiComp) RankList(session comm.IUserSession, req *pb.PagodaRankListR
return return
} }
_data3 := rd.Val() _data3 := rd.Val()
_data, err2 := rd.Result()
this.module.Errorln(_data, err2, _data3)
for _, v := range _data3 { for _, v := range _data3 {
conn_, err := db.Cross() conn_, err := db.Cross()
dbModel := db.NewDBModel(comm.TableSeasonRecord, time.Hour, conn_) dbModel := db.NewDBModel(comm.TableSeasonRecord, time.Hour, conn_)

View File

@ -1,6 +1,7 @@
package pagoda package pagoda
import ( import (
"fmt"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
@ -63,6 +64,9 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
log.Errorf("get game_pagoda conf err:%v", err) log.Errorf("get game_pagoda conf err:%v", err)
return return
}) })
_data := this.GetPagodaSeasonReward()
fmt.Printf("%v", _data)
return return
} }
@ -163,3 +167,21 @@ func (this *configureComp) GetPassCheckByID(id int32) *cfg.GamePassCheckData {
} }
return nil return nil
} }
// 获取
func (this *configureComp) GetPagodaSeasonReward() [][]int32 {
rank := make([][]int32, 0)
if v, err := this.GetConfigure(game_pagodaseasonreward); err == nil {
var (
configure *cfg.GamePagodaSeasonReward
ok bool
)
if configure, ok = v.(*cfg.GamePagodaSeasonReward); ok {
for _, v := range configure.GetDataList() {
rank = append(rank, v.Ranking)
}
return rank
}
}
return nil
}

View File

@ -241,3 +241,44 @@ func (this *ModelRank) SetNormalPagodaRankList(tableName string, score int32, ui
} }
} }
func (this *ModelRank) seasonSettlement() {
list := this.modulePagoda.configure.GetPagodaSeasonReward()
if list == nil {
return
}
if !db.IsCross() {
if conn, err := db.Cross(); err == nil {
var (
pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
Items []*pb.UserAssets
)
rd := pipe.ZRange("pagodaSeasonRank0", 0, 50)
if _, err = pipe.Exec(); err != nil {
this.modulePagoda.Errorln(err)
return
}
uids := rd.Val()
if len(uids) > 0 {
Items = make([]*pb.UserAssets, 0) //TO 排名配置
// for i, v := range v.RankReward {
// Items[i] = &pb.UserAssets{
// A: v.A,
// T: v.T,
// N: v.N,
// }
// }
//发邮件
this.modulePagoda.mail.SendNewMail(&pb.DBMailData{
CreateTime: uint64(configure.Now().Unix()),
Items: Items,
}, uids...)
}
}
}
}

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/sys/redis/pipe" "go_dreamfactory/lego/sys/redis/pipe"
@ -22,7 +23,8 @@ type Pagoda struct {
modulerank *ModelRank modulerank *ModelRank
configure *configureComp configure *configureComp
battle comm.IBattle battle comm.IBattle
service core.IService service base.IRPCXService
mail comm.Imail
} }
func NewModule() core.IModule { func NewModule() core.IModule {
@ -35,7 +37,7 @@ func (this *Pagoda) GetType() core.M_Modules {
func (this *Pagoda) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { func (this *Pagoda) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options) err = this.ModuleBase.Init(service, module, options)
this.service = service this.service = service.(base.IRPCXService)
return return
} }
@ -71,8 +73,12 @@ func (this *Pagoda) Start() (err error) {
if module, err = this.service.GetModule(comm.ModuleBattle); err != nil { if module, err = this.service.GetModule(comm.ModuleBattle); err != nil {
return return
} }
if module, err = this.service.GetModule(comm.ModuleMail); err != nil {
return
}
this.mail = module.(comm.Imail)
this.battle = module.(comm.IBattle) this.battle = module.(comm.IBattle)
this.service.RegisterFunctionName(string(comm.Rpc_ModuleSeasonPagodaReward), this.Rpc_ModuleSeasonPagodaReward)
return return
} }
@ -169,3 +175,7 @@ func (this *Pagoda) CheckPoint(uid string) bool {
} }
return true return true
} }
func (this *Pagoda) Rpc_ModuleSeasonPagodaReward(ctx context.Context, args *pb.EmptyReq, reply *pb.EmptyResp) {
this.Debug("Rpc_ModuleSeasonPagodaReward", log.Field{Key: "args", Value: args.String()})
this.modulerank.seasonSettlement()
}

View File

@ -10,11 +10,11 @@ import (
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/sys/db" "go_dreamfactory/sys/db"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase" "go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/cron" "go_dreamfactory/lego/sys/cron"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/sys/redis/pipe"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
@ -30,7 +30,7 @@ type SeasonPagoda struct {
cbase.ModuleCompBase cbase.ModuleCompBase
modules.MCompConfigure modules.MCompConfigure
modules.MCompModel modules.MCompModel
service core.IService service base.IRPCXService
module *Timer module *Timer
mail comm.Imail mail comm.Imail
} }
@ -40,7 +40,7 @@ func (this *SeasonPagoda) Init(service core.IService, module core.IModule, comp
this.MCompConfigure.Init(service, module, comp, options) this.MCompConfigure.Init(service, module, comp, options)
this.TableName = comm.TableSeasonPagoda this.TableName = comm.TableSeasonPagoda
this.MCompModel.Init(service, module, comp, options) this.MCompModel.Init(service, module, comp, options)
this.service = service this.service = service.(base.IRPCXService)
this.module = module.(*Timer) this.module = module.(*Timer)
if module1, err := this.service.GetModule(comm.ModuleMail); err == nil { if module1, err := this.service.GetModule(comm.ModuleMail); err == nil {
@ -104,28 +104,6 @@ func (this *SeasonPagoda) GetSeasonLoop(id int32) *cfg.GameSeasonLoopData {
// // 赛季塔结束 // // 赛季塔结束
func (this *SeasonPagoda) TimerSeasonOver() { func (this *SeasonPagoda) TimerSeasonOver() {
this.module.Debugf("TimerSeasonOver:%d", configure.Now().Unix()) this.module.Debugf("TimerSeasonOver:%d", configure.Now().Unix())
if conn, err := db.Cross(); err == nil {
var (
pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
)
rd := pipe.ZRange("pagodaSeasonRank", 0, 50)
if _, err = pipe.Exec(); err != nil {
this.module.Errorln(err)
return
}
_data3 := rd.Val()
this.module.Debugf("%v", _data3)
//sz := this.GetSeasonReward()
// this.mail.SendNewMail(&pb.DBMailData{
// CreateTime: uint64(configure.Now().Unix()),
// Items: nil,
// }, _data3...)
}
if db.IsCross() { if db.IsCross() {
if conn, err := db.Cross(); err == nil { if conn, err := db.Cross(); err == nil {
if rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{}); rst != nil { if rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{}); rst != nil {
@ -156,12 +134,22 @@ func (this *SeasonPagoda) TimerSeasonOver() {
} }
} }
//star := configure.Now() if _, err := this.service.RpcGo(context.Background(),
this.DB.DeleteMany(comm.TableSeasonPagoda, bson.M{}, options.Delete()) comm.Service_Worker,
//this.module.Debugf("=====%d,", time.Since(star).Milliseconds()) string(comm.Rpc_ModuleSeasonPagodaReward),
pb.EmptyReq{},
nil,
); err != nil {
this.module.Errorln(err)
}
} }
// 赛季塔开始 // 赛季塔开始
func (this *SeasonPagoda) TimerSeasonStar() { func (this *SeasonPagoda) TimerSeasonStar() {
this.module.Debugf("TimerSeasonStar:%d", configure.Now().Unix()) this.module.Debugf("TimerSeasonStar:%d", configure.Now().Unix())
// 打印耗时
//star := configure.Now()
this.DB.DeleteMany(comm.TableSeasonPagoda, bson.M{}, options.Delete())
//this.module.Debugf("=====%d,", time.Since(star).Milliseconds())
} }