技能升级配置表结构变化 对应读取程序修改

This commit is contained in:
meixiongfeng 2022-08-11 11:37:03 +08:00
parent 55127dc69b
commit 161f8a4c20
5 changed files with 1456 additions and 325 deletions

File diff suppressed because it is too large Load Diff

View File

@ -22,12 +22,9 @@ func (this *apiComp) StrengthenUpSkillCheck(session comm.IUserSession, req *pb.H
/// 英雄技能升级
func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroStrengthenUpSkillReq) (code pb.ErrorCode, data proto.Message) {
var (
tmpUpSkillID map[int32]*pb.SkillData // 即将要升级的技能id
probability map[int32]int32 // 即将升级技能的权重
upSkillPos int32 // 升级的技能位置
totalprobability int32 // 所有技能总权重
tmpValue int32 // 临时对象 存放累加权重
tagColor int32 // 目标卡品质
probability map[int32]int32 // 即将升级技能的权重
upSkillPos int32 // 升级的技能位置
totalprobability int32 // 所有技能总权重
_hero *pb.DBHero // 操作的英雄
ChangeList []*pb.DBHero // 推送 改变的英雄
@ -39,7 +36,6 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
mapCostHero = make(map[string]int32, 0)
mapCostObj = make(map[string]*pb.DBHero, 0)
ChangeList = make([]*pb.DBHero, 0)
tmpUpSkillID = make(map[int32]*pb.SkillData, 0)
code = this.StrengthenUpSkillCheck(session, req) // check
if code != pb.ErrorCode_Success {
@ -55,7 +51,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
code = pb.ErrorCode_HeroNoExist
return
}
tagColor = heroCfg.Color
for _, v := range req.CostCardObj { // 数组转 map
mapCostHero[v]++
}
@ -74,7 +70,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
return
}
tmp := this.module.configure.GetHero(costHero.HeroID) // 星级校验
if tmp.Color != tagColor {
if tmp.Color != heroCfg.Color {
code = pb.ErrorCode_HeroColorErr
return
}
@ -99,33 +95,27 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
return
}
tmpUpSkillID := make(map[int32]bool, 0)
for i := 0; i < int(lvUpCount); i++ { // 升级技能
config, err1 := this.module.configure.GetHeroSkillUpConfig()
if err1 != nil {
code = pb.ErrorCode_ConfigNoFound
return
}
probability = make(map[int32]int32, 0)
for index, skill := range _hero.NormalSkill {
skillMaxLv := this.module.configure.GetHeroSkillMaxLvConfig(uint32(skill.SkillID))
if skill.SkillLv < skillMaxLv { // 找到没有满级的技能id
tmpUpSkillID[int32(index)] = skill
tmpUpSkillID[int32(index)] = true
skillData := this.module.configure.GetHeroSkillUpConfig(skill.SkillID)
if skillData == nil {
code = pb.ErrorCode_ConfigNoFound
return
}
probability[skill.SkillID] = skillData.Probability[skill.SkillLv] // 获取权重
}
}
if len(tmpUpSkillID) == 0 {
code = pb.ErrorCode_HeroMaxSkillLv
return
}
probability = make(map[int32]int32, 0)
// 获取权重
for k, v := range tmpUpSkillID {
for _, v2 := range config.GetDataList() { // 需要优化配置表
if v2.Hid == _hero.HeroID && (k+1) == v2.Skillpos && v.SkillLv == v2.Skilllevel {
probability[k] = v2.Probability // 设置权重
break
}
}
}
totalprobability = 0
// 根据权重升级对应的技能
for _, v := range probability {
@ -136,10 +126,10 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
return
}
n, _ := rand.Int(rand.Reader, big.NewInt(int64(totalprobability)))
tmpValue = 0
tmp := 0
for k, v := range probability {
tmpValue += v
if int32(n.Int64()) < tmpValue { // 找到了
tmp += int(v)
if int32(n.Int64()) < v { // 找到了
upSkillPos = k
break
}

View File

@ -270,18 +270,13 @@ func (this *configureComp) GetHeroLvgrow(heroId string) *cfg.Game_heroLevelgrowD
}
// 获取英雄技能升级相关信息
func (this *configureComp) GetHeroSkillUpConfig() (configure *cfg.Game_heroSkillLevel, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(hero_skillup); err == nil {
if configure, ok = v.(*cfg.Game_heroSkillLevel); !ok {
err = fmt.Errorf("%T no is *cfg.Game_hero", v)
func (this *configureComp) GetHeroSkillUpConfig(skillid int32) (data *cfg.Game_heroSkillLevelData) {
if v, err := this.GetConfigure(hero_skillup); err == nil {
if conf, ok := v.(*cfg.Game_heroSkillLevel); ok {
data = conf.Get(skillid)
return
}
} else {
err = fmt.Errorf("%T no is *cfg.Game_hero", v)
}
return

View File

@ -21,7 +21,7 @@ func NewGame_heroSkillLevel(_buf []map[string]interface{}) (*Game_heroSkillLevel
return nil, err2
} else {
_dataList = append(_dataList, _v)
dataMap[_v.Key] = _v
dataMap[_v.Id] = _v
}
}
return &Game_heroSkillLevel{_dataList:_dataList, _dataMap:dataMap}, nil

View File

@ -11,11 +11,8 @@ package cfg
import "errors"
type Game_heroSkillLevelData struct {
Key int32
Hid string
Skillpos int32
Skilllevel int32
Probability int32
Id int32
Probability []int32
}
func (Game_heroSkillLevelData) GetTypeId() int {
@ -24,10 +21,20 @@ func (Game_heroSkillLevelData) GetTypeId() int {
func NewGame_heroSkillLevelData(_buf map[string]interface{}) (_v *Game_heroSkillLevelData, err error) {
_v = &Game_heroSkillLevelData{}
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["key"].(float64); !_ok_ { err = errors.New("key error"); return }; _v.Key = int32(_tempNum_) }
{ var _ok_ bool; if _v.Hid, _ok_ = _buf["hid"].(string); !_ok_ { err = errors.New("hid error"); return } }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["skillpos"].(float64); !_ok_ { err = errors.New("skillpos error"); return }; _v.Skillpos = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["skilllevel"].(float64); !_ok_ { err = errors.New("skilllevel error"); return }; _v.Skilllevel = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["probability"].(float64); !_ok_ { err = errors.New("probability error"); return }; _v.Probability = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) }
{
var _arr_ []interface{}
var _ok_ bool
if _arr_, _ok_ = _buf["probability"].([]interface{}); !_ok_ { err = errors.New("probability error"); return }
_v.Probability = make([]int32, 0, len(_arr_))
for _, _e_ := range _arr_ {
var _list_v_ int32
{ var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) }
_v.Probability = append(_v.Probability, _list_v_)
}
}
return
}