This commit is contained in:
wh_zcy 2023-05-29 20:10:49 +08:00
commit 85110dc808
23 changed files with 130 additions and 63 deletions

View File

@ -25,25 +25,32 @@ func PuttaskParam(r *TaskParam) {
var buriedParamPool = &sync.Pool{
New: func() interface{} {
return &TaskParam{}
return &BuriedParam{
Value: 0,
Filter: make([]int32, 0),
}
},
}
//普通任务
func GetBuriedParam(t TaskType, vaule int32, p ...int32) *BuriedParam {
task := taskParamPool.Get().(*BuriedParam)
task := buriedParamPool.Get().(*BuriedParam)
task.Btype = t
task.Value = vaule
task.Filter = append(task.Filter, p...)
if len(p) > 0 {
task.Filter = append(task.Filter, p...)
}
return task
}
//统计型任务
func GetBuriedParam2(t TaskType, statistics string, p ...int32) *BuriedParam {
task := taskParamPool.Get().(*BuriedParam)
task := buriedParamPool.Get().(*BuriedParam)
task.Btype = t
task.Statistics = statistics
task.Filter = append(task.Filter, p...)
if len(p) > 0 {
task.Filter = append(task.Filter, p...)
}
return task
}
@ -51,5 +58,5 @@ func PutburiedParam(r *BuriedParam) {
r.Filter = r.Filter[:0]
r.Value = 0
r.Statistics = ""
taskParamPool.Put(r)
buriedParamPool.Put(r)
}

View File

@ -27,6 +27,7 @@ type configureComp struct {
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.MCompConfigure.Init(service, module, comp, options)
this.module = module.(*Buried)
this.LoadConfigure(game_buriedtype, cfg.NewGameBuriedType)
this.LoadConfigure(game_buriedcondi, cfg.NewGameBuriedCondi)
configure.RegisterConfigure(game_buriedcondi, cfg.NewGameBuriedCondi, this.updateconfigure)
return

View File

@ -33,7 +33,7 @@ const (
//判断埋点数据的有效性
func checkburied(buried *comm.BuriedParam, bconf *cfg.GameBuriedTypeData, conf *cfg.GameBuriedCondiData) (efficient bool) {
if len(buried.Filter) == len(conf.Filter) {
if len(buried.Filter) != len(conf.Filter) {
log.Error("校验埋点错误!", log.Field{Key: "buried", Value: buried}, log.Field{Key: "conf", Value: conf})
return
}

View File

@ -55,6 +55,7 @@ func (this *buriedModel) getUserBurieds(uid string) (results map[int32]*pb.DBBur
this.module.Errorln(err)
return
}
results = make(map[int32]*pb.DBBuried)
for _, v := range temp {
results[v.Btype] = v
}

View File

@ -233,14 +233,14 @@ func (this *Buried) TriggerBuried(uid string, burieds ...*comm.BuriedParam) {
this.Error("未找到目标埋点类型配置", log.Field{Key: "type", Value: buried.Btype})
continue
}
if bdata, ok = bdatas[bdata.Btype]; !ok {
bdatas[bdata.Btype] = &pb.DBBuried{
if bdata, ok = bdatas[int32(buried.Btype)]; !ok {
bdatas[int32(buried.Btype)] = &pb.DBBuried{
Id: primitive.NewObjectID().Hex(),
Uid: uid,
Btype: bdata.Btype,
Btype: int32(buried.Btype),
Items: make(map[int32]*pb.DBBuriedItem),
}
bdata = bdatas[bdata.Btype]
bdata = bdatas[int32(buried.Btype)]
}
for _, cond := range conds {
if cond.Rtype == rtype1 { //创号后入录
@ -265,6 +265,7 @@ func (this *Buried) TriggerBuried(uid string, burieds ...*comm.BuriedParam) {
//通知事件
if len(completeConIds) > 0 {
this.Debug("条件达成通知", log.Field{Key: "ConIds", Value: completeConIds})
event.TriggerEvent(comm.EventBuriedComplete, uid, completeConIds)
}
}

View File

@ -42,6 +42,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HeroBuyReq) (code pb
if conf, err = this.module.configure.GetShopItemsConfigureByGroups(req.BuyType, udata); err != nil { // 找配置
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}

View File

@ -266,9 +266,10 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
}
for index, star := range szStar {
_data := this.module.configure.GetPollByType(strPool[index])
if _data == nil {
_data, err := this.module.configure.GetPollByType(strPool[index])
if err != nil {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
sz := make([]int32, 0)

View File

@ -77,9 +77,10 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
for index, skill := range _hero.NormalSkill {
skillMaxLv := this.module.configure.GetHeroSkillMaxLvConfig(uint32(skill.SkillID))
if skill.SkillLv < skillMaxLv { // 找到没有满级的技能id
skillData := this.module.configure.GetHeroSkillUpConfig(skill.SkillID)
if skillData == nil {
skillData, err := this.module.configure.GetHeroSkillUpConfig(skill.SkillID)
if err != nil {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
sz = append(sz, skillData.Probability[skill.SkillLv])

View File

@ -58,9 +58,10 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe
}
}
talentConf := this.module.configure.GetHeroTalent(req.TalentID)
if talentConf == nil {
talentConf, err := this.module.configure.GetHeroTalent(req.TalentID)
if err != nil {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
// 校验

View File

@ -42,9 +42,12 @@ func (this *apiComp) TalentReset(session comm.IUserSession, req *pb.HeroTalentRe
}
for k := range _talent.Talent {
if conf := this.module.configure.GetHeroTalent(k); conf != nil {
if conf, err := this.module.configure.GetHeroTalent(k); err == nil {
talentPoint += conf.Point // 获取当前英雄的天赋点数
} else {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
}
if t := this.module.configure.GetHeroTalentBoxItem(_talent.HeroId); t != "" {

View File

@ -172,8 +172,12 @@ func (this *configureComp) SetHeroDrawConfig() {
return
}
func (this *configureComp) GetPollByType(poosType string) map[int32][]*cfg.GameDrawCardData {
return this.drawCardCfg[poosType]
func (this *configureComp) GetPollByType(poosType string) (conf map[int32][]*cfg.GameDrawCardData, err error) {
var ok bool
if conf, ok = this.drawCardCfg[poosType]; !ok {
err = comm.NewNotFoundConfErr("hero", hero_drawcard, poosType)
}
return
}
func (this *configureComp) GetHeroExp(hid string) (conf *cfg.GameHeroExpData, err error) {
@ -248,15 +252,19 @@ func (this *configureComp) GetHeroLvgrow(heroId string) *cfg.GameHeroLevelgrowDa
}
// 获取英雄技能升级相关信息
func (this *configureComp) GetHeroSkillUpConfig(skillid int32) (data *cfg.GameHeroSkillLevelData) {
if v, err := this.GetConfigure(hero_skillup); err == nil {
if conf, ok := v.(*cfg.GameHeroSkillLevel); ok {
data = conf.Get(skillid)
func (this *configureComp) GetHeroSkillUpConfig(skillid int32) (data *cfg.GameHeroSkillLevelData, err error) {
var (
v interface{}
)
if conf, ok := v.(*cfg.GameHeroSkillLevel); ok {
if v, err = this.GetConfigure(hero_skillup); err == nil {
if data = conf.Get(skillid); data == nil {
err = comm.NewNotFoundConfErr("hero", hero_skillup, skillid)
}
return
}
}
this.module.Errorf("cfg.GetHeroSkillUpConfig :id = %d", skillid)
err = comm.NewNotFoundConfErr("hero", hero_skillup, skillid)
return
}
@ -293,15 +301,20 @@ func (this *configureComp) GetHeroFucionConfig(cid string) (data *cfg.GameHerofu
return
}
func (this *configureComp) GetHeroTalent(id int32) (data *cfg.GameHeroTalentData) {
if v, err := this.GetConfigure(hero_talent); err == nil {
func (this *configureComp) GetHeroTalent(id int32) (data *cfg.GameHeroTalentData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(hero_talent); err == nil {
if configure, ok := v.(*cfg.GameHeroTalent); ok {
data = configure.Get(id)
if data = configure.Get(id); data == nil {
err = comm.NewNotFoundConfErr("hero", hero_talent, id)
}
return
}
}
this.module.Errorf("cfg.GameHeroTalentData GetHeroTalent:id = %d", id)
return nil
err = comm.NewNotFoundConfErr("hero", hero_talent, id)
return
}
// 天赋指定消耗
@ -341,6 +354,7 @@ func (this *configureComp) GetShopItemsConfigureByGroups(groupid int32, user *pb
)
if v, err = this.GetConfigure(game_shopitem); err != nil {
this.module.Errorf("err:%v", err)
err = comm.NewNotFoundConfErr("hero", game_shopitem, groupid)
return
} else {
table = v.(*cfg.GameShopitem)

View File

@ -814,7 +814,7 @@ func (this *ModelHero) resetTalentProperty(hero *pb.DBHero) {
for _, v := range rst {
if v.HeroId == hero.HeroID { // 找到对应的英雄
for k := range v.Talent {
if conf := this.module.configure.GetHeroTalent(k); conf != nil { //获取天赋树
if conf, _ := this.module.configure.GetHeroTalent(k); conf != nil { //获取天赋树
if conf.Hp != -1 {
attr[0] += conf.Hp
}

View File

@ -536,7 +536,7 @@ func (this *Hero) ContinuousRestriction(uid string, heroCid string, drawCount in
iMaxCOunt := conf.DrawCardContinuousRestrictionStar5
if drawCount-index <= iMaxCOunt { // 连续n次还获得该英雄 直接替换其他英雄
_data := this.configure.GetPollByType(pool)
_data, _ := this.configure.GetPollByType(pool)
if _data == nil {
return heroCid

View File

@ -181,9 +181,11 @@ func (this *ModelItemsComp) DeleteUserPack(uid string, itmes ...*pb.DB_UserItemD
}
}
} else {
if err = this.DelListlds(uid, gridIds); err != nil {
this.module.Errorf("err:%v", err)
return
if len(gridIds) > 0 {
if err = this.DelListlds(uid, gridIds); err != nil {
this.module.Errorf("err:%v", err)
return
}
}
}
return

View File

@ -33,9 +33,10 @@ func (this *apiComp) GetStoryReward(session comm.IUserSession, req *pb.LibraryGe
code = pb.ErrorCode_ReqParameterError
return
}
favorConf := this.module.configure.GetFavorability(_heroFetter.Heroid, 1) // 取1级的就可以
if favorConf == nil {
favorConf, err := this.module.configure.GetFavorability(_heroFetter.Heroid, 1) // 取1级的就可以
if err != nil {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
// 领取传记往事id

View File

@ -38,9 +38,10 @@ func (this *apiComp) LvReward(session comm.IUserSession, req *pb.LibraryLvReward
code = pb.ErrorCode_LibraryReward // 重复领奖
return
}
confData := this.module.configure.GetFavorability(_heroFetter.Heroid, req.Lv)
if confData == nil {
confData, err := this.module.configure.GetFavorability(_heroFetter.Heroid, req.Lv)
if err != nil {
code = pb.ErrorCode_ReqParameterError
data.Message = err.Error()
return
}

View File

@ -38,9 +38,10 @@ func (this *apiComp) FetterLvUp(session comm.IUserSession, req *pb.LibraryFetter
}
}
fetter.Fidlv += 1
conf := this.module.configure.GetFriendData(fetter.Fid, fetter.Fidlv)
if len(conf) == 0 {
conf, e := this.module.configure.GetFriendData(fetter.Fid, fetter.Fidlv)
if e != nil || len(conf) == 0 {
code = pb.ErrorCode_ConfigNoFound
data.Message = e.Error()
return
}

View File

@ -39,9 +39,10 @@ func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftRe
return
}
_exp := this.module.configure.GetFavorabilityExp(_heroObj.Heroid)
if len(_exp) == 0 {
_exp, err := this.module.configure.GetFavorabilityExp(_heroObj.Heroid)
if err != nil {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
maxLv = int32(len(_exp)) // 获取当前星级羁绊最大等级
@ -70,9 +71,10 @@ func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftRe
}
_heroObj.Givecount += req.Counts
// 校验是否是自己喜欢的食物
_c := this.module.configure.GetFavorability(_heroObj.Heroid, _heroObj.Favorlv)
if _c == nil {
_c, err := this.module.configure.GetFavorability(_heroObj.Heroid, _heroObj.Favorlv)
if err != nil {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
for _, v := range _c.LikesFood { // 喜欢的食物

View File

@ -2,6 +2,7 @@ package library
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
@ -62,9 +63,16 @@ func (this *configureComp) SetFavorability() {
}
}
func (this *configureComp) GetFavorability(hid string, lv int32) *cfg.GameFavorabilityData {
return this.favorability[hid+"-"+strconv.Itoa(int(lv))]
func (this *configureComp) GetFavorability(hid string, lv int32) (conf *cfg.GameFavorabilityData, err error) {
var (
ok bool
par interface{}
)
if conf, ok = this.favorability[hid+"-"+strconv.Itoa(int(lv))]; !ok {
par = fmt.Errorf("hid:%s,lv:%d", hid, lv)
err = comm.NewNotFoundConfErr("hero", game_favorability, par)
}
return
}
func (this *configureComp) SetFriendData() {
@ -90,8 +98,16 @@ func (this *configureComp) SetFriendData() {
}
// id:羁绊id lv 羁绊等级
func (this *configureComp) GetFriendData(id int32, lv int32) []*cfg.GameFriendsData {
return this.friend[int64(id)<<8+int64(lv)]
func (this *configureComp) GetFriendData(id int32, lv int32) (conf []*cfg.GameFriendsData, err error) {
var (
ok bool
par interface{}
)
if conf, ok = this.friend[int64(id)<<8+int64(lv)]; !ok {
par = fmt.Errorf("hid:%d,lv:%d", id, lv)
err = comm.NewNotFoundConfErr("hero", game_friends, par)
}
return
}
// 通过英雄获取当前英雄的所有羁绊ID
@ -116,7 +132,12 @@ func (this *configureComp) GetConfigure(name string) (v interface{}, err error)
return configure.GetConfigure(name)
}
func (this *configureComp) GetFavorabilityExp(hid string) []int32 {
return this.favorLvExp[hid]
func (this *configureComp) GetFavorabilityExp(hid string) (conf []int32, err error) {
var (
ok bool
)
if conf, ok = this.favorLvExp[hid]; !ok {
err = comm.NewNotFoundConfErr("hero", game_favorability, hid)
}
return
}

View File

@ -35,7 +35,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.MlineGetListReq)
}
}
if len(rsp.Data) == 0 { // 什么数据都没有 创建一条
if chapterConf := this.module.configure.GetFirstChapterIDByType(req.CType); chapterConf != nil { // 配置文件校验
if chapterConf, err := this.module.configure.GetFirstChapterIDByType(req.CType); err == nil { // 配置文件校验
if stageConf := this.module.configure.GetFirstStageIDByChapter(chapterConf.Id); stageConf != nil {
newData := &pb.DBMline{
Id: primitive.NewObjectID().Hex(),
@ -52,6 +52,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.MlineGetListReq)
}
} else {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
}

View File

@ -1,6 +1,7 @@
package mline
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/sys/configure"
@ -85,18 +86,21 @@ func (this *configureComp) GetPreMainChapter(stageId int32) (preStageID int32) {
}
return
}
func (this *configureComp) GetFirstChapterIDByType(iType int32) *cfg.GameMainChapterData {
if v, err := this.GetConfigure(game_mainchapter); err == nil {
func (this *configureComp) GetFirstChapterIDByType(iType int32) (conf *cfg.GameMainChapterData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_mainchapter); err == nil {
if configure, ok := v.(*cfg.GameMainChapter); ok {
for _, v := range configure.GetDataList() {
if v.ChapterType == iType {
return v
for _, conf = range configure.GetDataList() {
if conf.ChapterType == iType {
return
}
}
}
}
return nil
err = comm.NewNotFoundConfErr("mline", game_mainchapter, iType)
return
}
func (this *configureComp) GetFirstStageIDByChapter(chapterID int32) *cfg.GameMainStageData {

View File

@ -138,6 +138,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
for _, v := range shopconf.Shopitem {
if _items, err = this.module.configure.GetShopItemsConfigureByGroups(v, udata); err != nil || len(_items) == 0 {
code = pb.ErrorCode_SystemError
data.Message = err.Error()
return
}
items = append(items, randomGoods(_items))

View File

@ -2,6 +2,7 @@ package shop
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
@ -75,6 +76,7 @@ func (this *configureComp) GetShopItemsConfigureByGroups(groupid int32, user *pb
)
if v, err = this.GetConfigure(game_shopitem); err != nil {
this.module.Errorf("err:%v", err)
err = comm.NewNotFoundConfErr("hero", game_shopitem, groupid)
return
} else {
table = v.(*cfg.GameShopitem)