三消积分清理机制

This commit is contained in:
meixiongfeng 2024-01-09 16:47:00 +08:00
parent 5ac8f5abfc
commit 8b4654d1c4
5 changed files with 71 additions and 28 deletions

View File

@ -218,6 +218,8 @@ type (
// 体力转经验
PsConvertExp(ps int32) (res *cfg.Gameatn)
CleanUserConsumeMoney(session IUserSession) (err error)
}
//武器模块
IEquipment interface {

View File

@ -48,7 +48,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.EntertainGetList
if list.Etime > endSeasonTime {
list.Etime = endSeasonTime
update["etime"] = list.Etime
this.module.ModuleUser.CleanUserMerchantmoney(session)
this.module.ModuleUser.CleanUserConsumeMoney(session)
curMonth := time.Now().Month() // 计算赛季
curYear := time.Now().Year()
preMonth := this.module.service.GetOpentime().Month()
@ -56,6 +56,13 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.EntertainGetList
tmp := int(curYear-preYear)*12 + int(curMonth-preMonth)
list.Rounds = int32(tmp)
update["rounds"] = list.Rounds
// 低于一定的分数数据不清了
score := this.module.configure.GetConsumeResetIntegral()
if list.Consumeexp > score {
list.Consumeexp = score
update["consumeexp"] = list.Consumeexp
}
}
this.module.model.modifyEntertainmList(session.GetUserId(), update)
}

View File

@ -26,10 +26,11 @@ const (
// /配置管理组件
type configureComp struct {
modules.MCompConfigure
module *Entertainment
lock sync.RWMutex
block map[int32]*cfg.GameBlockData
order map[int32][]*cfg.GamePassCheckData //战令
module *Entertainment
lock sync.RWMutex
block map[int32]*cfg.GameBlockData
order map[int32][]*cfg.GamePassCheckData //战令
resetScore int32 // 重置积分
}
const moduleName = "entertainment"
@ -48,6 +49,9 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
})
configure.RegisterConfigure(game_block, cfg.NewGameBlock, this.LoadGameBlock)
configure.RegisterConfigure(game_passcheck, cfg.NewGamePassCheck, this.updatePassCheck)
configure.RegisterConfigure(game_consumeIntegral, cfg.NewGameConsumeIntegral, this.loadConsumeIntegral)
this.GetConsumeResetIntegral()
return
}
@ -365,3 +369,28 @@ func (this *configureComp) GetGameConsumeReward() (conf []*cfg.GameIntegralData,
err = comm.NewNotFoundConfErr(moduleName, game_integral, nil)
return
}
func (this *configureComp) loadConsumeIntegral() {
var (
v interface{}
configure *cfg.GameConsumeIntegral
err error
ok bool
)
if v, err = this.GetConfigure(game_consumeIntegral); err != nil {
this.module.Errorln(err)
return
}
if configure, ok = v.(*cfg.GameConsumeIntegral); ok {
for _, v := range configure.GetDataList() {
if v.Type == 2 {
this.resetScore = v.Key
break
}
}
}
return
}
func (this *configureComp) GetConsumeResetIntegral() (score int32) {
return this.resetScore
}

View File

@ -310,31 +310,23 @@ func (this *ModelUser) changelv(session comm.IUserSession, lv int32, exp int64,
}
func (this *ModelUser) CleanUserMerchantmoney(session comm.IUserSession) (err error) {
// 只处理跨服
if !db.IsCross() {
return
}
var (
update map[string]interface{}
uid string
)
uid = session.GetUserId()
user := &pb.DBUser{}
update = make(map[string]interface{}, 0)
update["profit"] = 0
update["merchantmoney"] = 0
if user.Caravanlv == 0 { // 默认1级
user.Caravanlv = 1
update["caravanlv"] = user.Caravanlv
// 获取本服的数据
if m, e := this.module.GetDBModelByUid(session.GetUserId(), this.TableName); e == nil {
user := &pb.DBUser{}
if err := m.Get(session.GetUserId(), user); err == nil {
if user.Caravanlv == 0 {
user.Caravanlv = 1
}
err = m.Change(session.GetUserId(), map[string]interface{}{
"profit": 0,
"caravanlv": user.Caravanlv,
"merchantmoney": 0,
})
} else {
this.module.Errorf("err:%v", err)
}
}
if err := this.Get(uid, user); err == nil {
err = this.Change(uid, update)
} else {
this.module.Errorf("err:%v", err)
}
return
}
@ -407,3 +399,12 @@ func (this *ModelUser) ResAutoReplies(session comm.IUserSession, resreplies map[
}
}
}
func (this *ModelUser) CleanUserConsumeMoney(session comm.IUserSession) (err error) {
// 获取本服的数据
if m, e := this.module.GetDBModelByUid(session.GetUserId(), this.TableName); e == nil {
err = m.Change(session.GetUserId(), map[string]interface{}{
"consumemoney": 0,
})
}
return
}

View File

@ -1476,3 +1476,7 @@ func (this *User) PsConvertExp(ps int32) (res *cfg.Gameatn) {
return
}
func (this *User) CleanUserConsumeMoney(session comm.IUserSession) (err error) {
return this.modelUser.CleanUserConsumeMoney(session)
}