147 lines
4.0 KiB
Go
147 lines
4.0 KiB
Go
// package
|
|
// 公会
|
|
// 赵长远
|
|
package sociaty
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/base"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
var _ comm.ISociaty = (*Sociaty)(nil)
|
|
|
|
type Sociaty struct {
|
|
modules.ModuleBase
|
|
api *apiComp
|
|
service base.IRPCXService
|
|
modelSociaty *ModelSociaty
|
|
modelSociatyTask *ModelSociatyTask
|
|
modelSociatyLog *ModelSociatyLog
|
|
configure *configureComp
|
|
globalConf *cfg.GameGlobalData
|
|
sociatyActivityConf *cfg.GameGuildActivity
|
|
sociatyTaskConf *cfg.GameGuildTask
|
|
sociatySignConf *cfg.GameGuildSign
|
|
rtaskCondConf *cfg.GameRdtaskCondi
|
|
}
|
|
|
|
func NewModule() core.IModule {
|
|
return &Sociaty{}
|
|
}
|
|
|
|
func (this *Sociaty) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
|
err = this.ModuleBase.Init(service, module, options)
|
|
this.service = service.(base.IRPCXService)
|
|
return
|
|
}
|
|
|
|
func (this *Sociaty) GetType() core.M_Modules {
|
|
return comm.ModuleSociaty
|
|
}
|
|
|
|
func (this *Sociaty) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
this.modelSociaty = this.RegisterComp(new(ModelSociaty)).(*ModelSociaty)
|
|
this.modelSociatyTask = this.RegisterComp(new(ModelSociatyTask)).(*ModelSociatyTask)
|
|
this.modelSociatyLog = this.RegisterComp(new(ModelSociatyLog)).(*ModelSociatyLog)
|
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
|
}
|
|
|
|
func (this *Sociaty) Start() (err error) {
|
|
err = this.ModuleBase.Start()
|
|
this.service.RegisterFunctionName(string(comm.Rpc_ModuleSociaty), this.RpcGetSociaty)
|
|
this.globalConf = this.configure.GetGlobalConf()
|
|
if this.globalConf == nil {
|
|
err = errors.New("global config not found")
|
|
return
|
|
}
|
|
if this.sociatyActivityConf, err = this.configure.getSociatyActivityCfg(); err != nil {
|
|
return err
|
|
}
|
|
if this.sociatyTaskConf, err = this.configure.getSociatyTaskCfg(); err != nil {
|
|
return err
|
|
}
|
|
if this.rtaskCondConf, err = this.configure.getRtaskCondiCfg(); err != nil {
|
|
return err
|
|
}
|
|
if this.sociatySignConf, err = this.configure.getSociatySignCfg(); err != nil {
|
|
return err
|
|
}
|
|
return
|
|
}
|
|
|
|
// 会长弹劾处理
|
|
// Deprecated
|
|
func (this *Sociaty) ProcessAccuse(uid, sociatyId string) {
|
|
t := this.globalConf.GuildImpeachmentCountDown
|
|
if t == 0 {
|
|
return
|
|
}
|
|
sociaty := this.modelSociaty.getSociaty(sociatyId)
|
|
if sociaty != nil {
|
|
if sociaty.AccuseTime > 0 {
|
|
now := configure.Now().Unix()
|
|
if now-sociaty.AccuseTime >= int64(3600*t) {
|
|
//TODO 选新会长
|
|
|
|
} else {
|
|
//结束弹劾
|
|
update := map[string]interface{}{
|
|
"accuseTime": 0,
|
|
}
|
|
if err := this.modelSociaty.updateSociaty(sociatyId, update); err != nil {
|
|
this.Errorf("弹劾时间更新失败 %v", err)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 获取我的公会成员
|
|
func (this *Sociaty) MembersByUid(uid string) (list []*pb.SociatyMemberInfo) {
|
|
sociaty := this.modelSociaty.getUserSociaty(uid)
|
|
return this.modelSociaty.members(sociaty)
|
|
}
|
|
|
|
// 获取公会成员
|
|
func (this *Sociaty) MembersBySociatyId(sociatyId string) (list []*pb.SociatyMemberInfo) {
|
|
sociaty := this.modelSociaty.getSociaty(sociatyId)
|
|
return this.modelSociaty.members(sociaty)
|
|
}
|
|
|
|
//公会
|
|
func (this *Sociaty) Reddot(uid string, rid ...comm.ReddotType) (reddot map[comm.ReddotType]bool) {
|
|
reddot = make(map[comm.ReddotType]bool)
|
|
sociaty := this.modelSociaty.getUserSociaty(uid)
|
|
if sociaty == nil || sociaty.Id == "" {
|
|
reddot[comm.Reddot3] = false
|
|
return
|
|
}
|
|
for _, v := range rid {
|
|
switch v {
|
|
case comm.Reddot3:
|
|
if ok := this.modelSociaty.IsSign(uid, sociaty); !ok {
|
|
reddot[comm.Reddot3] = true
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// 跨服获取公会
|
|
func (this *Sociaty) RpcGetSociaty(ctx context.Context, req *pb.RPCGeneralReqA1, reply *pb.DBSociaty) error {
|
|
this.Debug("Rpc_ModuleSociaty", log.Fields{"req": req})
|
|
sociaty := this.modelSociaty.getSociaty(req.Param1)
|
|
*reply = *sociaty
|
|
return nil
|
|
}
|