上传事件

This commit is contained in:
liwei1dao 2023-09-08 14:55:02 +08:00
parent 47880f27d5
commit 59aff5c46b
7 changed files with 45 additions and 52 deletions

View File

@ -173,5 +173,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype60, 1)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype60, 1))
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype61, 1, int32(req.Level))) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype61, 1, int32(req.Level)))
go this.module.ModuleBuried.TriggerBuried(session.Clone(), tasks...) go this.module.ModuleBuried.TriggerBuried(session.Clone(), tasks...)
go this.module.ModuleSys.CheckOpenCond(session.Clone(), comm.OpencondTypeMaxmapid, req.Level)
return return
} }

View File

@ -71,21 +71,28 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (er
if cfg, ok := this.module.sociatySignConf.GetDataMap()[signCfgId]; ok { if cfg, ok := this.module.sociatySignConf.GetDataMap()[signCfgId]; ok {
// 更新公会经验 // 更新公会经验
if cfg.Exp.T == "guildexp" { if cfg.Exp.T == "guildexp" {
if err := this.module.modelSociaty.updateSociatyExp(cfg.Exp.N, sociaty); err != nil { update := map[string]interface{}{}
this.module.Error("公会经验更新", this.module.modelSociaty.updateSociatyExp(cfg.Exp.N, sociaty, update)
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "经验", Value: cfg.Exp.N},
log.Field{Key: "err", Value: err.Error()},
)
}
// 更新等级 // 更新等级
if err := this.module.modelSociaty.changeLv(sociaty); err != nil { if changelv, err := this.module.modelSociaty.changeLv(sociaty, update); err != nil {
this.module.Error("公会等级更新", errdata = &pb.ErrorData{
log.Field{Key: "uid", Value: uid}, Code: pb.ErrorCode_ConfigNoFound,
log.Field{Key: "sociatyId", Value: sociaty.Id}, Title: pb.ErrorCode_ConfigNoFound.ToString(),
log.Field{Key: "err", Value: err.Error()}, Message: err.Error(),
) }
} else if changelv {
this.module.modelSociaty.EventApp.Dispatch(comm.EventSociatyRankChanged, &SociatyListen{
sociaty: sociaty,
})
go this.module.ModuleSys.CheckOpenCond(session.Clone(), comm.OpencondTypeWorldtaskid, sociaty.Lv)
}
if err := this.module.modelSociaty.updateSociaty(sociaty.Id, update); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
} }
} }
} }

View File

