上传装备回收系数

This commit is contained in:
liwei1dao 2023-03-30 20:45:04 +08:00
parent b3badfd074
commit 8fbbd1e3f8
5 changed files with 130 additions and 3 deletions

View File

@ -0,0 +1,22 @@
[
{
"character": 1,
"coefficient": 1000
},
{
"character": 2,
"coefficient": 1200
},
{
"character": 3,
"coefficient": 1500
},
{
"character": 4,
"coefficient": 2000
},
{
"character": 5,
"coefficient": 3000
}
]

View File

@ -18,6 +18,8 @@ const (
game_equipcompose = "game_equipcompose.json" //装备锻造
game_equipattribute = "game_equipattribute.json" //装备技能列表
game_equipenchanting = "game_equipenchanting.json" //装备附魔
game_sellcoefficient = "game_sellcoefficient.json" //装备出售品质系数
)
///背包配置管理组件
@ -39,6 +41,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
this.LoadConfigure(game_equipcompose, cfg.NewGameEquipSCompose)
this.LoadConfigure(game_equipattribute, cfg.NewGameEquipAttribute)
this.LoadConfigure(game_equipenchanting, cfg.NewGameEquipEnchanting)
this.LoadConfigure(game_sellcoefficient, cfg.NewGameSellCoefficient)
configure.RegisterConfigure(game_equip, cfg.NewGameEquip, func() {
this.equiplock.Lock()
if v, err := this.GetConfigure(game_equip); err != nil {
@ -282,7 +285,24 @@ func (this *configureComp) getEquipenchanting(id string) (result *cfg.GameEquipE
} else {
if result, ok = v.(*cfg.GameEquipEnchanting).GetDataMap()[id]; !ok {
err = fmt.Errorf("on found getEquipenchanting id:%s", id)
this.module.Errorf("err:%v", err)
return
}
}
return
}
//读取装备出售系数配置
func (this *configureComp) getSellcoefficient(id int32) (result *cfg.GameSellCoefficientData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_sellcoefficient); err != nil {
this.module.Errorf("err:%v", err)
return
} else {
if result, ok = v.(*cfg.GameSellCoefficient).GetDataMap()[id]; !ok {
err = fmt.Errorf("on found getSellcoefficient id:%d", id)
return
}
}

View File

@ -235,6 +235,7 @@ func (this *Equipment) RecycleEquipments(session comm.IUserSession, equs []strin
var (
err error
equipments []*pb.DB_Equipment
sellconf *cfg.GameSellCoefficientData
confs []*cfg.GameEquipData
sale [][]*cfg.Gameatn
)
@ -252,19 +253,24 @@ func (this *Equipment) RecycleEquipments(session comm.IUserSession, equs []strin
}
if confs[i], err = this.configure.GetEquipmentConfigureById(v.CId); err != nil {
this.Errorln(err)
code = pb.ErrorCode_EquipmentOnFoundEquipment
code = pb.ErrorCode_ConfigNoFound
return
}
if confs[i].SmithySale == nil || len(confs[i].SmithySale) == 0 {
code = pb.ErrorCode_EquipmentNoCanSell
return
}
if sellconf, err = this.configure.getSellcoefficient(int32(len(v.AdverbEntry))); err != nil {
this.Errorln(err)
code = pb.ErrorCode_ConfigNoFound
return
}
sale[i] = make([]*cfg.Gameatn, len(confs[i].Sale))
for n, s := range confs[i].SmithySale {
_s := &cfg.Gameatn{
A: s.A,
T: s.T,
N: int32(math.Floor(float64(s.N) * float64(discount+1000) / float64(1000))),
N: int32(math.Floor(float64(s.N) * (float64(discount+1000) / float64(1000)) * (float64(sellconf.Coefficient) / float64(1000)))),
}
sale[i][n] = _s
}

View File

@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <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 GameSellCoefficient struct {
_dataMap map[int32]*GameSellCoefficientData
_dataList []*GameSellCoefficientData
}
func NewGameSellCoefficient(_buf []map[string]interface{}) (*GameSellCoefficient, error) {
_dataList := make([]*GameSellCoefficientData, 0, len(_buf))
dataMap := make(map[int32]*GameSellCoefficientData)
for _, _ele_ := range _buf {
if _v, err2 := DeserializeGameSellCoefficientData(_ele_); err2 != nil {
return nil, err2
} else {
_dataList = append(_dataList, _v)
dataMap[_v.Character] = _v
}
}
return &GameSellCoefficient{_dataList:_dataList, _dataMap:dataMap}, nil
}
func (table *GameSellCoefficient) GetDataMap() map[int32]*GameSellCoefficientData {
return table._dataMap
}
func (table *GameSellCoefficient) GetDataList() []*GameSellCoefficientData {
return table._dataList
}
func (table *GameSellCoefficient) Get(key int32) *GameSellCoefficientData {
return table._dataMap[key]
}

View File

@ -0,0 +1,37 @@
//------------------------------------------------------------------------------
// <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 GameSellCoefficientData struct {
Character int32
Coefficient int32
}
const TypeId_GameSellCoefficientData = 46519505
func (*GameSellCoefficientData) GetTypeId() int32 {
return 46519505
}
func (_v *GameSellCoefficientData)Deserialize(_buf map[string]interface{}) (err error) {
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["character"].(float64); !_ok_ { err = errors.New("character error"); return }; _v.Character = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["coefficient"].(float64); !_ok_ { err = errors.New("coefficient error"); return }; _v.Coefficient = int32(_tempNum_) }
return
}
func DeserializeGameSellCoefficientData(_buf map[string]interface{}) (*GameSellCoefficientData, error) {
v := &GameSellCoefficientData{}
if err := v.Deserialize(_buf); err == nil {
return v, nil
} else {
return nil, err
}
}