This commit is contained in:
meixiongfeng 2022-12-20 16:12:57 +08:00
parent a05f57c626
commit 3ee4ca9f77
7 changed files with 76 additions and 109 deletions

View File

@ -547,7 +547,7 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex
hero.SameCount -= 1 hero.SameCount -= 1
newhero = this.CloneNewHero(hero) // 克隆一个新的 newhero = this.CloneNewHero(hero) // 克隆一个新的
} }
this.moduleHero.Debugf("add hero exp :old lv:%d,old exp:%d,new lv:%d,new exp:%d,addexp:%d", hero.Lv, hero.Exp, curLv, curExp, exp)
update["lv"] = curLv update["lv"] = curLv
update["exp"] = curExp update["exp"] = curExp
update["isOverlying"] = false update["isOverlying"] = false
@ -557,7 +557,7 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex
hero.Exp = curExp hero.Exp = curExp
hero.IsOverlying = false hero.IsOverlying = false
hero.SameCount = 1 hero.SameCount = 1
this.moduleHero.Debugf("add hero exp :%v", hero)
if err := this.ChangeList(session.GetUserId(), hero.Id, update); err != nil { if err := this.ChangeList(session.GetUserId(), hero.Id, update); err != nil {
this.moduleHero.Errorf("add hero exp failed ChangeList %v", err) this.moduleHero.Errorf("add hero exp failed ChangeList %v", err)
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError

View File

@ -22,13 +22,19 @@ func (this *apiComp) Activate(session comm.IUserSession, req *pb.PagodaActivateR
var ( var (
list *pb.DBPagoda list *pb.DBPagoda
) )
this.ActivateCheck(session, req) list, err := this.module.modelPagoda.getPagodaList(session.GetUserId())
expand, err := this.module.ModuleUser.GetUserExpand(session.GetUserId())
if err != nil { if err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
if expand.CompletePagoda { // 普通塔 Nomalcfg := this.module.configure.GetPagodaConfigData(comm.PagodaType, list.PagodaId+1)
if Nomalcfg == nil && !list.Complete {
list.Complete = true
this.module.ModifyPagodaData(session.GetUserId(), map[string]interface{}{
"complete": true,
})
}
if list.Complete {
season, _ := this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId()) season, _ := this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
if season.Id == "" { if season.Id == "" {
season.Id = primitive.NewObjectID().Hex() season.Id = primitive.NewObjectID().Hex()

View File

@ -27,6 +27,8 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal
pagoda *pb.DBPagoda pagoda *pb.DBPagoda
costTime int32 // 本次战斗消耗的时间 costTime int32 // 本次战斗消耗的时间
isWin bool isWin bool
err error
bSeason bool
) )
mapData = make(map[string]interface{}, 0) mapData = make(map[string]interface{}, 0)
code = this.ChallengeOverCheck(session, req) code = this.ChallengeOverCheck(session, req)
@ -34,38 +36,29 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal
return // 参数校验失败直接返回 return // 参数校验失败直接返回
} }
// 校验是不是通关了普通塔
expand, err := this.module.ModuleUser.GetUserExpand(session.GetUserId())
if err != nil {
code = pb.ErrorCode_DBError
return
}
conf := this.module.configure.GetPagodaConfigData(req.PagodaType, req.LevelID) conf := this.module.configure.GetPagodaConfigData(req.PagodaType, req.LevelID)
if conf == nil { if conf == nil {
code = pb.ErrorCode_PagodaNotFound code = pb.ErrorCode_PagodaNotFound
return return
} }
if !expand.CompletePagoda { pagoda, err = this.module.modelPagoda.getPagodaList(session.GetUserId())
pagoda, err = this.module.modelPagoda.getPagodaList(session.GetUserId()) if err != nil {
if err != nil { code = pb.ErrorCode_PagodaNotFound
code = pb.ErrorCode_PagodaNotFound return
return }
}
if pagoda.Type != conf.PagodaType || conf.LayerNum-1 != pagoda.PagodaId { if pagoda.Complete {
code = pb.ErrorCode_PagodaLevlErr // 挑战关卡数据不匹配
return
}
} else {
// 塔数据校验 // 塔数据校验
pagoda, err = this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId()) pagoda, err = this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
if err != nil { if err != nil {
code = pb.ErrorCode_PagodaNotFound code = pb.ErrorCode_PagodaNotFound
return return
} }
if pagoda.Type != req.PagodaType || conf.LayerNum-1 != pagoda.PagodaId { bSeason = true
code = pb.ErrorCode_PagodaLevlErr // 挑战关卡数据不匹配 }
return if pagoda.Type != conf.PagodaType || conf.LayerNum-1 != pagoda.PagodaId {
} code = pb.ErrorCode_PagodaLevlErr // 挑战关卡数据不匹配
return
} }
// 校验通过 // 校验通过
code, isWin = this.module.battle.CheckBattleReport(session, req.Report) code, isWin = this.module.battle.CheckBattleReport(session, req.Report)
@ -85,43 +78,27 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal
} }
} }
} }
if !expand.CompletePagoda { // 普通塔 if !bSeason { // 普通塔
pagoda.Type = req.PagodaType pagoda.Type = req.PagodaType
mapData["pagodaId"] = conf.LayerNum mapData["pagodaId"] = conf.LayerNum
mapData["type"] = pagoda.Type mapData["type"] = pagoda.Type
pagoda.PagodaId = conf.LayerNum // 更新层数 this.module.modulerank.AddPagodaRecord(session.GetUserId(), costTime, pagoda.PagodaId, conf.PagodaType)
code = this.module.ModifyPagodaData(session.GetUserId(), mapData)
session.SendMsg(string(this.module.GetType()), PagodaChallengeOverResp, &pb.PagodaChallengeOverResp{Data: pagoda})
if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil {
this.chat.SendSysChatToWorld(comm.ChatSystem4, nil, pagoda.PagodaId, 0, user.Name)
} else {
this.module.Errorf("no found userdata uid:%s", session.GetUserId())
}
userinfo := this.module.ModuleUser.GetUser(session.GetUserId())
newData := &pb.DBPagodaRecord{
Id: primitive.NewObjectID().Hex(),
Uid: session.GetUserId(),
PagodaId: pagoda.PagodaId,
Type: pagoda.Type,
Nickname: userinfo.Name,
Icon: "", // icon 暂无
Lv: userinfo.Lv,
CostTime: req.Report.Costtime,
}
costTime = newData.CostTime
this.module.modulerank.AddPagodaRecord(session.GetUserId(), newData)
//this.module.modulerank.SetNormalPagodaRankList("pagodaRank", pagoda.PagodaId<<16-costTime, session.GetUserId())
// 普通塔通关了 // 普通塔通关了
Nomalcfg := this.module.configure.GetPagodaConfigData(comm.PagodaType, pagoda.PagodaId+1) Nomalcfg := this.module.configure.GetPagodaConfigData(comm.PagodaType, pagoda.PagodaId+1)
if Nomalcfg == nil { if Nomalcfg == nil {
// 修改expand 数据 pagoda.Complete = true
update := map[string]interface{}{ mapData["complete"] = pagoda.Complete
"completePagoda": true, }
}
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), update) pagoda.PagodaId = conf.LayerNum // 更新层数
code = this.module.ModifyPagodaData(session.GetUserId(), mapData)
session.SendMsg(string(this.module.GetType()), PagodaChallengeOverResp, &pb.PagodaChallengeOverResp{Data: pagoda})
if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { // 发系统公告
this.chat.SendSysChatToWorld(comm.ChatSystem4, nil, pagoda.PagodaId, 0, user.Name)
} else {
this.module.Errorf("no found userdata uid:%s", session.GetUserId())
} }
} else { } else {
pagoda.PagodaId = conf.LayerNum pagoda.PagodaId = conf.LayerNum

View File

@ -19,14 +19,8 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PagodaGetListReq
var ( var (
list *pb.DBPagoda list *pb.DBPagoda
) )
this.GetListCheck(session, req)
expand, err := this.module.ModuleUser.GetUserExpand(session.GetUserId())
if err != nil {
code = pb.ErrorCode_DBError
return
}
list, _ = this.module.modelPagoda.getPagodaList(session.GetUserId()) list, _ = this.module.modelPagoda.getPagodaList(session.GetUserId())
if !expand.CompletePagoda { // 普通塔 if list.Id == "" { // 普通塔
if list == nil { // redis没有数据 if list == nil { // redis没有数据
list = &pb.DBPagoda{} list = &pb.DBPagoda{}
list.Id = primitive.NewObjectID().Hex() list.Id = primitive.NewObjectID().Hex()
@ -36,13 +30,8 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PagodaGetListReq
list.Type = comm.PagodaType list.Type = comm.PagodaType
this.module.modelPagoda.addNewPagoda(session.GetUserId(), list) this.module.modelPagoda.addNewPagoda(session.GetUserId(), list)
} }
} else { } else if list.Complete {
season, _ := this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId()) list, _ = this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
if season.Id == "" {
list.Complete = true
} else {
list = season
}
} }
session.SendMsg(string(this.module.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list}) session.SendMsg(string(this.module.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list})

