优化
This commit is contained in:
parent
a05f57c626
commit
3ee4ca9f77
@ -547,7 +547,7 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex
|
||||
hero.SameCount -= 1
|
||||
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["exp"] = curExp
|
||||
update["isOverlying"] = false
|
||||
@ -557,7 +557,7 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex
|
||||
hero.Exp = curExp
|
||||
hero.IsOverlying = false
|
||||
hero.SameCount = 1
|
||||
this.moduleHero.Debugf("add hero exp :%v", hero)
|
||||
|
||||
if err := this.ChangeList(session.GetUserId(), hero.Id, update); err != nil {
|
||||
this.moduleHero.Errorf("add hero exp failed ChangeList %v", err)
|
||||
code = pb.ErrorCode_DBError
|
||||
|
@ -22,13 +22,19 @@ func (this *apiComp) Activate(session comm.IUserSession, req *pb.PagodaActivateR
|
||||
var (
|
||||
list *pb.DBPagoda
|
||||
)
|
||||
this.ActivateCheck(session, req)
|
||||
expand, err := this.module.ModuleUser.GetUserExpand(session.GetUserId())
|
||||
list, err := this.module.modelPagoda.getPagodaList(session.GetUserId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
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())
|
||||
if season.Id == "" {
|
||||
season.Id = primitive.NewObjectID().Hex()
|
||||
|
@ -27,6 +27,8 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal
|
||||
pagoda *pb.DBPagoda
|
||||
costTime int32 // 本次战斗消耗的时间
|
||||
isWin bool
|
||||
err error
|
||||
bSeason bool
|
||||
)
|
||||
mapData = make(map[string]interface{}, 0)
|
||||
code = this.ChallengeOverCheck(session, req)
|
||||
@ -34,39 +36,30 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal
|
||||
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)
|
||||
if conf == nil {
|
||||
code = pb.ErrorCode_PagodaNotFound
|
||||
return
|
||||
}
|
||||
if !expand.CompletePagoda {
|
||||
pagoda, err = this.module.modelPagoda.getPagodaList(session.GetUserId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_PagodaNotFound
|
||||
return
|
||||
}
|
||||
if pagoda.Type != conf.PagodaType || conf.LayerNum-1 != pagoda.PagodaId {
|
||||
code = pb.ErrorCode_PagodaLevlErr // 挑战关卡数据不匹配
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
||||
if pagoda.Complete {
|
||||
// 塔数据校验
|
||||
pagoda, err = this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_PagodaNotFound
|
||||
return
|
||||
}
|
||||
if pagoda.Type != req.PagodaType || conf.LayerNum-1 != pagoda.PagodaId {
|
||||
bSeason = true
|
||||
}
|
||||
if pagoda.Type != conf.PagodaType || conf.LayerNum-1 != pagoda.PagodaId {
|
||||
code = pb.ErrorCode_PagodaLevlErr // 挑战关卡数据不匹配
|
||||
return
|
||||
}
|
||||
}
|
||||
// 校验通过
|
||||
code, isWin = this.module.battle.CheckBattleReport(session, req.Report)
|
||||
if code != pb.ErrorCode_Success {
|
||||
@ -85,43 +78,27 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal
|
||||
}
|
||||
}
|
||||
}
|
||||
if !expand.CompletePagoda { // 普通塔
|
||||
if !bSeason { // 普通塔
|
||||
pagoda.Type = req.PagodaType
|
||||
mapData["pagodaId"] = conf.LayerNum
|
||||
mapData["type"] = pagoda.Type
|
||||
|
||||
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())
|
||||
}
|
||||
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())
|
||||
this.module.modulerank.AddPagodaRecord(session.GetUserId(), costTime, pagoda.PagodaId, conf.PagodaType)
|
||||
|
||||
// 普通塔通关了
|
||||
Nomalcfg := this.module.configure.GetPagodaConfigData(comm.PagodaType, pagoda.PagodaId+1)
|
||||
if Nomalcfg == nil {
|
||||
// 修改expand 数据
|
||||
update := map[string]interface{}{
|
||||
"completePagoda": true,
|
||||
pagoda.Complete = true
|
||||
mapData["complete"] = pagoda.Complete
|
||||
}
|
||||
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 {
|
||||
pagoda.PagodaId = conf.LayerNum
|
||||
|
@ -19,14 +19,8 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PagodaGetListReq
|
||||
var (
|
||||
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())
|
||||
if !expand.CompletePagoda { // 普通塔
|
||||
if list.Id == "" { // 普通塔
|
||||
if list == nil { // redis没有数据
|
||||
list = &pb.DBPagoda{}
|
||||
list.Id = primitive.NewObjectID().Hex()
|
||||
@ -36,13 +30,8 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PagodaGetListReq
|
||||
list.Type = comm.PagodaType
|
||||
this.module.modelPagoda.addNewPagoda(session.GetUserId(), list)
|
||||
}
|
||||
} else {
|
||||
season, _ := this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
|
||||
if season.Id == "" {
|
||||
list.Complete = true
|
||||
} else {
|
||||
list = season
|
||||
}
|
||||
} else if list.Complete {
|
||||
list, _ = this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list})
|
||||
|
@ -3,7 +3,7 @@ package pagoda
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/redis"
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
"go_dreamfactory/modules"
|
||||
"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) {
|
||||
result = &pb.DBPagoda{}
|
||||
if err = this.Get(uid, result); err != nil {
|
||||
if redis.RedisNil != err {
|
||||
result = nil
|
||||
}
|
||||
if err = this.Get(uid, result); err != nil && err == mgo.MongodbNil {
|
||||
err = nil
|
||||
return
|
||||
}
|
||||
err = nil
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
"go_dreamfactory/sys/db"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
var floorRankKey = "pagoda:floor"
|
||||
@ -40,8 +41,20 @@ func (this *ModelRank) GetRankData() (data []*pb.DBPagodaRecord, err error) {
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -241,18 +241,6 @@ func (this *Pagoda) CheckPagodaMaxFloor(uid string, pagodaType int32) int32 {
|
||||
|
||||
// 赛季塔跳转
|
||||
func (this *Pagoda) ModifySeasonPagodaFloor(session comm.IUserSession, level int32) (code pb.ErrorCode) {
|
||||
|
||||
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()
|
||||
@ -267,10 +255,7 @@ func (this *Pagoda) ModifySeasonPagodaFloor(session comm.IUserSession, level int
|
||||
}
|
||||
this.modelSeasonPagoda.addNewSeasonPagoda(session.GetUserId(), list)
|
||||
session.SendMsg(string(this.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list})
|
||||
}
|
||||
} else {
|
||||
list, _ := this.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
|
||||
if list.Id != "" {
|
||||
|
||||
list.PagodaId = level
|
||||
mapData := make(map[string]interface{}, 0)
|
||||
@ -278,7 +263,6 @@ func (this *Pagoda) ModifySeasonPagodaFloor(session comm.IUserSession, level int
|
||||
code = this.ModifySeasonPagodaData(session.GetUserId(), mapData)
|
||||
session.SendMsg(string(this.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list})
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user