diff --git a/comm/imodule.go b/comm/imodule.go index 63d636a6e..fabdb5fcb 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -290,6 +290,8 @@ type ( AddVipData(session IUserSession, oldVip, newVip int32) // 查询所有特权 key 对应comm.PrivilegeType1类型 CheckAllPrivilege(session IUserSession) map[int32]*pb.PrivilegeList + // 通过特权类型获取特权对应的增加数量 + GetCountByPrivilegeId(uid string, pId int32) (count int32) } //武馆 IMartialhall interface { diff --git a/modules/gourmet/module.go b/modules/gourmet/module.go index 86418be02..96459e2da 100644 --- a/modules/gourmet/module.go +++ b/modules/gourmet/module.go @@ -70,15 +70,11 @@ func (this *Gourmet) Reddot(session comm.IUserSession, rid ...comm.ReddotType) ( } func (this *Gourmet) CheckPoint20(uid string) bool { - cfgCom := this.configure.GetGlobalConf() // 获取总的下单时长 - if cfgCom == nil { - return false - } _gourmet, err := this.modelGourmet.getGourmetList(uid) if err != nil { return false } - if cfgCom.Gourmet < _gourmet.OrderCostTime { // 大于总时长是不允许的 + if _gourmet.OrderCostTime > 0 { return false } return true diff --git a/modules/hunting/api_buy.go b/modules/hunting/api_buy.go index 24f4706d2..f1ec5e14e 100644 --- a/modules/hunting/api_buy.go +++ b/modules/hunting/api_buy.go @@ -88,8 +88,8 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HuntingBuyReq) (code list.RecoveryTime = 0 } addCount += req.Count - if amount+addCount > conf.VikingNum { - code = pb.ErrorCode_VikingBuyMaxCount + if amount+addCount > conf.HuntingNum { + code = pb.ErrorCode_HuntingBuyMaxCount return } mapData["recoveryTime"] = list.RecoveryTime diff --git a/modules/hunting/api_challenge.go b/modules/hunting/api_challenge.go index 27092fadf..cd959e961 100644 --- a/modules/hunting/api_challenge.go +++ b/modules/hunting/api_challenge.go @@ -44,10 +44,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.HuntingChallen code = pb.ErrorCode_HuntingNoChallengeCount return } - // if hunting.ChallengeCount > this.module.configure.GetGlobalConf().HuntingNum+hunting.BuyCount { - // code = pb.ErrorCode_HuntingMaxChallengeCount - // return - // } + cfgData := this.module.configure.GetHuntingBossConfigData(req.BossType, req.Difficulty) if cfgData == nil { code = pb.ErrorCode_ConfigNoFound diff --git a/modules/hunting/api_getlist.go b/modules/hunting/api_getlist.go index b7b4b733d..394709ff5 100644 --- a/modules/hunting/api_getlist.go +++ b/modules/hunting/api_getlist.go @@ -2,11 +2,14 @@ package hunting import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/mgo" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/utils" + "strconv" + "go.mongodb.org/mongo-driver/bson/primitive" "google.golang.org/protobuf/proto" ) @@ -28,7 +31,38 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.HuntingGetListRe } list, err := this.module.modelHunting.getHuntingList(session.GetUserId()) - if err != nil { + if mgo.MongodbNil == err { + result := &pb.DBHunting{ + Id: primitive.NewObjectID().Hex(), + Uid: session.GetUserId(), + Boss: make(map[int32]int32), + BossTime: make(map[string]int32), + } + _cfg := this.module.configure.GetHuntingBossTypeConfigData() + for k := range _cfg { + result.Boss[k] = 0 + str := strconv.Itoa(int(k)) + "_1" + result.BossTime[str] = 0 + } + + this.module.modelHunting.Add(session.GetUserId(), result) + conf := this.module.configure.GetGlobalConf() + if conf == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + iCont := conf.EnchantbossInitial + atn := conf.EnchantbossCos + if iCont > 0 { + + this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{ + A: atn.A, + T: atn.T, + N: iCont, + }}, true) + } + } else if err != nil { + code = pb.ErrorCode_DBError return } diff --git a/modules/hunting/model_hunting.go b/modules/hunting/model_hunting.go index e4ff20e75..b25d35e93 100644 --- a/modules/hunting/model_hunting.go +++ b/modules/hunting/model_hunting.go @@ -6,9 +6,7 @@ import ( "go_dreamfactory/lego/sys/mgo" "go_dreamfactory/modules" "go_dreamfactory/pb" - "strconv" - "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/x/bsonx" ) @@ -35,27 +33,11 @@ func (this *modelHunting) modifyHuntingDataByObjId(uid string, data map[string]i // 获取列表信息 func (this *modelHunting) getHuntingList(uid string) (result *pb.DBHunting, err error) { - result = &pb.DBHunting{ - Id: primitive.NewObjectID().Hex(), - Uid: uid, - Boss: make(map[int32]int32), - BossTime: make(map[string]int32), - } + result = &pb.DBHunting{} if err = this.Get(uid, result); err != nil && mgo.MongodbNil != err { - return } - if mgo.MongodbNil == err { - if len(result.Boss) == 0 { - _cfg := this.module.configure.GetHuntingBossTypeConfigData() - for k := range _cfg { - result.Boss[k] = 0 - str := strconv.Itoa(int(k)) + "_1" - result.BossTime[str] = 0 - } - } - this.Add(uid, result) - } + err = nil return result, err } diff --git a/modules/privilege/configure.go b/modules/privilege/configure.go index 1c3925791..9ffd4d210 100644 --- a/modules/privilege/configure.go +++ b/modules/privilege/configure.go @@ -3,8 +3,11 @@ package privilege import ( "fmt" "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" + "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" + "sync" ) const ( @@ -15,7 +18,9 @@ const ( ///背包配置管理组件 type configureComp struct { modules.MCompConfigure - module *Privilege + module *Privilege + hlock sync.RWMutex + _privilegeMap map[int32]map[int32]int32 } //组件初始化接口 @@ -24,6 +29,25 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp this.module = module.(*Privilege) this.LoadConfigure(game_privilegecard, cfg.NewGamePrivilegeCard) this.LoadConfigure(game_privilege, cfg.NewGamePrivilege) + this._privilegeMap = make(map[int32]map[int32]int32, 0) + configure.RegisterConfigure(game_privilege, cfg.NewGamePrivilege, func() { + if v, err := this.GetConfigure(game_privilege); err == nil { + if configure, ok := v.(*cfg.GamePrivilege); ok { + this.hlock.Lock() + defer this.hlock.Unlock() + for k, v := range configure.GetDataMap() { + if v1, ok := this._privilegeMap[v.PrivilegeType]; ok { + v1[k] = v.PrivilegeParameter + } else { + this._privilegeMap[v.PrivilegeType] = make(map[int32]int32) + } + } + return + } + } + log.Errorf("get game_pagoda conf err:%v", err) + return + }) return } @@ -59,3 +83,11 @@ func (this *configureComp) GetPrivilegeData(id int32) (result *cfg.GamePrivilege this.module.Errorf("GetPrivilegeData err, id:%d", id) return nil } + +func (this *configureComp) GetPrivilegeByType(iType int32) (result map[int32]int32) { + result = make(map[int32]int32) + if v, ok := this._privilegeMap[iType]; ok { + result = v + } + return result +} diff --git a/modules/privilege/module.go b/modules/privilege/module.go index 41152e5a3..3e66edb1d 100644 --- a/modules/privilege/module.go +++ b/modules/privilege/module.go @@ -401,3 +401,18 @@ func (this *Privilege) SendDailyPrivilegeMail(session comm.IUserSession, cId []i this.mail.SendMailByCid(session, comm.VipDaily, res) } } +func (this *Privilege) GetCountByPrivilegeId(uid string, pId int32) (count int32) { + vip, err := this.modelVip.getVipList(uid) + if err != nil { + return + } + if v, ok := vip.Privilege[pId]; ok { + data := this.configure.GetPrivilegeByType(pId) + for _, v1 := range v.PrivilegeID { + if c, ok1 := data[v1]; ok1 { + count += c + } + } + } + return +} diff --git a/modules/viking/api_buy.go b/modules/viking/api_buy.go index 560b8653f..0e591d915 100644 --- a/modules/viking/api_buy.go +++ b/modules/viking/api_buy.go @@ -69,7 +69,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code if list.RecoveryTime+int64(conf.VikingExpeditionRecoveryTime*60) <= configure.Now().Unix() { curCount++ list.RecoveryTime += int64(conf.VikingExpeditionRecoveryTime * 60) - if curCount >= conf.HuntingNum { + if curCount >= conf.VikingNum { list.RecoveryTime = 0 break } diff --git a/modules/viking/api_getlist.go b/modules/viking/api_getlist.go index 3237ecc07..765cfed0c 100644 --- a/modules/viking/api_getlist.go +++ b/modules/viking/api_getlist.go @@ -63,7 +63,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq if list.RecoveryTime+int64(conf.VikingExpeditionRecoveryTime*60) <= configure.Now().Unix() { curCount++ list.RecoveryTime += int64(conf.VikingExpeditionRecoveryTime * 60) - if curCount >= conf.HuntingNum { + if curCount >= conf.VikingNum { list.RecoveryTime = 0 break }