diff --git a/comm/const.go b/comm/const.go index 2a3a5d470..0a62e3026 100644 --- a/comm/const.go +++ b/comm/const.go @@ -350,6 +350,7 @@ const ( EventOpenCond core.Event_Key = "event_open_cond" //功能开放事件 EventBuriedComplete core.Event_Key = "event_buried_complete" //埋点系统条件完成事件批处理接口 接口样例 func(uid string,conids []int32) + EventFriendChange core.Event_Key = "event_friend_change" //加好友 ) const ( diff --git a/modules/battle/module.go b/modules/battle/module.go index 82e81d394..b13b196df 100644 --- a/modules/battle/module.go +++ b/modules/battle/module.go @@ -463,5 +463,10 @@ func (this *Battle) CheckBattleReport(session comm.IUserSession, report *pb.Batt // this.ModuleBuried.SendToRtask(session, comm.Rtype157, int32(report.Info.Ptype), v) go this.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype157, int32(report.Info.Ptype), v)) } - return nil, true + + if (report.WinSide == 1 && report.Info.RedCompId == session.GetUserId()) || (report.WinSide == 2 && report.Info.BlueCompId == session.GetUserId()) { + return nil, true + } else { + return nil, false + } } diff --git a/modules/friend/api_cross_agree.go b/modules/friend/api_cross_agree.go index a8c99520a..a29fdbb42 100644 --- a/modules/friend/api_cross_agree.go +++ b/modules/friend/api_cross_agree.go @@ -2,6 +2,7 @@ package friend import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/event" "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "go_dreamfactory/utils" @@ -150,6 +151,8 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.FriendAgreeReq) (e } return } + + event.TriggerEvent(comm.EventFriendChange, uid, len(self.FriendIds)) } // 拥有xx个好友 diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 1cae6e27c..3312c8014 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -36,7 +36,7 @@ func (this *ModelHero) Init(service core.IService, module core.IModule, comp cor return } -//初始化英雄 +// 初始化英雄 func (this *ModelHero) InitHero(uid string, heroCfgId string) *pb.DBHero { heroCfg, _ := this.module.configure.GetHeroConfig(heroCfgId) @@ -67,7 +67,7 @@ func (this *ModelHero) InitHero(uid string, heroCfgId string) *pb.DBHero { return newHero } -//初始化英雄技能 +// 初始化英雄技能 func (this *ModelHero) initHeroSkill(hero *pb.DBHero) []*pb.SkillData { heroCfg, _ := this.module.configure.GetHeroConfig(hero.HeroID) @@ -92,7 +92,7 @@ func (this *ModelHero) initHeroSkill(hero *pb.DBHero) []*pb.SkillData { return nil } -//创建一个指定的英雄 +// 创建一个指定的英雄 func (this *ModelHero) createSpecialHero(uid string, heroCfgId string) (hero *pb.DBHero, err error) { list := this.getHeroList(uid) for _, v := range list { @@ -132,7 +132,7 @@ func (this *ModelHero) CloneNewHero(uid string, hero *pb.DBHero) (newHero *pb.DB return } -//初始化可叠加的英雄 +// 初始化可叠加的英雄 func (this *ModelHero) initHeroOverlying(uid string, heroCfgId string, count int32) (hero *pb.DBHero, err error) { var ( model *db.DBModel @@ -158,7 +158,7 @@ func (this *ModelHero) initHeroOverlying(uid string, heroCfgId string, count int return } -//获取一个英雄(参数唯一objID) +// 获取一个英雄(参数唯一objID) func (this *ModelHero) getOneHero(uid, heroId string) *pb.DBHero { hero := &pb.DBHero{} err := this.GetListObj(uid, heroId, hero) @@ -168,7 +168,7 @@ func (this *ModelHero) getOneHero(uid, heroId string) *pb.DBHero { return hero } -//消耗英雄卡 +// 消耗英雄卡 func (this *ModelHero) consumeHeroCard(uid string, hero *pb.DBHero) (err error) { if hero == nil { @@ -183,7 +183,7 @@ func (this *ModelHero) consumeHeroCard(uid string, hero *pb.DBHero) (err error) return } -//获取玩家的英雄列表 +// 获取玩家的英雄列表 func (this *ModelHero) getHeroList(uid string) []*pb.DBHero { heroes := make([]*pb.DBHero, 0) err := this.GetList(uid, &heroes) @@ -276,11 +276,13 @@ func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipmen } for _, v := range hero.Suits { - if configure, err := this.module.configure.GetEquipsuit(v.Suitid); err != nil { - this.module.Errorln(err) - } else { - for k, v := range configure.SetBonuses { - addProperty[k] += v + if v.Effect { + if configure, err := this.module.configure.GetEquipsuit(v.Suitid); err != nil { + this.module.Errorln(err) + } else { + for k, v := range configure.SetBonuses { + addProperty[k] += v + } } } } @@ -300,7 +302,7 @@ func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipmen this.mergeAddProperty(hero.Uid, hero, addProperty, equipSkill) } -//设置装备 +// 设置装备 func (this *ModelHero) setEquipment(uid string, hero *pb.DBHero) (newHero *pb.DBHero, err error) { if len(hero.EquipID) == 0 { return @@ -316,7 +318,7 @@ func (this *ModelHero) setEquipment(uid string, hero *pb.DBHero) (newHero *pb.DB return } -//合并属性即属性值累加 (data 额外加的属性) +// 合并属性即属性值累加 (data 额外加的属性) func (this *ModelHero) mergeMainProperty(uid string, hero *pb.DBHero, data map[string]int32) (err error) { for k, v := range hero.Property { if v1, ok := data[k]; ok { @@ -332,7 +334,7 @@ func (this *ModelHero) mergeMainProperty(uid string, hero *pb.DBHero, data map[s return } -//合并附加属性 +// 合并附加属性 func (this *ModelHero) mergeAddProperty(uid string, hero *pb.DBHero, data map[string]int32, skills []*pb.SkillData) { hero.AddProperty = data @@ -373,8 +375,8 @@ func (this *ModelHero) StarHpAddition(star int32) (addValue float32) { return addValue } -//属性计算 基础属性 -//英雄基础属性 + 英雄等级基础属性 * 英雄成长系数 + 英雄星级对应等级属性 * 英雄品质系数 +// 属性计算 基础属性 +// 英雄基础属性 + 英雄等级基础属性 * 英雄成长系数 + 英雄星级对应等级属性 * 英雄品质系数 func (this *ModelHero) PropertyCompute(hero *pb.DBHero) { growCfg := this.module.configure.GetHeroLvgrow(hero.HeroID) heroCfg, _ := this.module.configure.GetHeroConfig(hero.HeroID) @@ -416,7 +418,7 @@ func (this *ModelHero) PropertyCompute(hero *pb.DBHero) { this.resetJuexingProperty(hero) } -//重新计算英雄属性 +// 重新计算英雄属性 func (this *ModelHero) ChangeHeroProperty(session comm.IUserSession, hero *pb.DBHero) (err error) { this.PropertyCompute(hero) //重新计算 property 的值 update := map[string]interface{}{ @@ -639,7 +641,7 @@ func (this *ModelHero) InitMonsterHero(heroCfgId string, star, lv int32) *pb.DBH return newHero } -//设置天赋属性 +// 设置天赋属性 func (this *ModelHero) setTalentProperty(hero *pb.DBHero, conf *cfg.GameHeroTalentData) { if conf == nil || hero == nil { return diff --git a/modules/practice/modelPandata.go b/modules/practice/modelPandata.go index e2acbc2e9..2dd348375 100644 --- a/modules/practice/modelPandata.go +++ b/modules/practice/modelPandata.go @@ -105,6 +105,7 @@ func (this *modelPandata) queryrooms(uids []string) (results []*pb.DBPracticeRoo // } go this.module.atlas.CheckActivatePandaAtlasCollect(v, "100001") newdata[v] = temp + results = append(results, temp) } if err = this.Adds(newdata); err != nil { this.module.Errorln(err) diff --git a/modules/shop/api_getlist.go b/modules/shop/api_getlist.go index 1f29807d0..1b6db3559 100644 --- a/modules/shop/api_getlist.go +++ b/modules/shop/api_getlist.go @@ -135,6 +135,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) } if int(shopData.RefreshnumgoldShop) < refresh { isrefresh = true + shopData.RefreshnumgoldShop++ } } if !isrefresh { diff --git a/modules/smithy/api_getCustomer.go b/modules/smithy/api_getCustomer.go index ee946da10..fae7e8f84 100644 --- a/modules/smithy/api_getCustomer.go +++ b/modules/smithy/api_getCustomer.go @@ -1,6 +1,7 @@ package smithy import ( + "errors" "go_dreamfactory/comm" "go_dreamfactory/pb" "go_dreamfactory/utils" @@ -24,14 +25,24 @@ func (this *apiComp) Customer(session comm.IUserSession, req *pb.SmithyCustomerR cus, err := this.module.modelTrade.getDBCustomer(session.GetUserId()) if err != nil { if err == mongo.ErrNoDocuments { - c, err := this.module.modelTrade.addCustomer(session.GetUserId(), customerCount) //3个顾客 + c, err := this.module.modelTrade.addCustomer(session.GetUserId(), customerCount) if err != nil { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_DBError, - Title: pb.ErrorCode_DBError.ToString(), - Message: err.Error(), + var customErr = new(comm.CustomError) + if errors.As(err, &customErr) { + errdata = &pb.ErrorData{ + Code: customErr.Code, + Title: customErr.Code.ToString(), + Message: err.Error(), + } + return + } else { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: err.Error(), + } + return } - return } cus = c } else { @@ -43,8 +54,7 @@ func (this *apiComp) Customer(session comm.IUserSession, req *pb.SmithyCustomerR return } } - - if utils.IsFirstTody(cus.LastRefreshTime) { + if utils.IsFirstTody(cus.LastRefreshTime) || (cus.Customers == nil || len(cus.Customers) == 0) { this.module.modelTrade.DelByUId(session.GetUserId()) c, err := this.module.modelTrade.addCustomer(session.GetUserId(), customerCount) if err != nil { diff --git a/modules/smithy/api_trade.go b/modules/smithy/api_trade.go index 398f1c4e7..fcf0474ab 100644 --- a/modules/smithy/api_trade.go +++ b/modules/smithy/api_trade.go @@ -31,20 +31,15 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.SmithySellReq) (err if err != nil { var customErr = new(comm.CustomError) if errors.As(err, &customErr) { - errdata = &pb.ErrorData{ - Code: customErr.Code, - Title: customErr.Code.ToString(), - Message: err.Error(), - } + this.module.Debug(customErr.Code.String()) } else { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } + return } - - return } conf, err := this.module.configure.GetSmithyCustomerConf(req.CustomerId) diff --git a/modules/smithy/model_trade.go b/modules/smithy/model_trade.go index 82c3fe978..74dd50a81 100644 --- a/modules/smithy/model_trade.go +++ b/modules/smithy/model_trade.go @@ -93,12 +93,22 @@ func (s *modelTrade) addCustomer(uid string, num int32) (*pb.DBCustomer, error) Total: num, LastRefreshTime: configure.Now().Unix(), } + for i := 0; i < int(num); i++ { - customer.Customers = append(customer.Customers, &pb.CustomerInfo{ - CustomerId: s.getCustomerRandom(), - SuitId: s.GetSuitRandom(uid), - EquipCount: s.module.modelStove.StoveSkillBuyEquip(uid), - }) + randCustomerId := s.getCustomerRandom() + conf, err := s.module.configure.GetSmithyCustomerConf(randCustomerId) + if err != nil { + return nil, comm.NewCustomError(pb.ErrorCode_ConfigNoFound) + } + suitId := s.GetSuitRandom(uid, conf.CustomerType) + if suitId != 0 { + customer.Customers = append(customer.Customers, &pb.CustomerInfo{ + CustomerId: randCustomerId, + SuitId: suitId, + EquipCount: s.module.modelStove.StoveSkillBuyEquip(uid), + }) + } + } if err := s.Add(uid, customer); err != nil { s.module.Errorln(err) @@ -139,12 +149,20 @@ func (s *modelTrade) updateCustomer(uid string, customerId int32) (*pb.DBCustome if left < 0 { return nil, comm.NewCustomError(pb.ErrorCode_SmithyCustomerLimit) } + randCustomerId := s.getCustomerRandom() + conf, err := s.module.configure.GetSmithyCustomerConf(randCustomerId) + if err != nil { + return nil, comm.NewCustomError(pb.ErrorCode_ConfigNoFound) + } + suiteId := s.GetSuitRandom(uid, conf.CustomerType) + if suiteId != 0 { + cus.Customers = append(cus.Customers, &pb.CustomerInfo{ + CustomerId: randCustomerId, + SuitId: suiteId, + EquipCount: s.module.modelStove.StoveSkillBuyEquip(uid), + }) + } - cus.Customers = append(cus.Customers, &pb.CustomerInfo{ - CustomerId: s.getCustomerRandom(), - SuitId: s.GetSuitRandom(uid), - EquipCount: s.module.modelStove.StoveSkillBuyEquip(uid), - }) cus.LastRefreshTime = configure.Now().Unix() update := map[string]interface{}{ "customers": cus.Customers, @@ -159,7 +177,7 @@ func (s *modelTrade) updateCustomer(uid string, customerId int32) (*pb.DBCustome } // 返回概率下的套装 -func (s *modelTrade) GetSuitRandom(uid string) (suiteId int32) { +func (s *modelTrade) GetSuitRandom(uid string, ctype int32) (suiteId int32) { //获取玩家所有解锁套装 uex, err := s.module.ModuleUser.GetUserExpand(uid) if err != nil { @@ -187,7 +205,14 @@ func (s *modelTrade) GetSuitRandom(uid string) (suiteId int32) { }) } - merge := append(unlockSuiteItems, ownerSuiteItems...) + var merge []*WeightItem + + if ctype == 1 { + merge = append(unlockSuiteItems, ownerSuiteItems...) + } else if ctype == 2 { + merge = unlockSuiteItems + } + // 设置权重 wr := newWeightedRandom(merge) if c := wr.pick(); c != nil { diff --git a/modules/worldtask/api_battlefinish.go b/modules/worldtask/api_battlefinish.go index 0f351669b..bb7e1a2a9 100644 --- a/modules/worldtask/api_battlefinish.go +++ b/modules/worldtask/api_battlefinish.go @@ -90,6 +90,17 @@ func (this *apiComp) Battlefinish(session comm.IUserSession, req *pb.WorldtaskBa if errdata, isWin = ibattle.CheckBattleReport(session, req.Report); errdata == nil { if isWin { if battleConf, ok := battleConf.GetDataMap()[req.BattleConfId]; ok { + + if battleConf.Carexe > 0 { + if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { + for _, v := range req.Report.Info.Redflist[0].Team { + if !v.Ishelp { // 助战英雄不加经验 + this.module.ModuleHero.AddHeroExp(session, v.Oid, battleConf.Carexe) + } + } + } + } + if errdata = this.module.DispenseRes(session, []*cfg.Gameatn{battleConf.Playexp}, true); errdata != nil { this.module.Error("世界任务战斗玩家经验结算", log.Field{Key: "uid", Value: uid}, @@ -114,6 +125,7 @@ func (this *apiComp) Battlefinish(session comm.IUserSession, req *pb.WorldtaskBa //判断是否配置了通知module if len(taskConf.Module) == 0 { + // 发奖 // if errdata = this.module.DispenseRes(session, taskConf.Reword, true); errdata != nil { // this.module.Error("资源发放",