This commit is contained in:
liwei1dao 2022-10-14 10:31:23 +08:00
commit 9ef6b5d085
4 changed files with 46 additions and 46 deletions

View File

@ -174,8 +174,8 @@ type (
IHeroFetter interface { IHeroFetter interface {
ModifyHeroFetterData(uid string, obj string, data map[string]interface{}) (code pb.ErrorCode) // 修改羁绊信息 ModifyHeroFetterData(uid string, obj string, data map[string]interface{}) (code pb.ErrorCode) // 修改羁绊信息
QueryHeroFetter(uid string) (data []*pb.DBHeroFetter) // 查询所有的羁绊信息 QueryHeroFetter(uid string) (data []*pb.DBHeroFetter) // 查询所有的羁绊信息
QueryOneHeroFetter(uid string, cid string) *pb.DBHeroFetter // 通过英雄配置id 查询羁绊信息 //QueryOneHeroFetter(uid string, cid string) *pb.DBHeroFetter // 通过英雄配置id 查询羁绊信息
AddHeroFetterData(uid string, heroConfId string) // 创建一条羁绊信息 AddHeroFetterData(session IUserSession, heroConfId string) (code pb.ErrorCode) // 创建一条羁绊信息
} }
//月子秘境 //月子秘境
IMoonFantasy interface { IMoonFantasy interface {

View File

@ -67,14 +67,9 @@ func (this *Hero) CreateHeroes(uid string, heroCfgId ...string) error {
func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string, num int32, bPush bool) (code pb.ErrorCode) { func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string, num int32, bPush bool) (code pb.ErrorCode) {
_hero, err := this.modelHero.createHeroOverlying(session.GetUserId(), heroCfgId, num) _hero, err := this.modelHero.createHeroOverlying(session.GetUserId(), heroCfgId, num)
if err == nil { if err == nil {
this.moduleFetter.AddHeroFetterData(session, heroCfgId)
go func(uid string, heroCfgId string) { // 携程处理 图鉴数据 go func(uid string, heroCfgId string) { // 携程处理 图鉴数据
_data := this.moduleFetter.QueryOneHeroFetter(uid, heroCfgId) // 查询获得英雄是否存在羁绊信息
this.Debugf("%v", _data)
if _data == nil {
this.moduleFetter.AddHeroFetterData(uid, heroCfgId) // 创建一个新的羁绊数据
}
if result, err1 := this.ModuleUser.GetUserExpand(uid); err1 == nil { if result, err1 := this.ModuleUser.GetUserExpand(uid); err1 == nil {
initUpdate := map[string]interface{}{} initUpdate := map[string]interface{}{}
sz := result.GetTujian() sz := result.GetTujian()
@ -262,7 +257,9 @@ func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string]
this.ModuleRtask.SendToRtask(session, comm.Rtype31, 1, cfg.Color) this.ModuleRtask.SendToRtask(session, comm.Rtype31, 1, cfg.Color)
} }
} }
for k := range heros {
this.moduleFetter.AddHeroFetterData(session, k)
}
// 添加图鉴 // 添加图鉴
go func(uid string, heros map[string]int32) { // 携程处理 图鉴数据 go func(uid string, heros map[string]int32) { // 携程处理 图鉴数据
if result, err1 := this.ModuleUser.GetUserExpand(uid); err1 == nil { if result, err1 := this.ModuleUser.GetUserExpand(uid); err1 == nil {
@ -272,12 +269,6 @@ func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string]
sz = make(map[string]int32, 0) sz = make(map[string]int32, 0)
} }
for k := range heros { for k := range heros {
_data := this.moduleFetter.QueryOneHeroFetter(uid, k) // 查询获得英雄是否存在羁绊信息
this.Debugf("%v", _data)
if _data == nil {
this.moduleFetter.AddHeroFetterData(uid, k) // 创建一个新的羁绊数据
// 写羁绊数据
}
if _, ok := result.GetTujian()[k]; !ok { if _, ok := result.GetTujian()[k]; !ok {
sz[k] = 0 sz[k] = 0

View File

@ -15,6 +15,7 @@ const (
LibraryBuyResp = "buy" LibraryBuyResp = "buy"
LibraryRankListResp = "ranklist" LibraryRankListResp = "ranklist"
LibraryActivationFetterResp = "activationfetter" LibraryActivationFetterResp = "activationfetter"
LibraryChangePush = "change"
) )
type apiComp struct { type apiComp struct {

View File

@ -66,8 +66,8 @@ func (this *Library) GetLibraryListByFid(uid string, fid int32) *pb.DBLibrary {
} }
//通过羁绊id 创建多个羁绊信息 //通过羁绊id 创建多个羁绊信息
func (this *Library) CreateLibrary(uid string, fid int32, heroConfId string) (code pb.ErrorCode, objLibrary []*pb.DBLibrary) { func (this *Library) CreateLibrary(uid string, fid int32, heroConfId string) (code pb.ErrorCode, obj *pb.DBLibrary) {
obj := &pb.DBLibrary{ obj = &pb.DBLibrary{
Id: primitive.NewObjectID().Hex(), Id: primitive.NewObjectID().Hex(),
Uid: uid, Uid: uid,
Fid: fid, Fid: fid,
@ -86,9 +86,7 @@ func (this *Library) CreateLibrary(uid string, fid int32, heroConfId string) (co
} }
if err := this.modelLibrary.createLibrary(uid, obj); err != nil { if err := this.modelLibrary.createLibrary(uid, obj); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
} }
objLibrary = append(objLibrary, obj)
} }
return return
@ -137,40 +135,50 @@ func (this *Library) QueryOneHeroFetter(uid string, cid string) *pb.DBHeroFetter
} }
// 创建一条羁绊信息 // 创建一条羁绊信息
func (this *Library) AddHeroFetterData(uid string, heroConfId string) { func (this *Library) AddHeroFetterData(session comm.IUserSession, heroConfId string) (code pb.ErrorCode) {
this.createHeroFetter(uid, heroConfId) uid := session.GetUserId()
_conf := this.configure.GetLibraryHero(heroConfId) // 推送
if _conf != nil { rsp := &pb.LibraryChangePush{}
szFid := _conf.Fid _data := this.QueryOneHeroFetter(uid, heroConfId)
for _, fid := range szFid { this.Debugf("%v", _data)
// 查询是否存在这个羁绊对象 if _data == nil {
obj := this.GetLibraryListByFid(uid, fid) this.createHeroFetter(uid, heroConfId)
if obj == nil { // 没有羁绊信息 _conf := this.configure.GetLibraryHero(heroConfId)
this.createHeroFetter(uid, heroConfId) if _conf != nil {
this.CreateLibrary(uid, fid, heroConfId) szFid := _conf.Fid
for _, fid := range szFid {
// 查询是否存在这个羁绊对象
obj := this.GetLibraryListByFid(uid, fid)
if obj == nil { // 没有羁绊信息
this.createHeroFetter(uid, heroConfId)
code, obj = this.CreateLibrary(uid, fid, heroConfId)
} else { // 羁绊信息中没有这个heroid 也需要加进来 } else { // 羁绊信息中没有这个heroid 也需要加进来
for k, v := range obj.Hero { for k, v := range obj.Hero {
if v == 0 && k == heroConfId { if v == 0 && k == heroConfId {
obj.Hero[k] = 1 obj.Hero[k] = 1
}
} }
} // 重新计算最低等级
// 重新计算最低等级 var minLv int32
var minLv int32 for _, v := range obj.Hero {
for _, v := range obj.Hero { if minLv < v {
if minLv < v { minLv = v
minLv = v }
} }
obj.Fetterlv = minLv
// 同步数据
mapData := make(map[string]interface{}, 0)
mapData["hero"] = obj.Hero
mapData["fetterlv"] = obj.Fetterlv
this.modelLibrary.modifyLibraryDataByObjId(uid, obj.Id, mapData)
} }
obj.Fetterlv = minLv rsp.Data = append(rsp.Data, obj)
// 同步数据
mapData := make(map[string]interface{}, 0)
mapData["hero"] = obj.Hero
mapData["fetterlv"] = obj.Fetterlv
this.modelLibrary.modifyLibraryDataByObjId(uid, obj.Id, mapData)
} }
session.SendMsg(string(this.GetType()), LibraryChangePush, rsp)
} }
} }
return return
} }