上传代码优化

This commit is contained in:
liwei1dao 2023-04-01 18:05:44 +08:00
parent 56ef085449
commit b326ec8c32
2 changed files with 235 additions and 76 deletions

View File

@ -118,18 +118,24 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
subAtn := this.module.modelStove.CheckForgeConsume(req.ReelId, stove.Data[req.ReelId].Lv) subAtn := this.module.modelStove.CheckForgeConsume(req.ReelId, stove.Data[req.ReelId].Lv)
//costRes = append(costRes, subAtn...) //costRes = append(costRes, subAtn...)
// 异常处理 防止不消耗该道具 但是技能做了该道具的减免 // 异常处理 防止不消耗该道具 但是技能做了该道具的减免
for _, v := range costRes { _costRes := make([]*cfg.Gameatn, len(costRes))
for i, v := range costRes {
_costRes[i] = &cfg.Gameatn{
A: v.A,
T: v.T,
N: v.N,
}
for _, v1 := range subAtn { for _, v1 := range subAtn {
if v.A == v1.A && v.T == v1.T { if _costRes[i].A == v1.A && _costRes[i].T == v1.T {
v.N += v1.N _costRes[i].N += v1.N
} }
} }
if v.N < 0 { if _costRes[i].N < 0 {
v.N = 0 _costRes[i].N = 0
} }
} }
if code = this.module.ConsumeRes(session, costRes, true); code != pb.ErrorCode_Success { if code = this.module.ConsumeRes(session, _costRes, true); code != pb.ErrorCode_Success {
return return
} }
// 玩小游戏增加双倍产出校验 // 玩小游戏增加双倍产出校验

View File

