上传装备回收系数
This commit is contained in:
parent
b3badfd074
commit
8fbbd1e3f8
22
bin/json/game_sellcoefficient.json
Normal file
22
bin/json/game_sellcoefficient.json
Normal 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
|
||||||
|
}
|
||||||
|
]
|
@ -18,6 +18,8 @@ const (
|
|||||||
game_equipcompose = "game_equipcompose.json" //装备锻造
|
game_equipcompose = "game_equipcompose.json" //装备锻造
|
||||||
game_equipattribute = "game_equipattribute.json" //装备技能列表
|
game_equipattribute = "game_equipattribute.json" //装备技能列表
|
||||||
game_equipenchanting = "game_equipenchanting.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_equipcompose, cfg.NewGameEquipSCompose)
|
||||||
this.LoadConfigure(game_equipattribute, cfg.NewGameEquipAttribute)
|
this.LoadConfigure(game_equipattribute, cfg.NewGameEquipAttribute)
|
||||||
this.LoadConfigure(game_equipenchanting, cfg.NewGameEquipEnchanting)
|
this.LoadConfigure(game_equipenchanting, cfg.NewGameEquipEnchanting)
|
||||||
|
this.LoadConfigure(game_sellcoefficient, cfg.NewGameSellCoefficient)
|
||||||
configure.RegisterConfigure(game_equip, cfg.NewGameEquip, func() {
|
configure.RegisterConfigure(game_equip, cfg.NewGameEquip, func() {
|
||||||
this.equiplock.Lock()
|
this.equiplock.Lock()
|
||||||
if v, err := this.GetConfigure(game_equip); err != nil {
|
if v, err := this.GetConfigure(game_equip); err != nil {
|
||||||
@ -282,7 +285,24 @@ func (this *configureComp) getEquipenchanting(id string) (result *cfg.GameEquipE
|
|||||||
} else {
|
} else {
|
||||||
if result, ok = v.(*cfg.GameEquipEnchanting).GetDataMap()[id]; !ok {
|
if result, ok = v.(*cfg.GameEquipEnchanting).GetDataMap()[id]; !ok {
|
||||||
err = fmt.Errorf("on found getEquipenchanting id:%s", id)
|
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
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,6 +235,7 @@ func (this *Equipment) RecycleEquipments(session comm.IUserSession, equs []strin
|
|||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
equipments []*pb.DB_Equipment
|
equipments []*pb.DB_Equipment
|
||||||
|
sellconf *cfg.GameSellCoefficientData
|
||||||
confs []*cfg.GameEquipData
|
confs []*cfg.GameEquipData
|
||||||
sale [][]*cfg.Gameatn
|
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 {
|
if confs[i], err = this.configure.GetEquipmentConfigureById(v.CId); err != nil {
|
||||||
this.Errorln(err)
|
this.Errorln(err)
|
||||||
code = pb.ErrorCode_EquipmentOnFoundEquipment
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if confs[i].SmithySale == nil || len(confs[i].SmithySale) == 0 {
|
if confs[i].SmithySale == nil || len(confs[i].SmithySale) == 0 {
|
||||||
code = pb.ErrorCode_EquipmentNoCanSell
|
code = pb.ErrorCode_EquipmentNoCanSell
|
||||||
return
|
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))
|
sale[i] = make([]*cfg.Gameatn, len(confs[i].Sale))
|
||||||
for n, s := range confs[i].SmithySale {
|
for n, s := range confs[i].SmithySale {
|
||||||
_s := &cfg.Gameatn{
|
_s := &cfg.Gameatn{
|
||||||
A: s.A,
|
A: s.A,
|
||||||
T: s.T,
|
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
|
sale[i][n] = _s
|
||||||
}
|
}
|
||||||
|
42
sys/configure/structs/Game.SellCoefficient.go
Normal file
42
sys/configure/structs/Game.SellCoefficient.go
Normal 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]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
37
sys/configure/structs/Game.SellCoefficientData.go
Normal file
37
sys/configure/structs/Game.SellCoefficientData.go
Normal 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
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user