This commit is contained in:
meixiongfeng 2023-06-30 10:49:03 +08:00
commit dde670cbab
10 changed files with 102 additions and 47 deletions

View File

@ -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 (

View File

@ -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))
}
if (report.WinSide == 1 && report.Info.RedCompId == session.GetUserId()) || (report.WinSide == 2 && report.Info.BlueCompId == session.GetUserId()) {
return nil, true
} else {
return nil, false
}
}

View File

@ -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个好友

View File

@ -276,6 +276,7 @@ func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipmen
}
for _, v := range hero.Suits {
if v.Effect {
if configure, err := this.module.configure.GetEquipsuit(v.Suitid); err != nil {
this.module.Errorln(err)
} else {
@ -284,6 +285,7 @@ func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipmen
}
}
}
}
for k, v := range addProperty {
switch k {

View File

@ -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)

View File

@ -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 {

View File

@ -1,6 +1,7 @@
package smithy
import (
"errors"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/utils"
@ -24,8 +25,17 @@ 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 {
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(),
@ -33,6 +43,7 @@ func (this *apiComp) Customer(session comm.IUserSession, req *pb.SmithyCustomerR
}
return
}
}
cus = c
} else {
errdata = &pb.ErrorData{
@ -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 {

View File

@ -31,21 +31,16 @@ 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
}
}
conf, err := this.module.configure.GetSmithyCustomerConf(req.CustomerId)
if err != nil {

View File

@ -93,13 +93,23 @@ func (s *modelTrade) addCustomer(uid string, num int32) (*pb.DBCustomer, error)
Total: num,
LastRefreshTime: configure.Now().Unix(),
}
for i := 0; i < int(num); i++ {
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: s.getCustomerRandom(),
SuitId: s.GetSuitRandom(uid),
CustomerId: randCustomerId,
SuitId: suitId,
EquipCount: s.module.modelStove.StoveSkillBuyEquip(uid),
})
}
}
if err := s.Add(uid, customer); err != nil {
s.module.Errorln(err)
return nil, 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: s.getCustomerRandom(),
SuitId: s.GetSuitRandom(uid),
CustomerId: randCustomerId,
SuitId: suiteId,
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 {

View File

@ -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("资源发放",