View File

@ -3,7 +3,7 @@ package pagoda
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/redis" "go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
@ -30,10 +30,8 @@ func (this *ModelPagoda) Init(service core.IService, module core.IModule, comp c
// 获取爬塔信息 // 获取爬塔信息
func (this *ModelPagoda) getPagodaList(uid string) (result *pb.DBPagoda, err error) { func (this *ModelPagoda) getPagodaList(uid string) (result *pb.DBPagoda, err error) {
result = &pb.DBPagoda{} result = &pb.DBPagoda{}
if err = this.Get(uid, result); err != nil { if err = this.Get(uid, result); err != nil && err == mgo.MongodbNil {
if redis.RedisNil != err { err = nil
result = nil
}
return return
} }
err = nil err = nil

View File

@ -14,6 +14,7 @@ import (
"go_dreamfactory/sys/db" "go_dreamfactory/sys/db"
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
"go.mongodb.org/mongo-driver/bson/primitive"
) )
var floorRankKey = "pagoda:floor" var floorRankKey = "pagoda:floor"
@ -40,8 +41,20 @@ func (this *ModelRank) GetRankData() (data []*pb.DBPagodaRecord, err error) {
return return
} }
func (this *ModelRank) AddPagodaRecord(uid string, record *pb.DBPagodaRecord) (err error) { // 写记录
err = this.AddList(uid, record.Id, record) func (this *ModelRank) AddPagodaRecord(uid string, costTime, pagodaId, pagodaType int32) (err error) {
userinfo := this.modulePagoda.ModuleUser.GetUser(uid)
newData := &pb.DBPagodaRecord{
Id: primitive.NewObjectID().Hex(),
Uid: uid,
PagodaId: pagodaId,
Type: pagodaType,
Nickname: userinfo.Name,
Icon: "", // icon 暂无
Lv: userinfo.Lv,
CostTime: costTime,
}
err = this.AddList(uid, newData.Id, newData)
return return
} }

View File

@ -241,43 +241,27 @@ func (this *Pagoda) CheckPagodaMaxFloor(uid string, pagodaType int32) int32 {
// 赛季塔跳转 // 赛季塔跳转
func (this *Pagoda) ModifySeasonPagodaFloor(session comm.IUserSession, level int32) (code pb.ErrorCode) { func (this *Pagoda) ModifySeasonPagodaFloor(session comm.IUserSession, level int32) (code pb.ErrorCode) {
list, _ := this.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
if list.Id == "" {
list.Id = primitive.NewObjectID().Hex()
list.Uid = session.GetUserId()
list.PagodaId = level
if conn, err := db.Cross(); err == nil {
rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{})
server := &pb.DBServerData{}
rst.Decode(server)
list.Type = server.SeasonType
expand, err := this.ModuleUser.GetUserExpand(session.GetUserId())
if err != nil {
code = pb.ErrorCode_DBError
return
}
if !expand.CompletePagoda { // 普通塔
expand.CompletePagoda = true
update := map[string]interface{}{
"completePagoda": true,
}
this.ModuleUser.ChangeUserExpand(session.GetUserId(), update)
list, _ := this.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
if list.Id == "" {
list.Id = primitive.NewObjectID().Hex()
list.Uid = session.GetUserId()
list.PagodaId = level
if conn, err := db.Cross(); err == nil {
rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{})
server := &pb.DBServerData{}
rst.Decode(server)
list.Type = server.SeasonType
}
this.modelSeasonPagoda.addNewSeasonPagoda(session.GetUserId(), list)
session.SendMsg(string(this.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list})
} }
this.modelSeasonPagoda.addNewSeasonPagoda(session.GetUserId(), list)
session.SendMsg(string(this.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list})
} else { } else {
list, _ := this.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
if list.Id != "" {
list.PagodaId = level list.PagodaId = level
mapData := make(map[string]interface{}, 0) mapData := make(map[string]interface{}, 0)
mapData["pagodaId"] = level mapData["pagodaId"] = level
code = this.ModifySeasonPagodaData(session.GetUserId(), mapData) code = this.ModifySeasonPagodaData(session.GetUserId(), mapData)
session.SendMsg(string(this.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list}) session.SendMsg(string(this.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list})
}
} }
return return