上传事件
This commit is contained in:
parent
47880f27d5
commit
59aff5c46b
@ -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.Rtype61, 1, int32(req.Level)))
|
||||
go this.module.ModuleBuried.TriggerBuried(session.Clone(), tasks...)
|
||||
go this.module.ModuleSys.CheckOpenCond(session.Clone(), comm.OpencondTypeMaxmapid, req.Level)
|
||||
return
|
||||
}
|
||||
|
@ -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.Exp.T == "guildexp" {
|
||||
if err := this.module.modelSociaty.updateSociatyExp(cfg.Exp.N, sociaty); err != nil {
|
||||
this.module.Error("公会经验更新",
|
||||
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()},
|
||||
)
|
||||
}
|
||||
update := map[string]interface{}{}
|
||||
this.module.modelSociaty.updateSociatyExp(cfg.Exp.N, sociaty, update)
|
||||
// 更新等级
|
||||
if err := this.module.modelSociaty.changeLv(sociaty); err != nil {
|
||||
this.module.Error("公会等级更新",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
||||
log.Field{Key: "err", Value: err.Error()},
|
||||
)
|
||||
if changelv, err := this.module.modelSociaty.changeLv(sociaty, update); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package sociaty
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
@ -19,10 +20,12 @@ const (
|
||||
|
||||
type configureComp struct {
|
||||
modules.MCompConfigure
|
||||
module *Sociaty
|
||||
}
|
||||
|
||||
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)
|
||||
this.module = module.(*Sociaty)
|
||||
err = this.LoadMultiConfigure(map[string]interface{}{
|
||||
gameSociatyLv: cfg.NewGameGuildLv,
|
||||
gameSociatyTask: cfg.NewGameGuildTask,
|
||||
@ -44,7 +47,7 @@ func (this *configureComp) getSociatyLvCfg() (data *cfg.GameGuildLv, err error)
|
||||
return
|
||||
} else {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -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 += val
|
||||
update := map[string]interface{}{
|
||||
"exp": exp,
|
||||
}
|
||||
return this.updateSociaty(sociaty.Id, update)
|
||||
update["exp"] = exp
|
||||
}
|
||||
|
||||
// 更新成员贡献值
|
||||
@ -886,37 +883,26 @@ func (this *ModelSociaty) rank() (rank []*pb.DBSociatyRank) {
|
||||
}
|
||||
|
||||
// 等级更新
|
||||
func (this *ModelSociaty) changeLv(sociaty *pb.DBSociaty) error {
|
||||
ggl, err := this.module.configure.getSociatyLvCfg()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
func (this *ModelSociaty) changeLv(sociaty *pb.DBSociaty, update map[string]interface{}) (changelv bool, err error) {
|
||||
var (
|
||||
ggl *cfg.GameGuildLv
|
||||
)
|
||||
|
||||
if ggl == nil {
|
||||
return errors.New("sociatyLvConf is nil")
|
||||
if ggl, err = this.module.configure.getSociatyLvCfg(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
curLv := sociaty.Lv
|
||||
update := map[string]interface{}{}
|
||||
|
||||
lv := curLv + 1
|
||||
if conf, ok := ggl.GetDataMap()[lv]; ok {
|
||||
if sociaty.Exp > conf.Exp {
|
||||
update["lv"] = lv
|
||||
sociaty.Lv = lv
|
||||
changelv = true
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
return
|
||||
}
|
||||
|
||||
// 获取可容纳的最大上限
|
||||
|
@ -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())
|
||||
if sociaty == nil || sociaty.Id == "" {
|
||||
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,
|
||||
}
|
||||
|
||||
err := this.modelSociaty.updateSociaty(sociaty.Id, update)
|
||||
if err != nil {
|
||||
return err
|
||||
if _, err = this.modelSociaty.changeLv(sociaty, update); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return this.modelSociaty.changeLv(sociaty)
|
||||
err = this.modelSociaty.updateSociaty(sociaty.Id, update)
|
||||
return
|
||||
}
|
||||
|
||||
// 设置工会活跃度
|
||||
|
@ -24,16 +24,12 @@ import (
|
||||
type ModelUser struct {
|
||||
modules.MCompModel
|
||||
module *User
|
||||
// EventApp *event_v2.App
|
||||
}
|
||||
|
||||
func (this *ModelUser) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.TableName = comm.TableUser
|
||||
err = this.MCompModel.Init(service, module, comp, options)
|
||||
this.module = module.(*User)
|
||||
// this.EventApp = event_v2.NewApp()
|
||||
// this.EventApp.Listen(comm.EventUserVipChanged, this.ChangeVipExp)
|
||||
// this.EventApp.Listen(comm.EventUserChanged, this.ChangeLevel)
|
||||
// 通过uid创建索引
|
||||
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
||||
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.sys.CheckOpenCond(session, comm.OpencondTypePlatlv, lv)
|
||||
go this.module.sys.CheckOpenCond(session.Clone(), comm.OpencondTypePlatlv, lv)
|
||||
session.Push()
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,7 @@ func (this *apiComp) FinishCheck(session comm.IUserSession, req *pb.WTaskFinishR
|
||||
// /获取系统公告
|
||||
func (this *apiComp) Finish(session comm.IUserSession, req *pb.WTaskFinishReq) (errdata *pb.ErrorData) {
|
||||
var (
|
||||
conf *cfg.GameWorldTaskData
|
||||
// afterconf *cfg.GameWorldTaskData
|
||||
conf *cfg.GameWorldTaskData
|
||||
wtask *pb.DBWTask
|
||||
condis []*pb.ConIProgress
|
||||
award []*pb.UserAtno
|
||||
@ -151,5 +150,6 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WTaskFinishReq) (
|
||||
if conf.Des == 5 {
|
||||
this.module.caravan.TaskComplete(session, req.Tid)
|
||||
}
|
||||
go this.module.ModuleSys.CheckOpenCond(session.Clone(), comm.OpencondTypeWorldtaskid, req.Tid)
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user