From 7b3c4bac660dab574707fdc2cd351d33a34562f4 Mon Sep 17 00:00:00 2001
From: meixiongfeng <766881921@qq.com>
Date: Mon, 21 Nov 2022 11:44:27 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E7=A4=BC=E7=89=A9=E9=85=8D?=
=?UTF-8?q?=E7=BD=AE=E5=90=88=E5=B9=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
bin/json/game_favornum.json | 34 ------------------
modules/comp_configure.go | 23 +++++++++++-
modules/hero/model_hero.go | 4 +--
modules/library/api_usegift.go | 10 +++---
modules/library/comp_configure.go | 24 ++++++-------
sys/configure/structs/Game.FavorNum.go | 42 ----------------------
sys/configure/structs/Game.FavorNumData.go | 37 -------------------
7 files changed, 42 insertions(+), 132 deletions(-)
delete mode 100644 bin/json/game_favornum.json
delete mode 100644 sys/configure/structs/Game.FavorNum.go
delete mode 100644 sys/configure/structs/Game.FavorNumData.go
diff --git a/bin/json/game_favornum.json b/bin/json/game_favornum.json
deleted file mode 100644
index 431af6fc5..000000000
--- a/bin/json/game_favornum.json
+++ /dev/null
@@ -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
- }
-]
\ No newline at end of file
diff --git a/modules/comp_configure.go b/modules/comp_configure.go
index 0561f265c..899e56fd7 100644
--- a/modules/comp_configure.go
+++ b/modules/comp_configure.go
@@ -23,6 +23,8 @@ const (
// 签到
game_signreset = "game_signreset.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_signreset, cfg.NewGameSignReset)
//err = this.LoadConfigure(game_sign, cfg.NewGameSign)
-
+ err = this.LoadConfigure(game_item, cfg.NewGameItem)
this._dropMap = make(map[int32][]*cfg.GameDropData, 0)
this._sign = make(map[int32]*cfg.GameSignData, 0)
configure.RegisterConfigure(game_drop, cfg.NewGameDrop, this.LoadDropData)
@@ -297,3 +299,22 @@ func (this *MCompConfigure) GetHeroConfigData() (data []*cfg.GameHeroData) {
}
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
+}
diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go
index 2a146fa3c..ae27fda84 100644
--- a/modules/hero/model_hero.go
+++ b/modules/hero/model_hero.go
@@ -509,7 +509,7 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex
_data := this.moduleHero.configure.GetHeroLv(curLv)
if _data != nil {
var maxExp int32
-
+ maxExp = _data.Heroexp
if maxLv <= curLv && curExp >= maxExp { // 加经验之前校验是否达到最大等级
code = pb.ErrorCode_HeroMaxLv
return
@@ -520,7 +520,7 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex
curExp = 0
break
}
- maxExp = _data.Heroexp
+
if maxLv <= curLv && curExp >= maxExp { // 设置最大经验和等级
curLv = maxLv
curExp = maxExp
diff --git a/modules/library/api_usegift.go b/modules/library/api_usegift.go
index 659435ad9..e04380a6e 100644
--- a/modules/library/api_usegift.go
+++ b/modules/library/api_usegift.go
@@ -53,12 +53,14 @@ func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftRe
T: k,
N: v,
})
- expConf := this.configure.GetFavorNum(k)
- if expConf == nil {
- code = pb.ErrorCode_ConfigNoFound
+
+ conf, err := this.configure.GetItemConfigureData(k)
+ if err != nil {
+ this.module.Errorf("err:%v", err)
return
}
- totalExp += expConf.FavorNum * v
+
+ totalExp += conf.SpecialType * v
}
if code = this.module.CheckRes(session, res); code != pb.ErrorCode_Success { // 道具不够直接返回
return
diff --git a/modules/library/comp_configure.go b/modules/library/comp_configure.go
index 30daffc8f..ab2d3328a 100644
--- a/modules/library/comp_configure.go
+++ b/modules/library/comp_configure.go
@@ -15,7 +15,7 @@ const (
game_libraryhistory = "game_libraryhistory.json" // 往事id 对应的奖励
game_libraryfavor = "game_libraryfavor.json" // 英雄好感度升级所需的经验
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_libraryfavor: cfg.NewGameLibraryFavor,
game_librarystory: cfg.NewGameLibraryStory,
- game_favornum: cfg.NewGameFavorNum,
+ //game_favornum: cfg.NewGameFavorNum,
})
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) {
- if v, err := this.GetConfigure(game_favornum); err == nil {
- if configure, ok := v.(*cfg.GameFavorNum); ok {
- data = configure.Get(cid)
- }
- } else {
- log.Errorf("GetLibraryStory conf err:%v", err)
- }
- return
-}
+// func (this *configureComp) GetFavorNum(cid string) (data *cfg.GameFavorNumData) {
+// if v, err := this.GetConfigure(game_favornum); err == nil {
+// if configure, ok := v.(*cfg.GameFavorNum); ok {
+// data = configure.Get(cid)
+// }
+// } else {
+// log.Errorf("GetLibraryStory conf err:%v", err)
+// }
+// return
+// }
diff --git a/sys/configure/structs/Game.FavorNum.go b/sys/configure/structs/Game.FavorNum.go
deleted file mode 100644
index 8d2d981a5..000000000
--- a/sys/configure/structs/Game.FavorNum.go
+++ /dev/null
@@ -1,42 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-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]
-}
-
-
diff --git a/sys/configure/structs/Game.FavorNumData.go b/sys/configure/structs/Game.FavorNumData.go
deleted file mode 100644
index f25a9cc0b..000000000
--- a/sys/configure/structs/Game.FavorNumData.go
+++ /dev/null
@@ -1,37 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-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
- }
-}