@ -34,40 +34,174 @@ func (*GameNewSmithyData) GetTypeId() int32 {
} }
func (_v *GameNewSmithyData) Deserialize(_buf map[string]interface{}) (err error) { func (_v *GameNewSmithyData) Deserialize(_buf map[string]interface{}) (err error) {
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) } {
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["type"].(float64); !_ok_ { err = errors.New("type error"); return }; _v.Type = int32(_tempNum_) } var _ok_ bool
{var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["drawing_name"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.DrawingName error"); return }; { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.DrawingName, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } } var _tempNum_ float64
{var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["quality_text"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.QualityText error"); return }; { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.QualityText, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } } if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ {
{ var _ok_ bool; if _v.DrawingPng, _ok_ = _buf["drawing_png"].(string); !_ok_ { err = errors.New("drawing_png error"); return } } err = errors.New("id error")
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["basic_drop"].(float64); !_ok_ { err = errors.New("basic_drop error"); return }; _v.BasicDrop = int32(_tempNum_) } return
}
_v.Id = int32(_tempNum_)
}
{
var _ok_ bool
var _tempNum_ float64
if _tempNum_, _ok_ = _buf["type"].(float64); !_ok_ {
err = errors.New("type error")
return
}
_v.Type = int32(_tempNum_)
}
{
var _ok_ bool
var __json_text__ map[string]interface{}
if __json_text__, _ok_ = _buf["drawing_name"].(map[string]interface{}); !_ok_ {
err = errors.New("_v.DrawingName error")
return
}
{
var _ok_ bool
if _, _ok_ = __json_text__["key"].(string); !_ok_ {
err = errors.New("key error")
return
}
}
{
var _ok_ bool
if _v.DrawingName, _ok_ = __json_text__["text"].(string); !_ok_ {
err = errors.New("text error")
return
}
}
}
{
var _ok_ bool
var __json_text__ map[string]interface{}
if __json_text__, _ok_ = _buf["quality_text"].(map[string]interface{}); !_ok_ {
err = errors.New("_v.QualityText error")
return
}
{
var _ok_ bool
if _, _ok_ = __json_text__["key"].(string); !_ok_ {
err = errors.New("key error")
return
}
}
{
var _ok_ bool
if _v.QualityText, _ok_ = __json_text__["text"].(string); !_ok_ {
err = errors.New("text error")
return
}
}
}
{
var _ok_ bool
if _v.DrawingPng, _ok_ = _buf["drawing_png"].(string); !_ok_ {
err = errors.New("drawing_png error")
return
}
}
{
var _ok_ bool
var _tempNum_ float64
if _tempNum_, _ok_ = _buf["basic_drop"].(float64); !_ok_ {
err = errors.New("basic_drop error")
return
}
_v.BasicDrop = int32(_tempNum_)
}
{ {
var _arr_ []interface{} var _arr_ []interface{}
var _ok_ bool var _ok_ bool
if _arr_, _ok_ = _buf["basic_cos"].([]interface{}); !_ok_ { err = errors.New("basic_cos error"); return } if _arr_, _ok_ = _buf["basic_cos"].([]interface{}); !_ok_ {
err = errors.New("basic_cos error")
return
}
_v.BasicCos = make([]*Gameatn, 0, len(_arr_)) _v.BasicCos = make([]*Gameatn, 0, len(_arr_))
for _, _e_ := range _arr_ { for _, _e_ := range _arr_ {
var _list_v_ *Gameatn var _list_v_ *Gameatn
{ var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ { err = errors.New("_list_v_ error"); return }; if _list_v_, err = DeserializeGameatn(_x_); err != nil { return } } {
var _ok_ bool
var _x_ map[string]interface{}
if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ {
err = errors.New("_list_v_ error")
return
}
if _list_v_, err = DeserializeGameatn(_x_); err != nil {
return
}
}
_v.BasicCos = append(_v.BasicCos, _list_v_) _v.BasicCos = append(_v.BasicCos, _list_v_)
} }
} }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["temperature_cos"].(float64); !_ok_ { err = errors.New("temperature_cos error"); return }; _v.TemperatureCos = int32(_tempNum_) } {
{ var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["refine_cos"].(map[string]interface{}); !_ok_ { err = errors.New("refine_cos error"); return }; if _v.RefineCos, err = DeserializeGameatn(_x_); err != nil { return } } var _ok_ bool
{ var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["customized_cos1"].(map[string]interface{}); !_ok_ { err = errors.New("customized_cos1 error"); return }; if _v.CustomizedCos1, err = DeserializeGameatn(_x_); err != nil { return } } var _tempNum_ float64
{ var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["customized_cos2"].(map[string]interface{}); !_ok_ { err = errors.New("customized_cos2 error"); return }; if _v.CustomizedCos2, err = DeserializeGameatn(_x_); err != nil { return } } if _tempNum_, _ok_ = _buf["temperature_cos"].(float64); !_ok_ {
err = errors.New("temperature_cos error")
return
}
_v.TemperatureCos = int32(_tempNum_)
}
{
var _ok_ bool
var _x_ map[string]interface{}
if _x_, _ok_ = _buf["refine_cos"].(map[string]interface{}); !_ok_ {
err = errors.New("refine_cos error")
return
}
if _v.RefineCos, err = DeserializeGameatn(_x_); err != nil {
return
}
}
{
var _ok_ bool
var _x_ map[string]interface{}
if _x_, _ok_ = _buf["customized_cos1"].(map[string]interface{}); !_ok_ {
err = errors.New("customized_cos1 error")
return
}
if _v.CustomizedCos1, err = DeserializeGameatn(_x_); err != nil {
return
}
}
{
var _ok_ bool
var _x_ map[string]interface{}
if _x_, _ok_ = _buf["customized_cos2"].(map[string]interface{}); !_ok_ {
err = errors.New("customized_cos2 error")
return
}
if _v.CustomizedCos2, err = DeserializeGameatn(_x_); err != nil {
return
}
}
{ {
var _arr_ []interface{} var _arr_ []interface{}
var _ok_ bool var _ok_ bool
if _arr_, _ok_ = _buf["customized_lv"].([]interface{}); !_ok_ { err = errors.New("customized_lv error"); return } if _arr_, _ok_ = _buf["customized_lv"].([]interface{}); !_ok_ {
err = errors.New("customized_lv error")
return
}
_v.CustomizedLv = make([]int32, 0, len(_arr_)) _v.CustomizedLv = make([]int32, 0, len(_arr_))
for _, _e_ := range _arr_ { for _, _e_ := range _arr_ {
var _list_v_ int32 var _list_v_ int32
{ var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } {
var _ok_ bool
var _x_ float64
if _x_, _ok_ = _e_.(float64); !_ok_ {
err = errors.New("_list_v_ error")
return
}
_list_v_ = int32(_x_)
}
_v.CustomizedLv = append(_v.CustomizedLv, _list_v_) _v.CustomizedLv = append(_v.CustomizedLv, _list_v_)
} }
} }
@ -75,18 +209,37 @@ func (_v *GameNewSmithyData)Deserialize(_buf map[string]interface{}) (err error)
{ {
var _arr_ []interface{} var _arr_ []interface{}
var _ok_ bool var _ok_ bool
if _arr_, _ok_ = _buf["customized_lv_distribution"].([]interface{}); !_ok_ { err = errors.New("customized_lv_distribution error"); return } if _arr_, _ok_ = _buf["customized_lv_distribution"].([]interface{}); !_ok_ {
err = errors.New("customized_lv_distribution error")
return
}
_v.CustomizedLvDistribution = make([]int32, 0, len(_arr_)) _v.CustomizedLvDistribution = make([]int32, 0, len(_arr_))
for _, _e_ := range _arr_ { for _, _e_ := range _arr_ {
var _list_v_ int32 var _list_v_ int32
{ var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } {
var _ok_ bool
var _x_ float64
if _x_, _ok_ = _e_.(float64); !_ok_ {
err = errors.New("_list_v_ error")
return
}
_list_v_ = int32(_x_)
}
_v.CustomizedLvDistribution = append(_v.CustomizedLvDistribution, _list_v_) _v.CustomizedLvDistribution = append(_v.CustomizedLvDistribution, _list_v_)
} }
} }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["light_velocity"].(float64); !_ok_ { err = errors.New("light_velocity error"); return }; _v.LightVelocity = int32(_tempNum_) } {
var _ok_ bool
var _tempNum_ float64
if _tempNum_, _ok_ = _buf["light_velocity"].(float64); !_ok_ {
err = errors.New("light_velocity error")
return
}
_v.LightVelocity = int32(_tempNum_)
}
return return
} }