英雄礼物配置合并

This commit is contained in:
meixiongfeng 2022-11-21 11:44:27 +08:00
parent 040b9f668d
commit 7b3c4bac66
7 changed files with 42 additions and 132 deletions

View File

@ -1,34 +0,0 @@
[
{
"item_id": "10009",
"favor_num": 5
},
{
"item_id": "10010",
"favor_num": 5
},
{
"item_id": "10011",
"favor_num": 10
},
{
"item_id": "10012",
"favor_num": 10
},
{
"item_id": "10013",
"favor_num": 20
},
{
"item_id": "10014",
"favor_num": 35
},
{
"item_id": "10015",
"favor_num": 50
},
{
"item_id": "10016",
"favor_num": 100
}
]

View File

@ -23,6 +23,8 @@ const (
// 签到 // 签到
game_signreset = "game_signreset.json" game_signreset = "game_signreset.json"
game_sign = "game_sign.json" game_sign = "game_sign.json"
game_item = "game_item.json"
) )
///配置管理基础组件 ///配置管理基础组件
@ -44,7 +46,7 @@ func (this *MCompConfigure) Init(service core.IService, module core.IModule, com
err = this.LoadConfigure(game_facemod, cfg.NewGameFacemod) err = this.LoadConfigure(game_facemod, cfg.NewGameFacemod)
err = this.LoadConfigure(game_signreset, cfg.NewGameSignReset) err = this.LoadConfigure(game_signreset, cfg.NewGameSignReset)
//err = this.LoadConfigure(game_sign, cfg.NewGameSign) //err = this.LoadConfigure(game_sign, cfg.NewGameSign)
err = this.LoadConfigure(game_item, cfg.NewGameItem)
this._dropMap = make(map[int32][]*cfg.GameDropData, 0) this._dropMap = make(map[int32][]*cfg.GameDropData, 0)
this._sign = make(map[int32]*cfg.GameSignData, 0) this._sign = make(map[int32]*cfg.GameSignData, 0)
configure.RegisterConfigure(game_drop, cfg.NewGameDrop, this.LoadDropData) configure.RegisterConfigure(game_drop, cfg.NewGameDrop, this.LoadDropData)
@ -297,3 +299,22 @@ func (this *MCompConfigure) GetHeroConfigData() (data []*cfg.GameHeroData) {
} }
return nil return nil
} }
//读取物品配置
func (this *MCompConfigure) GetItemConfigureData(id string) (item *cfg.GameItemData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_item); err != nil {
log.Errorf("err:%v", err)
return
} else {
if item, ok = v.(*cfg.GameItem).GetDataMap()[id]; !ok {
err = fmt.Errorf("no found item:%s configure", id)
log.Errorf("err:%v", err)
return
}
}
return
}

View File

