This commit is contained in:
liwei1dao 2023-02-28 17:18:55 +08:00
commit 1d8009f0e0
10 changed files with 46 additions and 42 deletions

View File

@ -42,10 +42,6 @@ type Autogenerated struct {
D []interface{}
}
const (
HeroStarLvRatio int32 = 10 // 卡牌等级上限系数(星级*10
)
//Api Check 错误返回结构
type ErrorCode struct {
Code pb.ErrorCode

View File

@ -94,7 +94,7 @@ type (
GetAllMaxHero(session IUserSession) (code pb.ErrorCode)
// 教习登记
RegisterInstructor(session IUserSession, heroCid string, registerId int32) (code pb.ErrorCode)
RegisterInstructor(session IUserSession, heroOid string, registerId int32) (code pb.ErrorCode)
}
//玩家

View File

@ -69,7 +69,7 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
this.Debugf("create CMD :%s", cmd) // 打印个日志方便查询
datas := strings.Split(keys[1], ",")
if len(datas) == 3 && (datas[0] == comm.AttrType || datas[0] == comm.ItemType ||
datas[0] == comm.HeroType || datas[0] == comm.EquipmentType || datas[0] == comm.VipType || datas[0] == comm.PandaType) {
datas[0] == comm.HeroType || datas[0] == comm.EquipmentType || datas[0] == comm.VipType || datas[0] == comm.AtlasType || datas[0] == comm.PandaType) {
num, err := strconv.Atoi(datas[2])
if err != nil {
code = pb.ErrorCode_ReqParameterError

View File

@ -124,7 +124,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
//xx英雄满级、共鸣、觉醒至最高状态
nextAwaken := this.module.configure.GetHeroAwakenConfig(_hero.HeroID, _hero.JuexingLv+1)
if nextAwaken == nil { // 达到满级觉醒
if _hero.Lv == _hero.Star*comm.HeroStarLvRatio {
if _hero.Lv == this.module.configure.GetHeroMaxLv(_hero.Star) {
this.module.ModuleRtask.SendToRtask(session, comm.Rtype37, 1, cfg.Color)
this.module.ModuleRtask.SendToRtask(session, comm.Rtype38, 1)
}

View File

@ -10,7 +10,7 @@ import (
//参数校验
func (this *apiComp) GetSpecifiedCheck(session comm.IUserSession, req *pb.HeroGetSpecifiedReq) (code pb.ErrorCode) {
if req.HeroCoinfigID == "" || req.Star > 6 || req.Lv > 6*comm.HeroStarLvRatio {
if req.HeroCoinfigID == "" || req.Star <= 0 || req.Lv <= 0 {
code = pb.ErrorCode_ReqParameterError
return
}

View File

@ -66,7 +66,7 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
return
}
// 校验当前能不能升级
if _hero.Lv > _hero.Star*comm.HeroStarLvRatio { // 达到最大等级
if _hero.Lv >= this.module.configure.GetHeroMaxLv(_hero.Star) { // 达到最大等级
code = pb.ErrorCode_HeroMaxLv
return
}

View File

@ -471,18 +471,6 @@ func (this *configureComp) GetShopItemsConfigureByGroups(groupid int32, user *pb
}
return
}
func (this *configureComp) GetHeroStargrowConfigByStar(star int32) int32 {
if v, err := this.GetConfigure(hero_stargrow); err == nil {
if configure, ok := v.(*cfg.GameHeroStargrow); ok {
return configure.Get(star).Maxlevel
}
} else {
err = fmt.Errorf("%T no is *cfg.GameHero", v)
}
return 1
}
// 获取英雄升级属性变化相关配置数据
func (this *configureComp) GetEquipsuit(id int32) (configure *cfg.GameEquipSuitData, err error) {
@ -511,3 +499,17 @@ func (this *configureComp) GetHeroSkillCost(star int32) (cost []*cfg.Gameatn) {
}
return
}
// 获取英雄最大等级
func (this *configureComp) GetHeroMaxLv(star int32) int32 {
if v, err := this.GetConfigure(hero_stargrow); err == nil {
if configure, ok := v.(*cfg.GameHeroStargrow); ok {
return configure.Get(star).Maxlevel
}
} else {
err = fmt.Errorf("%T no is *cfg.GameHero", v)
}
return 1
}

View File

@ -504,7 +504,7 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex
curLv = hero.Lv
preLv = curLv
var maxLv int32 // 校验等级达到上限
maxLv = hero.Star * comm.HeroStarLvRatio
maxLv = this.moduleHero.configure.GetHeroMaxLv(hero.Star)
_data := this.moduleHero.configure.GetHeroLv(curLv)
if _data != nil {
var maxExp int32
@ -577,7 +577,7 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex
//xx英雄满级、共鸣、觉醒至最高状态
nextAwaken := this.moduleHero.configure.GetHeroAwakenConfig(hero.HeroID, hero.JuexingLv+1)
if nextAwaken == nil { // 达到满级觉醒
if hero.Lv == hero.Star*comm.HeroStarLvRatio {
if hero.Lv == this.moduleHero.configure.GetHeroMaxLv(hero.Star) {
this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype37, 1, cfg.Color)
this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype38, 1)
}

View File

@ -220,7 +220,7 @@ func (this *Hero) GetSpecifiedHero(session comm.IUserSession, heroConfId string,
// 获取最大星级
maxStar = this.configure.GetHeroMaxStar(cid, conf.Star)
maxLv := this.configure.GetHeroStargrowConfigByStar(maxStar) // 最大等级
maxLv := this.configure.GetHeroMaxLv(maxStar) // 最大等级
if star > maxStar || lv > maxLv {
code = pb.ErrorCode_ReqParameterError
return
@ -629,7 +629,7 @@ func (this *Hero) GetAllMaxHero(session comm.IUserSession) (code pb.ErrorCode) {
// 获取最大星级
maxStar = this.configure.GetHeroMaxStar(cid, v.Star)
maxLv := this.configure.GetHeroStargrowConfigByStar(maxStar) // 最大等级
maxLv := this.configure.GetHeroMaxLv(maxStar) // 最大等级
maxJux := 1 // 最大觉醒等级
for i := 1; ; i++ {
@ -798,24 +798,30 @@ func (this *Hero) InRange(heroRecord *pb.DBHeroRecord, strPool []string, update
return
}
func (this *Hero) RegisterInstructor(session comm.IUserSession, heroCid string, fulllvenr int32) (code pb.ErrorCode) {
list := this.GetHeroList(session.GetUserId())
for _, v := range list {
if v.HeroID == heroCid && v.Fulllvenr == 0 {
v.Fulllvenr = fulllvenr
_heroMap := map[string]interface{}{
"fulllvenr": v.Fulllvenr,
}
if err := this.modelHero.ChangeList(session.GetUserId(), v.Id, _heroMap); err != nil {
code = pb.ErrorCode_DBError
return
}
return
} else {
code = pb.ErrorCode_HeroIsRegister // 英雄已经注册过
func (this *Hero) RegisterInstructor(session comm.IUserSession, heroOid string, fulllvenr int32) (code pb.ErrorCode) {
_hero, code := this.GetHeroByObjID(session.GetUserId(), heroOid)
if code != pb.ErrorCode_Success {
return
}
if _hero.Fulllvenr == 0 {
// 校验有没有满级
if _hero.Lv < this.configure.GetHeroMaxLv(_hero.Star) {
code = pb.ErrorCode_HeroLvNoEnough // 必须满级
return
}
_hero.Fulllvenr = fulllvenr
_heroMap := map[string]interface{}{
"fulllvenr": _hero.Fulllvenr,
}
if err := this.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap); err != nil {
code = pb.ErrorCode_DBError
return
}
} else {
code = pb.ErrorCode_HeroIsRegister // 英雄已经注册过
return
}
code = pb.ErrorCode_HeroNoExist // 英雄不存在
return
}

View File

@ -49,8 +49,8 @@ func (this *modelMail) MailQueryUserMail(uId string) (mail []*pb.DBMailData, err
}
// 插入一封新的邮件
func (this *modelMail) MailInsertUserMail(mail *pb.DBMailData) (err error) {
func (this *modelMail) MailInsertUserMail(mail *pb.DBMailData) (err error) {
mail.ObjId = primitive.NewObjectID().Hex()
mail.Check = false
mail.Reward = true