加入公会任务事件

This commit is contained in:
wh_zcy 2022-11-23 15:47:56 +08:00
parent 9e710e9ef7
commit 3d616cbde9
6 changed files with 42 additions and 5 deletions

View File

@ -10,6 +10,11 @@ import (
)
func lenParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (n int, err error) {
if cfg.Data1 == 0 {
if len(vals) == 1 {
return 1, nil
}
}
if cfg.Data1 != 0 && cfg.Data2 != 0 && cfg.Data3 != 0 && cfg.Data4 != 0 && cfg.Data5 != 0 {
if len(vals) != 5 {
err = errors.New(fmt.Sprintf("%v 参数个数不一致,期望5实际是%v", cfg.Id, len(vals)))

View File

@ -169,6 +169,13 @@ func (this *ModuleRtask) initRtaskVerifyHandle() {
verify: this.modelRtaskRecord.verifyFirstGreatEqualParam,
update: this.modelRtaskRecord.addUpdate,
})
case comm.Rtype109:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtask.verifyRtype109,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype7, comm.Rtype12, comm.Rtype13, comm.Rtype14, comm.Rtype15,
comm.Rtype19, comm.Rtype21, comm.Rtype24,
comm.Rtype26, comm.Rtype27, comm.Rtype28, comm.Rtype38,

View File

@ -343,3 +343,18 @@ func (this *ModelRtask) verifyRtype63(uid string, cfg *cfg.GameRdtaskCondiData)
return
}
// 加入公会
func (this *ModelRtask) verifyRtype109(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
userModule, err := this.service.GetModule(comm.ModuleUser)
if err != nil {
return
}
if um, y := userModule.(comm.IUser); y {
if user, err := um.GetUserExpand(uid); err == nil {
return user.SociatyId != "", nil
}
}
return
}

View File

@ -51,6 +51,8 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) (
return
}
// 触发任务条件
this.module.ModuleRtask.SendToRtask(session, comm.Rtype109);
// 发邮件
if err := this.module.modelSociaty.sendMail("GuildApproved", []string{sociaty.Name}, []string{req.Uid}); err != nil {
this.module.Error("发送邮件 模板ID:GuildApproved", log.Fields{"uid": uid, "申请人": req.Uid, "sociatyId": sociaty.Id})

View File

@ -83,7 +83,8 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
}
// 申请
if err := this.module.modelSociaty.apply(uid, sociaty); err != nil {
isCheck, err := this.module.modelSociaty.apply(uid, sociaty)
if err != nil {
var customError = new(comm.CustomError)
if errors.As(err, &customError) {
code = customError.Code
@ -93,6 +94,12 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
this.module.Error("公会申请", log.Fields{"uid": uid, "sociatyId": req.SociatyId, "err": err.Error()})
return
}
// 无需审核
if !isCheck {
// 触发任务条件
this.module.ModuleRtask.SendToRtask(session, comm.Rtype109)
}
rsp := &pb.SociatyApplyResp{
Uid: uid,
ScoiatyId: req.SociatyId,

View File

@ -232,9 +232,10 @@ func (this *ModelSociaty) getUserSociaty(uid string) (sociaty *pb.DBSociaty) {
}
// 申请公会
func (this *ModelSociaty) apply(uid string, sociaty *pb.DBSociaty) error {
func (this *ModelSociaty) apply(uid string, sociaty *pb.DBSociaty) (isCheck bool,err error) {
// 判断公会审批设置
if sociaty.IsApplyCheck { //需要审核
isCheck = true
sociaty.ApplyRecord = append(sociaty.ApplyRecord, &pb.ApplyRecord{
Uid: uid,
Ctime: configure.Now().Unix(),
@ -242,15 +243,15 @@ func (this *ModelSociaty) apply(uid string, sociaty *pb.DBSociaty) error {
update := map[string]interface{}{
"applyRecord": sociaty.ApplyRecord,
}
return this.updateSociaty(sociaty.Id, update)
err = this.updateSociaty(sociaty.Id, update)
} else { //无需审核直接入会
if err := this.addMember(uid, sociaty); err != nil {
return err
return isCheck,err
}
//初始玩家公会任务
this.moduleSociaty.modelSociatyTask.initSociatyTask(uid, sociaty.Id)
}
return nil
return
}
// 设置公会