优化全局配置
This commit is contained in:
parent
3533baf805
commit
93057ea171
@ -23,7 +23,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
RDS_SESSION = ""
|
RDS_EMPTY = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
//ERR
|
//ERR
|
||||||
|
@ -21,12 +21,6 @@ func (this *apiComp) Addblack(session comm.IUserSession, req *pb.FriendAddBlackR
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
globalCnf := this.moduleFriend.configure.GetGlobalConf()
|
|
||||||
if globalCnf == nil {
|
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
self *pb.DBFriend
|
self *pb.DBFriend
|
||||||
@ -76,7 +70,7 @@ func (this *apiComp) Addblack(session comm.IUserSession, req *pb.FriendAddBlackR
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 判断是否黑名单人数已满
|
// 判断是否黑名单人数已满
|
||||||
if len(self.BlackIds) >= int(globalCnf.FriendBlack) {
|
if len(self.BlackIds) >= int(this.moduleFriend.globalConf.FriendBlack) {
|
||||||
code = pb.ErrorCode_FriendBlackMax
|
code = pb.ErrorCode_FriendBlackMax
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,6 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.FriendApplyReq) (c
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
globalCnf := this.moduleFriend.configure.GetGlobalConf()
|
|
||||||
if globalCnf == nil {
|
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
self *pb.DBFriend
|
self *pb.DBFriend
|
||||||
@ -67,15 +61,15 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.FriendApplyReq) (c
|
|||||||
code = pb.ErrorCode_FriendNotSelf
|
code = pb.ErrorCode_FriendNotSelf
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
globalConf := this.moduleFriend.globalConf
|
||||||
//判断是否超过最大好友数量
|
//判断是否超过最大好友数量
|
||||||
if len(self.FriendIds) >= int(globalCnf.FriendMaxnum) {
|
if len(self.FriendIds) >= int(globalConf.FriendMaxnum) {
|
||||||
code = pb.ErrorCode_FriendSelfMax
|
code = pb.ErrorCode_FriendSelfMax
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//判断对方是否也超过最大好友数量
|
//判断对方是否也超过最大好友数量
|
||||||
if len(target.FriendIds) >= int(globalCnf.FriendMaxnum) {
|
if len(target.FriendIds) >= int(globalConf.FriendMaxnum) {
|
||||||
code = pb.ErrorCode_FriendTargetMax
|
code = pb.ErrorCode_FriendTargetMax
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ func (this *apiComp) Getreward(session comm.IUserSession, req *pb.FriendGetrewar
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
code = this.moduleFriend.DispenseRes(session, this.moduleFriend.configure.GetGlobalConf().FriendPeize, true)
|
code = this.moduleFriend.DispenseRes(session, this.moduleFriend.globalConf.FriendPeize, true)
|
||||||
|
|
||||||
rsp := &pb.FriendGetrewardResp{Received: int32(received)}
|
rsp := &pb.FriendGetrewardResp{Received: int32(received)}
|
||||||
|
|
||||||
|
@ -27,12 +27,6 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (code
|
|||||||
selfId string
|
selfId string
|
||||||
)
|
)
|
||||||
|
|
||||||
globalCnf := this.moduleFriend.configure.GetGlobalConf()
|
|
||||||
if globalCnf == nil {
|
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
selfId = session.GetUserId()
|
selfId = session.GetUserId()
|
||||||
|
|
||||||
// 不能给自己点赞
|
// 不能给自己点赞
|
||||||
@ -76,7 +70,7 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (code
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 今日送出的友情点是否达到上限
|
// 今日送出的友情点是否达到上限
|
||||||
if ue.FriendPointOD >= globalCnf.FriendMaxsendnum {
|
if ue.FriendPointOD >= this.moduleFriend.globalConf.FriendMaxsendnum {
|
||||||
code = pb.ErrorCode_FriendPointLimit
|
code = pb.ErrorCode_FriendPointLimit
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,6 @@ func (this *apiComp) Zanreceive(session comm.IUserSession, req *pb.FriendZanrece
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
globalCnf := this.moduleFriend.configure.GetGlobalConf()
|
|
||||||
if globalCnf == nil {
|
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
self *pb.DBFriend
|
self *pb.DBFriend
|
||||||
err error
|
err error
|
||||||
@ -68,7 +62,7 @@ func (this *apiComp) Zanreceive(session comm.IUserSession, req *pb.FriendZanrece
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 今日获赠的友情点是否达到上限
|
// 今日获赠的友情点是否达到上限
|
||||||
if ue.FriendPointID >= int32(globalCnf.FriendMaxgetnum) {
|
if ue.FriendPointID >= int32(this.moduleFriend.globalConf.FriendMaxgetnum) {
|
||||||
code = pb.ErrorCode_FriendPointLimit
|
code = pb.ErrorCode_FriendPointLimit
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ import (
|
|||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
|
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
|
||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,6 +34,7 @@ type Friend struct {
|
|||||||
modelFriend *ModelFriend
|
modelFriend *ModelFriend
|
||||||
configure *modules.MCompConfigure
|
configure *modules.MCompConfigure
|
||||||
service base.IRPCXService
|
service base.IRPCXService
|
||||||
|
globalConf *cfg.GameGlobalData
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Friend) GetType() core.M_Modules {
|
func (this *Friend) GetType() core.M_Modules {
|
||||||
@ -53,6 +56,10 @@ func (this *Friend) OnInstallComp() {
|
|||||||
func (this *Friend) Start() (err error) {
|
func (this *Friend) Start() (err error) {
|
||||||
err = this.ModuleBase.Start()
|
err = this.ModuleBase.Start()
|
||||||
this.service.RegisterFunctionName(string(comm.Rpc_ModuleFriendUseAssitHero), this.RpcUseAssisHero)
|
this.service.RegisterFunctionName(string(comm.Rpc_ModuleFriendUseAssitHero), this.RpcUseAssisHero)
|
||||||
|
this.globalConf = this.configure.GetGlobalConf()
|
||||||
|
if this.globalConf == nil {
|
||||||
|
err = errors.New("global config not found")
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,12 +20,6 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
|
|||||||
if code = this.ApplyCheck(session, req); code != pb.ErrorCode_Success {
|
if code = this.ApplyCheck(session, req); code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 全局配置
|
|
||||||
ggd := this.module.configure.GetGlobalConf()
|
|
||||||
if ggd == nil {
|
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
uid := session.GetUserId()
|
uid := session.GetUserId()
|
||||||
|
|
||||||
@ -78,7 +72,7 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
//判断申请人数是否超出最大允许申请数
|
//判断申请人数是否超出最大允许申请数
|
||||||
if len(sociaty.ApplyRecord) >= int(ggd.GuildAcceptApplyMax) {
|
if len(sociaty.ApplyRecord) >= int(this.module.globalConf.GuildAcceptApplyMax) {
|
||||||
code = pb.ErrorCode_SociatyApplyMax
|
code = pb.ErrorCode_SociatyApplyMax
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package sociaty
|
package sociaty
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
@ -60,23 +61,21 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 验证公会名是否重复
|
// 验证公会名是否重复
|
||||||
if ok, err := this.module.modelSociaty.isNameExist(req.Name); ok {
|
if err := this.module.modelSociaty.isNameExist(req.Name); err != nil {
|
||||||
if err != nil {
|
var customErr = new(comm.CustomError)
|
||||||
code = pb.ErrorCode_DBError
|
if errors.As(err, &customErr) {
|
||||||
} else {
|
if customErr.Code == pb.ErrorCode_SociatyNameExist {
|
||||||
code = pb.ErrorCode_SociatyNameExist
|
code = pb.ErrorCode_SociatyNameExist
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//检查钻石
|
//检查钻石
|
||||||
ggd := this.module.modelSociaty.moduleSociaty.configure.GetGlobalConf()
|
if code = this.module.ConsumeRes(session, []*cfg.Gameatn{
|
||||||
if ggd == nil {
|
this.module.globalConf.GuildBuildCos}, true); code != pb.ErrorCode_Success {
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if code = this.module.ConsumeRes(session, []*cfg.Gameatn{ggd.GuildBuildCos}, true); code != pb.ErrorCode_Success {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,12 +15,6 @@ func (this *apiComp) DismissCheck(session comm.IUserSession, req *pb.SociatyDism
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
// 全局配置
|
|
||||||
ggd := this.module.configure.GetGlobalConf()
|
|
||||||
if ggd == nil {
|
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
|
||||||
return
|
|
||||||
}
|
|
||||||
uid := session.GetUserId()
|
uid := session.GetUserId()
|
||||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||||
if sociaty.Id == "" {
|
if sociaty.Id == "" {
|
||||||
@ -40,10 +34,10 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
update := map[string]interface{}{}
|
update := map[string]interface{}{}
|
||||||
|
globalCnf := this.module.globalConf
|
||||||
if sociaty.DismissTime == 0 {
|
if sociaty.DismissTime == 0 {
|
||||||
//更新解散倒计时
|
//更新解散倒计时
|
||||||
update["dismissTime"] = utils.AddHour(int(ggd.GuildDissolutionCountDownCd)).Unix()
|
update["dismissTime"] = utils.AddHour(int(globalCnf.GuildDissolutionCountDownCd)).Unix()
|
||||||
} else {
|
} else {
|
||||||
if req.Dismiss == 1 { //取消解散
|
if req.Dismiss == 1 { //取消解散
|
||||||
if utils.IsInCDHour(int64(sociaty.DismissCD)) {
|
if utils.IsInCDHour(int64(sociaty.DismissCD)) {
|
||||||
@ -51,7 +45,7 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe
|
|||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
// 设置冷区时间
|
// 设置冷区时间
|
||||||
update["dismissCD"] = utils.AddHour(int(ggd.GuildDissolutionCd)).Unix()
|
update["dismissCD"] = utils.AddHour(int(globalCnf.GuildDissolutionCd)).Unix()
|
||||||
}
|
}
|
||||||
//取消倒计时
|
//取消倒计时
|
||||||
update["dismissTime"] = 0
|
update["dismissTime"] = 0
|
||||||
|
@ -16,13 +16,6 @@ func (this *apiComp) QuitCheck(session comm.IUserSession, req *pb.SociatyQuitReq
|
|||||||
|
|
||||||
func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
uid := session.GetUserId()
|
uid := session.GetUserId()
|
||||||
// 全局配置
|
|
||||||
ggd := this.module.configure.GetGlobalConf()
|
|
||||||
if ggd == nil {
|
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||||
if sociaty.Id == "" {
|
if sociaty.Id == "" {
|
||||||
code = pb.ErrorCode_SociatyNoFound
|
code = pb.ErrorCode_SociatyNoFound
|
||||||
@ -46,7 +39,7 @@ func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (co
|
|||||||
//更新玩家sociatyId
|
//更新玩家sociatyId
|
||||||
update := map[string]interface{}{
|
update := map[string]interface{}{
|
||||||
"sociatyId": "", //玩家公会ID置空
|
"sociatyId": "", //玩家公会ID置空
|
||||||
"sociatyCd": utils.AddHour(int(ggd.GuildRejoinCd)).Unix(),
|
"sociatyCd": utils.AddHour(int(this.module.globalConf.GuildRejoinCd)).Unix(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := this.module.ModuleUser.ChangeRemoteUserExpand(uid, update); err != nil {
|
if err := this.module.ModuleUser.ChangeRemoteUserExpand(uid, update); err != nil {
|
||||||
|
@ -19,12 +19,6 @@ func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettin
|
|||||||
if code = this.SettingJobCheck(session, req); code != pb.ErrorCode_Success {
|
if code = this.SettingJobCheck(session, req); code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 全局配置
|
|
||||||
ggd := this.module.configure.GetGlobalConf()
|
|
||||||
if ggd == nil {
|
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
uid := session.GetUserId()
|
uid := session.GetUserId()
|
||||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||||
@ -42,9 +36,10 @@ func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 判断职位人数
|
// 判断职位人数
|
||||||
|
globalConf := this.module.globalConf
|
||||||
jobCount := this.module.modelSociaty.getJobCount(req.Job, sociaty)
|
jobCount := this.module.modelSociaty.getJobCount(req.Job, sociaty)
|
||||||
if req.Job == pb.SociatyJob_VICEPRESIDENT && jobCount >= int(ggd.GuildViceAllianceLeaderMaxNum) ||
|
if req.Job == pb.SociatyJob_VICEPRESIDENT && jobCount >= int(globalConf.GuildViceAllianceLeaderMaxNum) ||
|
||||||
req.Job == pb.SociatyJob_ADMIN && jobCount >= int(ggd.GuildAdministratorsMaxNum) {
|
req.Job == pb.SociatyJob_ADMIN && jobCount >= int(globalConf.GuildAdministratorsMaxNum) {
|
||||||
code = pb.ErrorCode_SociatyMemberCountLimit
|
code = pb.ErrorCode_SociatyMemberCountLimit
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -72,21 +72,21 @@ func (this *ModelSociaty) create(sociaty *pb.DBSociaty) error {
|
|||||||
if sociaty.ApplyLv == 0 {
|
if sociaty.ApplyLv == 0 {
|
||||||
sociaty.ApplyLv = 1 //默认玩家入会等级
|
sociaty.ApplyLv = 1 //默认玩家入会等级
|
||||||
}
|
}
|
||||||
return this.AddList("", sociaty.Id, sociaty)
|
return this.AddList(comm.RDS_EMPTY, sociaty.Id, sociaty)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 公会名是否存在
|
// 公会名是否存在
|
||||||
func (this *ModelSociaty) isNameExist(name string) (bool, error) {
|
func (this *ModelSociaty) isNameExist(name string) error {
|
||||||
var sociaties []*pb.DBSociaty
|
var sociaties []*pb.DBSociaty
|
||||||
if err := this.GetList("", &sociaties); err != nil {
|
if err := this.GetList(comm.RDS_EMPTY, &sociaties); err != nil {
|
||||||
return false, err
|
return err
|
||||||
}
|
}
|
||||||
for _, s := range sociaties {
|
for _, s := range sociaties {
|
||||||
if s.Name == name {
|
if s.Name == name {
|
||||||
return true, nil
|
return comm.NewCustomError(pb.ErrorCode_SociatyNameExist)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false, nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 公会列表
|
// 公会列表
|
||||||
@ -179,7 +179,7 @@ func (this *ModelSociaty) isDismiss(sociaty *pb.DBSociaty) bool {
|
|||||||
if sociaty.DismissTime == 0 {
|
if sociaty.DismissTime == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if utils.IsInCDHour(sociaty.DismissTime) { //
|
if utils.IsInCDHour(sociaty.DismissTime) {
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
if err := this.dismiss(sociaty); err != nil {
|
if err := this.dismiss(sociaty); err != nil {
|
||||||
@ -576,20 +576,18 @@ func (this *ModelSociaty) accuse(sociaty *pb.DBSociaty) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
ggd := this.moduleSociaty.configure.GetGlobalConf()
|
|
||||||
if ggd == nil {
|
globalCnf := this.moduleSociaty.globalConf
|
||||||
return errors.New("config not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
//会长离线时间
|
//会长离线时间
|
||||||
now := configure.Now().Unix()
|
now := configure.Now().Unix()
|
||||||
left := now - user.Offlinetime
|
left := now - user.Offlinetime
|
||||||
if left < int64(ggd.GuildInitiateImpeachmentTime*3600) || user.Offlinetime == 0 {
|
if left < int64(globalCnf.GuildInitiateImpeachmentTime*3600) || user.Offlinetime == 0 {
|
||||||
return errors.New("会长很称职,无需弹劾")
|
return errors.New("会长很称职,无需弹劾")
|
||||||
} else {
|
} else {
|
||||||
//更新会长的弹劾倒计时时间
|
//更新会长的弹劾倒计时时间
|
||||||
update := map[string]interface{}{
|
update := map[string]interface{}{
|
||||||
"accuseTime": utils.AddHour(int(ggd.GuildImpeachmentCountDown)).Unix(),
|
"accuseTime": utils.AddHour(int(globalCnf.GuildImpeachmentCountDown)).Unix(),
|
||||||
}
|
}
|
||||||
return this.updateSociaty(sociaty.Id, update)
|
return this.updateSociaty(sociaty.Id, update)
|
||||||
}
|
}
|
||||||
@ -599,10 +597,6 @@ func (this *ModelSociaty) accuse(sociaty *pb.DBSociaty) error {
|
|||||||
// srcMasterId 原会长ID
|
// srcMasterId 原会长ID
|
||||||
func (this *ModelSociaty) extendJob(srcMasterId string, sociaty *pb.DBSociaty) error {
|
func (this *ModelSociaty) extendJob(srcMasterId string, sociaty *pb.DBSociaty) error {
|
||||||
if sociaty.AccuseTime != 0 {
|
if sociaty.AccuseTime != 0 {
|
||||||
ggd := this.moduleSociaty.configure.GetGlobalConf()
|
|
||||||
if ggd == nil {
|
|
||||||
return errors.New("config not found")
|
|
||||||
}
|
|
||||||
//终止弹劾
|
//终止弹劾
|
||||||
now := configure.Now().Unix()
|
now := configure.Now().Unix()
|
||||||
if now < sociaty.AccuseTime {
|
if now < sociaty.AccuseTime {
|
||||||
|
@ -37,15 +37,11 @@ func (this *ModelSociatyTask) initSociatyTask(uid, sociatyId string) error {
|
|||||||
var taskList []*pb.SociatyTask
|
var taskList []*pb.SociatyTask
|
||||||
|
|
||||||
list := ggt.GetDataList()
|
list := ggt.GetDataList()
|
||||||
ggd := this.moduleSociaty.configure.GetGlobalConf()
|
globalConf := this.moduleSociaty.globalConf
|
||||||
if ggd == nil {
|
|
||||||
return errors.New("config not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 大于4条配置
|
// 大于4条配置
|
||||||
if len(list) > int(ggd.GuildTaskNum) {
|
if len(list) > int(globalConf.GuildTaskNum) {
|
||||||
//随机4条任务
|
//随机4条任务
|
||||||
randInts := utils.RandomNumbers(0, len(list)-1, int(ggd.GuildTaskNum))
|
randInts := utils.RandomNumbers(0, len(list)-1, int(globalConf.GuildTaskNum))
|
||||||
for _, v := range randInts {
|
for _, v := range randInts {
|
||||||
taskList = append(taskList, &pb.SociatyTask{
|
taskList = append(taskList, &pb.SociatyTask{
|
||||||
TaskId: list[v].TypeId,
|
TaskId: list[v].TypeId,
|
||||||
|
@ -5,6 +5,7 @@ package sociaty
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/base"
|
"go_dreamfactory/lego/base"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
@ -12,6 +13,7 @@ import (
|
|||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ comm.ISociaty = (*Sociaty)(nil)
|
var _ comm.ISociaty = (*Sociaty)(nil)
|
||||||
@ -24,6 +26,7 @@ type Sociaty struct {
|
|||||||
modelSociatyTask *ModelSociatyTask
|
modelSociatyTask *ModelSociatyTask
|
||||||
modelSociatyLog *ModelSociatyLog
|
modelSociatyLog *ModelSociatyLog
|
||||||
configure *configureComp
|
configure *configureComp
|
||||||
|
globalConf *cfg.GameGlobalData
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewModule() core.IModule {
|
func NewModule() core.IModule {
|
||||||
@ -52,14 +55,17 @@ func (this *Sociaty) OnInstallComp() {
|
|||||||
func (this *Sociaty) Start() (err error) {
|
func (this *Sociaty) Start() (err error) {
|
||||||
err = this.ModuleBase.Start()
|
err = this.ModuleBase.Start()
|
||||||
this.service.RegisterFunctionName(string(comm.Rpc_ModuleSociaty), this.RpcGetSociaty)
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 会长弹劾处理
|
// 会长弹劾处理
|
||||||
// Deprecated
|
// Deprecated
|
||||||
func (this *Sociaty) ProcessAccuse(uid, sociatyId string) {
|
func (this *Sociaty) ProcessAccuse(uid, sociatyId string) {
|
||||||
ggd := this.configure.GetGlobalConf()
|
t := this.globalConf.GuildImpeachmentCountDown
|
||||||
t := ggd.GuildImpeachmentCountDown
|
|
||||||
if t == 0 {
|
if t == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -43,12 +43,6 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
gConf := this.module.configure.GetGlobalConf()
|
|
||||||
if gConf == nil {
|
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
update := map[string]interface{}{
|
update := map[string]interface{}{
|
||||||
"name": req.NickName, //设置昵称
|
"name": req.NickName, //设置昵称
|
||||||
"created": true, //创角标识
|
"created": true, //创角标识
|
||||||
@ -56,10 +50,11 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
|
|||||||
"gender": req.Gender, //设置性别
|
"gender": req.Gender, //设置性别
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globalConf := this.module.globalConf
|
||||||
if req.Gender == 0 {
|
if req.Gender == 0 {
|
||||||
update["avatar"] = gConf.BoyHeadPortrait
|
update["avatar"] = globalConf.BoyHeadPortrait
|
||||||
} else if req.Gender == 1 {
|
} else if req.Gender == 1 {
|
||||||
update["avatar"] = gConf.GirlHeadPortrait
|
update["avatar"] = globalConf.GirlHeadPortrait
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := this.module.modelUser.Change(session.GetUserId(), update); err != nil {
|
if err := this.module.modelUser.Change(session.GetUserId(), update); err != nil {
|
||||||
|
@ -35,11 +35,11 @@ func (this *apiComp) Modifyname(session comm.IUserSession, req *pb.UserModifynam
|
|||||||
|
|
||||||
//校验名称修改次数
|
//校验名称修改次数
|
||||||
if expand.ModifynameCount <= 0 {
|
if expand.ModifynameCount <= 0 {
|
||||||
code = this.module.ConsumeRes(session, this.module.configure.GetGlobalConf().HeroName, true)
|
code = this.module.ConsumeRes(session, this.module.globalConf.HeroName, true)
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.module.Infof("修改昵称 uid:%v 消耗:%v code:%v", session.GetUserId(), this.module.configure.GetGlobalConf().HeroName, code)
|
this.module.Infof("修改昵称 uid:%v 消耗:%v code:%v", session.GetUserId(), this.module.globalConf.HeroName, code)
|
||||||
}
|
}
|
||||||
|
|
||||||
//修改名称次数
|
//修改名称次数
|
||||||
|
@ -61,7 +61,7 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.UserSignReq) (code
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if bReward {
|
if bReward {
|
||||||
this.module.DispenseRes(session, this.module.configure.GetGlobalConf().UnifiedReward, true) // 发放通用奖励
|
this.module.DispenseRes(session, this.module.globalConf.UnifiedReward, true) // 发放通用奖励
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), "sign", &pb.UserSignResp{
|
session.SendMsg(string(this.module.GetType()), "sign", &pb.UserSignResp{
|
||||||
|
@ -34,7 +34,7 @@ func (this *ModelSession) Start() (err error) {
|
|||||||
//获取用户
|
//获取用户
|
||||||
func (this *ModelSession) getUserSession(uid string) (user *pb.CacheUser) {
|
func (this *ModelSession) getUserSession(uid string) (user *pb.CacheUser) {
|
||||||
user = &pb.CacheUser{}
|
user = &pb.CacheUser{}
|
||||||
if err := this.GetListObj(comm.RDS_SESSION, uid, user); err != nil {
|
if err := this.GetListObj(comm.RDS_EMPTY, uid, user); err != nil {
|
||||||
if err != mongo.ErrNoDocuments {
|
if err != mongo.ErrNoDocuments {
|
||||||
this.module.Errorln(err)
|
this.module.Errorln(err)
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ func (this *ModelSession) getUserSession(uid string) (user *pb.CacheUser) {
|
|||||||
|
|
||||||
//设置用户session
|
//设置用户session
|
||||||
func (this *ModelSession) addUserSession(uid string, session comm.IUserSession) (err error) {
|
func (this *ModelSession) addUserSession(uid string, session comm.IUserSession) (err error) {
|
||||||
if err = this.AddList(comm.RDS_SESSION, uid, map[string]interface{}{
|
if err = this.AddList(comm.RDS_EMPTY, uid, map[string]interface{}{
|
||||||
"uid": uid,
|
"uid": uid,
|
||||||
"sessionId": session.GetSessionId(),
|
"sessionId": session.GetSessionId(),
|
||||||
"serviceTag": session.GetServiecTag(),
|
"serviceTag": session.GetServiecTag(),
|
||||||
@ -60,7 +60,7 @@ func (this *ModelSession) addUserSession(uid string, session comm.IUserSession)
|
|||||||
|
|
||||||
// 启动时清理session
|
// 启动时清理session
|
||||||
func (this *ModelSession) clean(key string) {
|
func (this *ModelSession) clean(key string) {
|
||||||
keys, err := this.Redis.Keys(fmt.Sprintf("session:%s-%s_*", comm.RDS_SESSION, key))
|
keys, err := this.Redis.Keys(fmt.Sprintf("session:%s-%s_*", comm.RDS_EMPTY, key))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("redis keys err:%v", err)
|
log.Errorf("redis keys err:%v", err)
|
||||||
return
|
return
|
||||||
|
@ -114,7 +114,7 @@ func (this *ModelSign) checkResetSignData(session comm.IUserSession) (code pb.Er
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if bReward {
|
if bReward {
|
||||||
this.module.DispenseRes(session, this.module.configure.GetGlobalConf().UnifiedReward, true) // 发放通用奖励
|
this.module.DispenseRes(session, this.module.globalConf.UnifiedReward, true) // 发放通用奖励
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), "sign", &pb.UserSignResp{
|
session.SendMsg(string(this.module.GetType()), "sign", &pb.UserSignResp{
|
||||||
|
@ -18,6 +18,8 @@ import (
|
|||||||
"go_dreamfactory/lego/sys/event"
|
"go_dreamfactory/lego/sys/event"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
|
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
@ -50,6 +52,7 @@ type User struct {
|
|||||||
modelExpand *ModelExpand
|
modelExpand *ModelExpand
|
||||||
service base.IRPCXService
|
service base.IRPCXService
|
||||||
configure *configureComp
|
configure *configureComp
|
||||||
|
globalConf *cfg.GameGlobalData
|
||||||
modelSign *ModelSign // 签到
|
modelSign *ModelSign // 签到
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +73,10 @@ func (this *User) Start() (err error) {
|
|||||||
this.service.RegisterFunctionName(Rpc_GetCrossUser, this.RpcGetCrossUser)
|
this.service.RegisterFunctionName(Rpc_GetCrossUser, this.RpcGetCrossUser)
|
||||||
this.service.RegisterFunctionName(Rpc_GetCrossUserSession, this.RpcGetCrossUserSession)
|
this.service.RegisterFunctionName(Rpc_GetCrossUserSession, this.RpcGetCrossUserSession)
|
||||||
this.service.RegisterFunctionName(Rpc_QueryUser, this.RpcQueryUser)
|
this.service.RegisterFunctionName(Rpc_QueryUser, this.RpcQueryUser)
|
||||||
|
this.globalConf = this.configure.GetGlobalConf()
|
||||||
|
if this.globalConf == nil {
|
||||||
|
err = errors.New("global config not found")
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,9 +141,9 @@ func (this *User) CleanSession(session comm.IUserSession) {
|
|||||||
if !this.IsCross() {
|
if !this.IsCross() {
|
||||||
this.modelUser.updateOfflineTime(session.GetUserId())
|
this.modelUser.updateOfflineTime(session.GetUserId())
|
||||||
}
|
}
|
||||||
sId := fmt.Sprintf("%s-%s", comm.RDS_SESSION, session.GetUserId())
|
sId := fmt.Sprintf("%s-%s", comm.RDS_EMPTY, session.GetUserId())
|
||||||
this.modelSession.Del(sId, db.SetDBMgoLog(false))
|
this.modelSession.Del(sId, db.SetDBMgoLog(false))
|
||||||
this.modelSession.DelListlds(comm.RDS_SESSION, session.GetUserId())
|
this.modelSession.DelListlds(comm.RDS_EMPTY, session.GetUserId())
|
||||||
this.modelUser.DelByUId(session.GetUserId(), db.SetDBMgoLog(false))
|
this.modelUser.DelByUId(session.GetUserId(), db.SetDBMgoLog(false))
|
||||||
this.modelExpand.DelByUId(session.GetUserId(), db.SetDBMgoLog(false))
|
this.modelExpand.DelByUId(session.GetUserId(), db.SetDBMgoLog(false))
|
||||||
this.modelSetting.DelByUId(session.GetUserId(), db.SetDBMgoLog(false))
|
this.modelSetting.DelByUId(session.GetUserId(), db.SetDBMgoLog(false))
|
||||||
@ -145,7 +152,7 @@ func (this *User) CleanSession(session comm.IUserSession) {
|
|||||||
// 在线玩家列表
|
// 在线玩家列表
|
||||||
func (this *User) UserOnlineList() ([]*pb.CacheUser, error) {
|
func (this *User) UserOnlineList() ([]*pb.CacheUser, error) {
|
||||||
var cache []*pb.CacheUser
|
var cache []*pb.CacheUser
|
||||||
if err := this.modelSession.GetList(comm.RDS_SESSION, &cache); err != nil {
|
if err := this.modelSession.GetList(comm.RDS_EMPTY, &cache); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return cache, nil
|
return cache, nil
|
||||||
@ -521,7 +528,7 @@ func (this *User) RpcGetAllOnlineUser(ctx context.Context, args *pb.EmptyReq, re
|
|||||||
}
|
}
|
||||||
model := db.NewDBModel(comm.TableSession, 0, conn)
|
model := db.NewDBModel(comm.TableSession, 0, conn)
|
||||||
var cache []*pb.CacheUser
|
var cache []*pb.CacheUser
|
||||||
if err := model.GetList(comm.RDS_SESSION, &cache); err != nil {
|
if err := model.GetList(comm.RDS_EMPTY, &cache); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
reply.Users = cache
|
reply.Users = cache
|
||||||
@ -538,7 +545,7 @@ func (this *User) RpcGetCrossUserSession(ctx context.Context, req *pb.UIdReq, re
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
model := db.NewDBModel(comm.TableSession, 0, conn)
|
model := db.NewDBModel(comm.TableSession, 0, conn)
|
||||||
if err := model.GetListObj(comm.RDS_SESSION, req.Uid, reply); err != nil {
|
if err := model.GetListObj(comm.RDS_EMPTY, req.Uid, reply); err != nil {
|
||||||
if err != mongo.ErrNoDocuments {
|
if err != mongo.ErrNoDocuments {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ func (this *SCompGateRoute) NoticeUserLogin(ctx context.Context, args *pb.Notice
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
model := db.NewDBModel(comm.TableSession, 0, conn)
|
model := db.NewDBModel(comm.TableSession, 0, conn)
|
||||||
model.AddList(comm.RDS_SESSION, args.UserId, map[string]interface{}{
|
model.AddList(comm.RDS_EMPTY, args.UserId, map[string]interface{}{
|
||||||
"uid": args.UserId,
|
"uid": args.UserId,
|
||||||
"sessionId": args.UserSessionId,
|
"sessionId": args.UserSessionId,
|
||||||
"serviceTag": args.ServiceTag,
|
"serviceTag": args.ServiceTag,
|
||||||
|
Loading…
Reference in New Issue
Block a user