go_dreamfactory/modules/practice/api_upgrade.go
2023-03-30 17:28:49 +08:00

85 lines
2.1 KiB
Go

package practice
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"google.golang.org/protobuf/proto"
)
//参数校验
func (this *apiComp) UpgradeCheck(session comm.IUserSession, req *pb.PracticeUpgradeReq) (code pb.ErrorCode) {
return
}
///练功请求 蹭馆
func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.PracticeUpgradeReq) (code pb.ErrorCode, data proto.Message) {
var (
err error
room *pb.DBPracticeRoom
pillarconfigure *cfg.GamePandamasMzData
pillar *pb.DBPracticePillar
filed string
)
if room, err = this.module.modelPandata.queryUserMartialhall(session.GetUserId()); err != nil {
code = pb.ErrorCode_DBError
return
}
switch req.Index {
case 1:
pillar = room.Pillar1
filed = "pillar1"
break
case 2:
pillar = room.Pillar2
filed = "pillar2"
break
case 3:
pillar = room.Pillar3
filed = "pillar3"
break
case 4:
pillar = room.Pillarf
filed = "pillarf"
break
}
if pillar.Hero != "" {
code = pb.ErrorCode_ReqParameterError
return
}
if pillarconfigure, err = this.module.configure.getGamePandamasMz(pillar.Lv); err != nil || len(pillarconfigure.UpLvConsume) == 0 {
code = pb.ErrorCode_PracticePillarMaxLv
return
}
if code = this.module.ConsumeRes(session, pillarconfigure.UpLvConsume, true); code != pb.ErrorCode_Success {
return
}
pillar.Lv++
if room.Pillarf.Lv < pillar.Lv {
room.Pillarf.Lv = pillar.Lv
}
switch pillar.Lv {
case 2:
this.module.atlas.CheckActivatePandaAtlasCollect(session.GetUserId(), "100002")
break
case 3:
this.module.atlas.CheckActivatePandaAtlasCollect(session.GetUserId(), "100003")
break
case 4:
this.module.atlas.CheckActivatePandaAtlasCollect(session.GetUserId(), "100004")
break
case 5:
this.module.atlas.CheckActivatePandaAtlasCollect(session.GetUserId(), "100005")
break
}
this.module.modelPandata.Change(session.GetUserId(), map[string]interface{}{
filed: pillar,
"pillarf": room.Pillarf,
})
session.SendMsg(string(this.module.GetType()), "upgrade", &pb.PracticeUpgradeResp{Index: req.Index, Lv: pillar.Lv})
return
}