merge
This commit is contained in:
parent
18cf7796b6
commit
b7d1b011a8
2
go.mod
2
go.mod
@ -5,6 +5,7 @@ go 1.18
|
|||||||
require (
|
require (
|
||||||
bright v0.0.0
|
bright v0.0.0
|
||||||
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394
|
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394
|
||||||
|
github.com/dengsgo/math-engine v0.0.0-20220213125415-0351c3c75eca
|
||||||
github.com/go-playground/validator/v10 v10.10.1
|
github.com/go-playground/validator/v10 v10.10.1
|
||||||
github.com/go-redis/redis/v8 v8.11.5
|
github.com/go-redis/redis/v8 v8.11.5
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible
|
github.com/golang-jwt/jwt v3.2.2+incompatible
|
||||||
@ -43,7 +44,6 @@ require (
|
|||||||
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
|
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||||
github.com/cheekybits/genny v1.0.0 // indirect
|
github.com/cheekybits/genny v1.0.0 // indirect
|
||||||
github.com/dengsgo/math-engine v0.0.0-20220213125415-0351c3c75eca // indirect
|
|
||||||
github.com/dgryski/go-jump v0.0.0-20211018200510-ba001c3ffce0 // indirect
|
github.com/dgryski/go-jump v0.0.0-20211018200510-ba001c3ffce0 // indirect
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
github.com/edwingeng/doublejump v0.0.0-20210724020454-c82f1bcb3280 // indirect
|
github.com/edwingeng/doublejump v0.0.0-20210724020454-c82f1bcb3280 // indirect
|
||||||
|
@ -118,7 +118,7 @@ func (this *Api_Comp) Upgrade(session comm.IUserSession, agrs map[string]interfa
|
|||||||
|
|
||||||
//已装备 重新计算属性
|
//已装备 重新计算属性
|
||||||
if equipment.HeroId != "" {
|
if equipment.HeroId != "" {
|
||||||
if hero, code = this.module.hero.GetHero(equipment.HeroId); code != pb.ErrorCode_Success {
|
if hero, code = this.module.hero.GetHero(session.GetUserId(), equipment.HeroId); code != pb.ErrorCode_Success {
|
||||||
log.Errorf("Upgrade code:%d", code)
|
log.Errorf("Upgrade code:%d", code)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package hero
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
@ -31,8 +30,8 @@ func (this *Api_Comp) StrengthenUplv_Check(session comm.IUserSession, req *pb.He
|
|||||||
var costGold int32 // 当前需要消耗金币的数量
|
var costGold int32 // 当前需要消耗金币的数量
|
||||||
var addExp int32 // 需要增加的经验
|
var addExp int32 // 需要增加的经验
|
||||||
// 查询 本次消耗会获得多少经验
|
// 查询 本次消耗会获得多少经验
|
||||||
expConf, err1 := this.module.configure_comp.GetHeroExpConByHeroid(_expHero.HeroID)
|
expConf := this.module.configure_comp.GetHeroExp(_expHero.HeroID)
|
||||||
if err1 != nil {
|
if expConf != nil {
|
||||||
addExp = expConf.Heroexp * req.Amount
|
addExp = expConf.Heroexp * req.Amount
|
||||||
}
|
}
|
||||||
if _expHero.Count <= req.Amount { // 消耗经验卡片数量不足
|
if _expHero.Count <= req.Amount { // 消耗经验卡片数量不足
|
||||||
@ -45,7 +44,7 @@ func (this *Api_Comp) StrengthenUplv_Check(session comm.IUserSession, req *pb.He
|
|||||||
code.Code = pb.ErrorCode_HeroMaxLv
|
code.Code = pb.ErrorCode_HeroMaxLv
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _data, err1 := this.module.configure_comp.GetHeroLevelUpByLv(curLv); err1 == nil {
|
if _data := this.module.configure_comp.GetHeroLv(curLv); _data != nil {
|
||||||
costGold += _data.Gold[0].N
|
costGold += _data.Gold[0].N
|
||||||
curExp += addExp // 先把经验加上
|
curExp += addExp // 先把经验加上
|
||||||
// 当前升级需要消耗的经验
|
// 当前升级需要消耗的经验
|
||||||
@ -54,7 +53,7 @@ func (this *Api_Comp) StrengthenUplv_Check(session comm.IUserSession, req *pb.He
|
|||||||
curExp = _data.Heroexp[0].N
|
curExp = _data.Heroexp[0].N
|
||||||
if curExp >= 0 { // 大于下一级经验
|
if curExp >= 0 { // 大于下一级经验
|
||||||
curLv += 1 // 经验够了 那么等级+1
|
curLv += 1 // 经验够了 那么等级+1
|
||||||
if _data, err1 := this.module.configure_comp.GetHeroLevelUpByLv(curLv); err1 == nil {
|
if _data := this.module.configure_comp.GetHeroLv(curLv); _data != nil {
|
||||||
if _data.Heroexp[0].N > curExp { // 经验不足则 直接返回
|
if _data.Heroexp[0].N > curExp { // 经验不足则 直接返回
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -88,12 +87,5 @@ func (this *Api_Comp) StrengthenUplv(session comm.IUserSession, agrs map[string]
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if configure, err := this.module.configure_comp.GetHeroConfigure(); err != nil {
|
|
||||||
_data := configure.GetDataMap()
|
|
||||||
for key, value := range _data {
|
|
||||||
log.Fatalf("%d,%v", key, value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
game_hero = "game_newhero.json"
|
new_hero = "game_newhero.json" //英雄
|
||||||
game_heroStargrow = "game_heroStargrow.json"
|
hero_stargrow = "game_herostargrow.json" //英雄品质系数
|
||||||
game_heroLevelgrow = "game_heroLevelgrow.json"
|
hero_levelgrow = "game_herolevelgrow.json" //英雄成长系数
|
||||||
game_heroStarup = "game_heroStarup.json"
|
hero_starup = "game_herostarup.json" //
|
||||||
game_heroLevelup = "game_heroLevelup.json"
|
hero_levelup = "game_herolevelup.json" //英雄等级基础属性
|
||||||
game_heroExp = "game_exp.json"
|
hero_exp = "game_exp.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
///配置管理组件
|
///配置管理组件
|
||||||
@ -24,28 +24,33 @@ type Configure_Comp struct {
|
|||||||
|
|
||||||
//组件初始化接口
|
//组件初始化接口
|
||||||
func (this *Configure_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *Configure_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
this.ModuleCompBase.Init(service, module, comp, options)
|
|
||||||
this.LoadConfigure(game_hero, cfg.NewGame_newHero)
|
err = this.MComp_Configure.Init(service, module, comp, options)
|
||||||
this.LoadConfigure(game_heroStargrow, cfg.NewGame_heroStargrow)
|
err = this.LoadMultiConfigure(map[string]interface{}{
|
||||||
this.LoadConfigure(game_heroLevelgrow, cfg.NewGame_heroLevelgrow)
|
new_hero: cfg.NewGame_newHero,
|
||||||
this.LoadConfigure(game_heroStarup, cfg.NewGame_heroStarup)
|
hero_stargrow: cfg.NewGame_heroStargrow,
|
||||||
this.LoadConfigure(game_heroLevelup, cfg.NewGame_heroLevelup)
|
hero_levelgrow: cfg.NewGame_heroLevelgrow,
|
||||||
this.LoadConfigure(game_heroExp, cfg.NewGame_heroExp)
|
hero_starup: cfg.NewGame_heroStarup,
|
||||||
|
hero_levelup: cfg.NewGame_heroLevelup,
|
||||||
|
hero_exp: cfg.NewGame_heroExp,
|
||||||
|
})
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取英雄配置数据
|
//获取英雄配置数据
|
||||||
func (this *Configure_Comp) GetHeroConfigure() (configure *cfg.Game_newHero, err error) {
|
func (this *Configure_Comp) getHeroConfigure() (configure *cfg.Game_newHero, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
ok bool
|
ok bool
|
||||||
)
|
)
|
||||||
if v, err = this.GetConfigure(game_hero); err == nil {
|
|
||||||
|
if v, err = this.GetConfigure(new_hero); err != nil {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
if configure, ok = v.(*cfg.Game_newHero); !ok {
|
if configure, ok = v.(*cfg.Game_newHero); !ok {
|
||||||
err = fmt.Errorf("%T no is *cfg.Game_hero", v)
|
err = fmt.Errorf("%T no is *cfg.Game_hero", v)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
err = fmt.Errorf("%T no is *cfg.Game_hero", v)
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -56,7 +61,7 @@ func (this *Configure_Comp) GetHeroStargrowCon() (configure *cfg.Game_heroStargr
|
|||||||
v interface{}
|
v interface{}
|
||||||
ok bool
|
ok bool
|
||||||
)
|
)
|
||||||
if v, err = this.GetConfigure(game_heroStargrow); err == nil {
|
if v, err = this.GetConfigure(hero_stargrow); err == nil {
|
||||||
if configure, ok = v.(*cfg.Game_heroStargrow); !ok {
|
if configure, ok = v.(*cfg.Game_heroStargrow); !ok {
|
||||||
err = fmt.Errorf("%T no is *cfg.Game_hero", v)
|
err = fmt.Errorf("%T no is *cfg.Game_hero", v)
|
||||||
return
|
return
|
||||||
@ -74,7 +79,7 @@ func (this *Configure_Comp) GetHeroLevelgrowCon() (configure *cfg.Game_heroLevel
|
|||||||
v interface{}
|
v interface{}
|
||||||
ok bool
|
ok bool
|
||||||
)
|
)
|
||||||
if v, err = this.GetConfigure(game_heroLevelgrow); err == nil {
|
if v, err = this.GetConfigure(hero_levelgrow); err == nil {
|
||||||
if configure, ok = v.(*cfg.Game_heroLevelgrow); !ok {
|
if configure, ok = v.(*cfg.Game_heroLevelgrow); !ok {
|
||||||
err = fmt.Errorf("%T no is *cfg.Game_heroLevelgrow", v)
|
err = fmt.Errorf("%T no is *cfg.Game_heroLevelgrow", v)
|
||||||
return
|
return
|
||||||
@ -90,7 +95,7 @@ func (this *Configure_Comp) GetHeroStarupCon() (configure *cfg.Game_heroStarup,
|
|||||||
v interface{}
|
v interface{}
|
||||||
ok bool
|
ok bool
|
||||||
)
|
)
|
||||||
if v, err = this.GetConfigure(game_heroStarup); err == nil {
|
if v, err = this.GetConfigure(hero_starup); err == nil {
|
||||||
if configure, ok = v.(*cfg.Game_heroStarup); !ok {
|
if configure, ok = v.(*cfg.Game_heroStarup); !ok {
|
||||||
err = fmt.Errorf("%T no is *cfg.Game_heroStarup", v)
|
err = fmt.Errorf("%T no is *cfg.Game_heroStarup", v)
|
||||||
return
|
return
|
||||||
@ -107,7 +112,7 @@ func (this *Configure_Comp) GetHeroLevelUpCon() (configure *cfg.Game_heroLevelup
|
|||||||
v interface{}
|
v interface{}
|
||||||
ok bool
|
ok bool
|
||||||
)
|
)
|
||||||
if v, err = this.GetConfigure(game_heroLevelup); err == nil {
|
if v, err = this.GetConfigure(hero_levelup); err == nil {
|
||||||
if configure, ok = v.(*cfg.Game_heroLevelup); !ok {
|
if configure, ok = v.(*cfg.Game_heroLevelup); !ok {
|
||||||
err = fmt.Errorf("%T no is *cfg.Game_heroLevelup", v)
|
err = fmt.Errorf("%T no is *cfg.Game_heroLevelup", v)
|
||||||
return
|
return
|
||||||
@ -118,29 +123,12 @@ func (this *Configure_Comp) GetHeroLevelUpCon() (configure *cfg.Game_heroLevelup
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取英雄升级相关配置数据
|
|
||||||
func (this *Configure_Comp) GetHeroLevelUpByLv(lv int32) (data *cfg.Game_heroLevelupData, err error) {
|
|
||||||
|
|
||||||
if v, err1 := this.GetConfigure(game_heroLevelup); err1 == nil {
|
|
||||||
if configure, ok := v.(*cfg.Game_heroLevelup); !ok {
|
|
||||||
err = fmt.Errorf("%T no is *cfg.Game_heroLevelup", v)
|
|
||||||
return
|
|
||||||
|
|
||||||
} else {
|
|
||||||
data = configure.Get(lv)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
err = fmt.Errorf("%T no is *cfg.Game_heroLevelup", v)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *Configure_Comp) GetHeroExpCon() (configure *cfg.Game_heroExp, err error) {
|
func (this *Configure_Comp) GetHeroExpCon() (configure *cfg.Game_heroExp, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
ok bool
|
ok bool
|
||||||
)
|
)
|
||||||
if v, err = this.GetConfigure(game_heroExp); err == nil {
|
if v, err = this.GetConfigure(hero_exp); err == nil {
|
||||||
if configure, ok = v.(*cfg.Game_heroExp); !ok {
|
if configure, ok = v.(*cfg.Game_heroExp); !ok {
|
||||||
err = fmt.Errorf("%T no is *cfg.Game_heroExp", v)
|
err = fmt.Errorf("%T no is *cfg.Game_heroExp", v)
|
||||||
return
|
return
|
||||||
@ -150,21 +138,117 @@ func (this *Configure_Comp) GetHeroExpCon() (configure *cfg.Game_heroExp, err er
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
func (this *Configure_Comp) GetHeroExp(hid int32) *cfg.Game_heroExpData {
|
||||||
|
|
||||||
func (this *Configure_Comp) GetHeroExpConByHeroid(hid int32) (data *cfg.Game_heroExpData, err error) {
|
if v, err := this.GetConfigure(hero_exp); err == nil {
|
||||||
var (
|
|
||||||
v interface{}
|
|
||||||
)
|
|
||||||
if v, err = this.GetConfigure(game_heroExp); err == nil {
|
|
||||||
if configure, ok := v.(*cfg.Game_heroExp); !ok {
|
if configure, ok := v.(*cfg.Game_heroExp); !ok {
|
||||||
err = fmt.Errorf("%T no is *cfg.Game_heroExp", v)
|
err = fmt.Errorf("%T no is *cfg.Game_heroExp", v)
|
||||||
|
return nil
|
||||||
return
|
|
||||||
} else {
|
} else {
|
||||||
data = configure.Get(hid)
|
return configure.Get(hid)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err = fmt.Errorf("%T no is *cfg.Game_heroExp", v)
|
err = fmt.Errorf("%T no is *cfg.Game_heroExp", v)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//英雄等级基础属性
|
||||||
|
func (this *Configure_Comp) GetHeroLevelup() (configure *cfg.Game_heroLevelup, err error) {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
ok bool
|
||||||
|
)
|
||||||
|
if v, err = this.GetConfigure(hero_levelup); err != nil {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
if configure, ok = v.(*cfg.Game_heroLevelup); !ok {
|
||||||
|
err = fmt.Errorf("%T no is *cfg.Game_heroLevelup", v)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//英雄品质系数
|
||||||
|
func (this *Configure_Comp) GetHeroStargrow() (configure *cfg.Game_heroStargrow, err error) {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
ok bool
|
||||||
|
)
|
||||||
|
if v, err = this.GetConfigure(hero_stargrow); err != nil {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
if configure, ok = v.(*cfg.Game_heroStargrow); !ok {
|
||||||
|
err = fmt.Errorf("%T no is *cfg.Game_heroStargrow", v)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取英雄配置
|
||||||
|
func (this *Configure_Comp) GetHero(heroId int32) *cfg.Game_newHeroData {
|
||||||
|
cfg, err := this.getHeroConfigure()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if v, ok := cfg.GetDataMap()[heroId]; ok {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取英雄星级配置
|
||||||
|
func (this *Configure_Comp) GetHeroStar(star int32) *cfg.Game_heroStargrowData {
|
||||||
|
cfg, err := this.GetHeroStargrow()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if v, ok := cfg.GetDataMap()[star]; ok {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取英雄等级配置
|
||||||
|
func (this *Configure_Comp) GetHeroLv(lv int32) *cfg.Game_heroLevelupData {
|
||||||
|
cfg, err := this.GetHeroLevelup()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if v, ok := cfg.GetDataMap()[lv]; ok {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 英雄成长系数
|
||||||
|
func (this *Configure_Comp) GetHeroLevelgrow() (configure *cfg.Game_heroLevelgrow, err error) {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
ok bool
|
||||||
|
)
|
||||||
|
if v, err = this.GetConfigure(hero_levelgrow); err != nil {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
if configure, ok = v.(*cfg.Game_heroLevelgrow); !ok {
|
||||||
|
err = fmt.Errorf("%T no is *cfg.Game_heroLevelgrow", v)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//英雄成长配置
|
||||||
|
func (this *Configure_Comp) GetHeroLvgrow(heroId int32) *cfg.Game_heroLevelgrowData {
|
||||||
|
cfg, err := this.GetHeroLevelgrow()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if v, ok := cfg.GetDataMap()[heroId]; ok {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -36,7 +36,7 @@ func (this *ModelHero) initHero(uid string, heroCfgId int32) *pb.DB_HeroData {
|
|||||||
newHero := &pb.DB_HeroData{
|
newHero := &pb.DB_HeroData{
|
||||||
Id: objId,
|
Id: objId,
|
||||||
Uid: uid,
|
Uid: uid,
|
||||||
HeroID: heroCfg.Id,
|
HeroID: heroCfg.Hid,
|
||||||
Star: heroCfg.Star,
|
Star: heroCfg.Star,
|
||||||
Lv: 1, //初始等级
|
Lv: 1, //初始等级
|
||||||
NormalSkill: []*pb.SkillData{},
|
NormalSkill: []*pb.SkillData{},
|
||||||
|
Loading…
Reference in New Issue
Block a user