@ -2,6 +2,7 @@ package sociaty
import ( import (
"fmt" "fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/modules" "go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
@ -19,10 +20,12 @@ const (
type configureComp struct { type configureComp struct {
modules.MCompConfigure modules.MCompConfigure
module *Sociaty
} }
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompConfigure.Init(service, module, comp, options) err = this.MCompConfigure.Init(service, module, comp, options)
this.module = module.(*Sociaty)
err = this.LoadMultiConfigure(map[string]interface{}{ err = this.LoadMultiConfigure(map[string]interface{}{
gameSociatyLv: cfg.NewGameGuildLv, gameSociatyLv: cfg.NewGameGuildLv,
gameSociatyTask: cfg.NewGameGuildTask, gameSociatyTask: cfg.NewGameGuildTask,
@ -44,7 +47,7 @@ func (this *configureComp) getSociatyLvCfg() (data *cfg.GameGuildLv, err error)
return return
} else { } else {
if data, ok = v.(*cfg.GameGuildLv); !ok { if data, ok = v.(*cfg.GameGuildLv); !ok {
err = fmt.Errorf("%T no is *cfg.GameGuildLv", v) err = comm.NewNotFoundConfErr(string(this.module.GetType()), gameSociatyLv, fmt.Errorf("%T no is *cfg.GameGuildLv", v))
return return
} }
} }

View File

@ -775,13 +775,10 @@ func (this *ModelSociaty) updateResourceFromTask(sociaty *pb.DBSociaty, conf *cf
} }
// 更新经验 // 更新经验
func (this *ModelSociaty) updateSociatyExp(val int32, sociaty *pb.DBSociaty) error { func (this *ModelSociaty) updateSociatyExp(val int32, sociaty *pb.DBSociaty, update map[string]interface{}) {
exp := sociaty.Exp //经验 exp := sociaty.Exp //经验
exp += val exp += val
update := map[string]interface{}{ update["exp"] = exp
"exp": exp,
}
return this.updateSociaty(sociaty.Id, update)
} }
// 更新成员贡献值 // 更新成员贡献值
@ -886,37 +883,26 @@ func (this *ModelSociaty) rank() (rank []*pb.DBSociatyRank) {
} }
// 等级更新 // 等级更新
func (this *ModelSociaty) changeLv(sociaty *pb.DBSociaty) error { func (this *ModelSociaty) changeLv(sociaty *pb.DBSociaty, update map[string]interface{}) (changelv bool, err error) {
ggl, err := this.module.configure.getSociatyLvCfg() var (
if err != nil { ggl *cfg.GameGuildLv
return err )
}
if ggl == nil { if ggl, err = this.module.configure.getSociatyLvCfg(); err != nil {
return errors.New("sociatyLvConf is nil") return
} }
curLv := sociaty.Lv curLv := sociaty.Lv
update := map[string]interface{}{}
lv := curLv + 1 lv := curLv + 1
if conf, ok := ggl.GetDataMap()[lv]; ok { if conf, ok := ggl.GetDataMap()[lv]; ok {
if sociaty.Exp > conf.Exp { if sociaty.Exp > conf.Exp {
update["lv"] = lv update["lv"] = lv
sociaty.Lv = lv
changelv = true
} }
} }
return
if len(update) > 0 {
if err = this.updateSociaty(sociaty.Id, update); err != nil {
return err
}
// 更新排行榜
this.EventApp.Dispatch(comm.EventSociatyRankChanged, &SociatyListen{
sociaty: sociaty,
})
}
return nil
} }
// 获取可容纳的最大上限 // 获取可容纳的最大上限

View File

@ -278,7 +278,7 @@ func (this *Sociaty) RpcUpdateSociaty(ctx context.Context, req *SociatyUpdatePar
} }
// 设置工会经验 // 设置工会经验
func (this *Sociaty) BingoSetExp(session comm.IUserSession, exp int32) error { func (this *Sociaty) BingoSetExp(session comm.IUserSession, exp int32) (err error) {
sociaty := this.modelSociaty.getUserSociaty(session.GetUserId()) sociaty := this.modelSociaty.getUserSociaty(session.GetUserId())
if sociaty == nil || sociaty.Id == "" { if sociaty == nil || sociaty.Id == "" {
log.Warn("未获得公会信息", log.Field{Key: "uid", Value: session.GetUserId()}) log.Warn("未获得公会信息", log.Field{Key: "uid", Value: session.GetUserId()})
@ -289,12 +289,12 @@ func (this *Sociaty) BingoSetExp(session comm.IUserSession, exp int32) error {
"exp": sociaty.Exp, "exp": sociaty.Exp,
} }
err := this.modelSociaty.updateSociaty(sociaty.Id, update) if _, err = this.modelSociaty.changeLv(sociaty, update); err != nil {
if err != nil { return
return err
} }
return this.modelSociaty.changeLv(sociaty) err = this.modelSociaty.updateSociaty(sociaty.Id, update)
return
} }
// 设置工会活跃度 // 设置工会活跃度

View File

@ -24,16 +24,12 @@ import (
type ModelUser struct { type ModelUser struct {
modules.MCompModel modules.MCompModel
module *User module *User
// EventApp *event_v2.App
} }
func (this *ModelUser) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { func (this *ModelUser) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.TableName = comm.TableUser this.TableName = comm.TableUser
err = this.MCompModel.Init(service, module, comp, options) err = this.MCompModel.Init(service, module, comp, options)
this.module = module.(*User) this.module = module.(*User)
// this.EventApp = event_v2.NewApp()
// this.EventApp.Listen(comm.EventUserVipChanged, this.ChangeVipExp)
// this.EventApp.Listen(comm.EventUserChanged, this.ChangeLevel)
// 通过uid创建索引 // 通过uid创建索引
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
@ -279,7 +275,7 @@ func (this *ModelUser) changelv(session comm.IUserSession, lv int32, exp int64,
) )
} }
this.module.chat.SendSysChatToUser(session, comm.ChatSystem12, lv, 0, name) this.module.chat.SendSysChatToUser(session, comm.ChatSystem12, lv, 0, name)
this.module.sys.CheckOpenCond(session, comm.OpencondTypePlatlv, lv) go this.module.sys.CheckOpenCond(session.Clone(), comm.OpencondTypePlatlv, lv)
session.Push() session.Push()
} }

View File

@ -18,7 +18,6 @@ func (this *apiComp) FinishCheck(session comm.IUserSession, req *pb.WTaskFinishR
func (this *apiComp) Finish(session comm.IUserSession, req *pb.WTaskFinishReq) (errdata *pb.ErrorData) { func (this *apiComp) Finish(session comm.IUserSession, req *pb.WTaskFinishReq) (errdata *pb.ErrorData) {
var ( var (
conf *cfg.GameWorldTaskData conf *cfg.GameWorldTaskData
// afterconf *cfg.GameWorldTaskData
wtask *pb.DBWTask wtask *pb.DBWTask
condis []*pb.ConIProgress condis []*pb.ConIProgress
award []*pb.UserAtno award []*pb.UserAtno
@ -151,5 +150,6 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WTaskFinishReq) (
if conf.Des == 5 { if conf.Des == 5 {
this.module.caravan.TaskComplete(session, req.Tid) this.module.caravan.TaskComplete(session, req.Tid)
} }
go this.module.ModuleSys.CheckOpenCond(session.Clone(), comm.OpencondTypeWorldtaskid, req.Tid)
return return
} }