@ -509,7 +509,7 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex
_data := this.moduleHero.configure.GetHeroLv(curLv) _data := this.moduleHero.configure.GetHeroLv(curLv)
if _data != nil { if _data != nil {
var maxExp int32 var maxExp int32
maxExp = _data.Heroexp
if maxLv <= curLv && curExp >= maxExp { // 加经验之前校验是否达到最大等级 if maxLv <= curLv && curExp >= maxExp { // 加经验之前校验是否达到最大等级
code = pb.ErrorCode_HeroMaxLv code = pb.ErrorCode_HeroMaxLv
return return
@ -520,7 +520,7 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex
curExp = 0 curExp = 0
break break
} }
maxExp = _data.Heroexp
if maxLv <= curLv && curExp >= maxExp { // 设置最大经验和等级 if maxLv <= curLv && curExp >= maxExp { // 设置最大经验和等级
curLv = maxLv curLv = maxLv
curExp = maxExp curExp = maxExp

View File

@ -53,12 +53,14 @@ func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftRe
T: k, T: k,
N: v, N: v,
}) })
expConf := this.configure.GetFavorNum(k)
if expConf == nil { conf, err := this.configure.GetItemConfigureData(k)
code = pb.ErrorCode_ConfigNoFound if err != nil {
this.module.Errorf("err:%v", err)
return return
} }
totalExp += expConf.FavorNum * v
totalExp += conf.SpecialType * v
} }
if code = this.module.CheckRes(session, res); code != pb.ErrorCode_Success { // 道具不够直接返回 if code = this.module.CheckRes(session, res); code != pb.ErrorCode_Success { // 道具不够直接返回
return return

View File

@ -15,7 +15,7 @@ const (
game_libraryhistory = "game_libraryhistory.json" // 往事id 对应的奖励 game_libraryhistory = "game_libraryhistory.json" // 往事id 对应的奖励
game_libraryfavor = "game_libraryfavor.json" // 英雄好感度升级所需的经验 game_libraryfavor = "game_libraryfavor.json" // 英雄好感度升级所需的经验
game_librarystory = "game_librarystory.json" // 羁绊id对应剧情奖励 game_librarystory = "game_librarystory.json" // 羁绊id对应剧情奖励
game_favornum = "game_favornum.json" // 羁绊id对应经验 //game_favornum = "game_favornum.json" // 羁绊id对应经验
) )
///配置管理基础组件 ///配置管理基础组件
@ -33,7 +33,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
game_libraryhistory: cfg.NewGameLibraryHistory, game_libraryhistory: cfg.NewGameLibraryHistory,
game_libraryfavor: cfg.NewGameLibraryFavor, game_libraryfavor: cfg.NewGameLibraryFavor,
game_librarystory: cfg.NewGameLibraryStory, game_librarystory: cfg.NewGameLibraryStory,
game_favornum: cfg.NewGameFavorNum, //game_favornum: cfg.NewGameFavorNum,
}) })
this.fetter = make(map[int64]*cfg.GameLibraryFetterData, 0) this.fetter = make(map[int64]*cfg.GameLibraryFetterData, 0)
@ -143,13 +143,13 @@ func (this *configureComp) GetLibraryStory(fid int32) (data *cfg.GameLibraryStor
} }
// 获取羁绊英雄经验数据 // 获取羁绊英雄经验数据
func (this *configureComp) GetFavorNum(cid string) (data *cfg.GameFavorNumData) { // func (this *configureComp) GetFavorNum(cid string) (data *cfg.GameFavorNumData) {
if v, err := this.GetConfigure(game_favornum); err == nil { // if v, err := this.GetConfigure(game_favornum); err == nil {
if configure, ok := v.(*cfg.GameFavorNum); ok { // if configure, ok := v.(*cfg.GameFavorNum); ok {
data = configure.Get(cid) // data = configure.Get(cid)
} // }
} else { // } else {
log.Errorf("GetLibraryStory conf err:%v", err) // log.Errorf("GetLibraryStory conf err:%v", err)
} // }
return // return
} // }

View File

@ -1,42 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
package cfg
type GameFavorNum struct {
_dataMap map[string]*GameFavorNumData
_dataList []*GameFavorNumData
}
func NewGameFavorNum(_buf []map[string]interface{}) (*GameFavorNum, error) {
_dataList := make([]*GameFavorNumData, 0, len(_buf))
dataMap := make(map[string]*GameFavorNumData)
for _, _ele_ := range _buf {
if _v, err2 := DeserializeGameFavorNumData(_ele_); err2 != nil {
return nil, err2
} else {
_dataList = append(_dataList, _v)
dataMap[_v.ItemId] = _v
}
}
return &GameFavorNum{_dataList:_dataList, _dataMap:dataMap}, nil
}
func (table *GameFavorNum) GetDataMap() map[string]*GameFavorNumData {
return table._dataMap
}
func (table *GameFavorNum) GetDataList() []*GameFavorNumData {
return table._dataList
}
func (table *GameFavorNum) Get(key string) *GameFavorNumData {
return table._dataMap[key]
}

View File

@ -1,37 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
package cfg
import "errors"
type GameFavorNumData struct {
ItemId string
FavorNum int32
}
const TypeId_GameFavorNumData = -1462878034
func (*GameFavorNumData) GetTypeId() int32 {
return -1462878034
}
func (_v *GameFavorNumData)Deserialize(_buf map[string]interface{}) (err error) {
{ var _ok_ bool; if _v.ItemId, _ok_ = _buf["item_id"].(string); !_ok_ { err = errors.New("item_id error"); return } }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["favor_num"].(float64); !_ok_ { err = errors.New("favor_num error"); return }; _v.FavorNum = int32(_tempNum_) }
return
}
func DeserializeGameFavorNumData(_buf map[string]interface{}) (*GameFavorNumData, error) {
v := &GameFavorNumData{}
if err := v.Deserialize(_buf); err == nil {
return v, nil
} else {
return nil, err
}
}