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 {
ModifyHeroFetterData(uid string, obj string, data map[string]interface{}) (code pb.ErrorCode) // 修改羁绊信息
QueryHeroFetter(uid string) (data []*pb.DBHeroFetter) // 查询所有的羁绊信息
QueryOneHeroFetter(uid string, cid string) *pb.DBHeroFetter // 通过英雄配置id 查询羁绊信息
AddHeroFetterData(uid string, heroConfId string) // 创建一条羁绊信息
//QueryOneHeroFetter(uid string, cid string) *pb.DBHeroFetter // 通过英雄配置id 查询羁绊信息
AddHeroFetterData(session IUserSession, heroConfId string) (code pb.ErrorCode) // 创建一条羁绊信息
}
//月子秘境
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) {
_hero, err := this.modelHero.createHeroOverlying(session.GetUserId(), heroCfgId, num)
if err == nil {
this.moduleFetter.AddHeroFetterData(session, heroCfgId)
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 {
initUpdate := map[string]interface{}{}
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)
}
}
for k := range heros {
this.moduleFetter.AddHeroFetterData(session, k)
}
// 添加图鉴
go func(uid string, heros map[string]int32) { // 携程处理 图鉴数据
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)
}
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 {
sz[k] = 0

View File

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

View File

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