上传代码优化

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)
//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 {
if v.A == v1.A && v.T == v1.T {
v.N += v1.N
if _costRes[i].A == v1.A && _costRes[i].T == v1.T {
_costRes[i].N += v1.N
}
}
if v.N < 0 {
v.N = 0
if _costRes[i].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
}
// 玩小游戏增加双倍产出校验

View File

@ -11,90 +11,243 @@ package cfg
import "errors"
type GameNewSmithyData struct {
Id int32
Type int32
DrawingName string
QualityText string
DrawingPng string
BasicDrop int32
BasicCos []*Gameatn
TemperatureCos int32
RefineCos *Gameatn
CustomizedCos1 *Gameatn
CustomizedCos2 *Gameatn
CustomizedLv []int32
CustomizedLvDistribution []int32
LightVelocity int32
Id int32
Type int32
DrawingName string
QualityText string
DrawingPng string
BasicDrop int32
BasicCos []*Gameatn
TemperatureCos int32
RefineCos *Gameatn
CustomizedCos1 *Gameatn
CustomizedCos2 *Gameatn
CustomizedLv []int32
CustomizedLvDistribution []int32
LightVelocity int32
}
const TypeId_GameNewSmithyData = -1249020316
func (*GameNewSmithyData) GetTypeId() int32 {
return -1249020316
return -1249020316
}
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 __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 _ok_ bool
if _arr_, _ok_ = _buf["basic_cos"].([]interface{}); !_ok_ { err = errors.New("basic_cos error"); return }
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 __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 _ok_ bool
if _arr_, _ok_ = _buf["basic_cos"].([]interface{}); !_ok_ {
err = errors.New("basic_cos error")
return
}
_v.BasicCos = make([]*Gameatn, 0, len(_arr_))
for _, _e_ := range _arr_ {
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 } }
_v.BasicCos = append(_v.BasicCos, _list_v_)
}
}
_v.BasicCos = make([]*Gameatn, 0, len(_arr_))
{ 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 _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 _ok_ bool
if _arr_, _ok_ = _buf["customized_lv"].([]interface{}); !_ok_ { err = errors.New("customized_lv error"); return }
for _, _e_ := range _arr_ {
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
}
}
_v.BasicCos = append(_v.BasicCos, _list_v_)
}
}
_v.CustomizedLv = make([]int32, 0, len(_arr_))
for _, _e_ := range _arr_ {
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_) }
_v.CustomizedLv = append(_v.CustomizedLv, _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 _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 _ok_ bool
if _arr_, _ok_ = _buf["customized_lv"].([]interface{}); !_ok_ {
err = errors.New("customized_lv error")
return
}
{
var _arr_ []interface{}
var _ok_ bool
if _arr_, _ok_ = _buf["customized_lv_distribution"].([]interface{}); !_ok_ { err = errors.New("customized_lv_distribution error"); return }
_v.CustomizedLv = make([]int32, 0, len(_arr_))
_v.CustomizedLvDistribution = make([]int32, 0, len(_arr_))
for _, _e_ := range _arr_ {
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_) }
_v.CustomizedLvDistribution = append(_v.CustomizedLvDistribution, _list_v_)
}
}
for _, _e_ := range _arr_ {
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_)
}
_v.CustomizedLv = append(_v.CustomizedLv, _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_) }
return
{
var _arr_ []interface{}
var _ok_ bool
if _arr_, _ok_ = _buf["customized_lv_distribution"].([]interface{}); !_ok_ {
err = errors.New("customized_lv_distribution error")
return
}
_v.CustomizedLvDistribution = make([]int32, 0, len(_arr_))
for _, _e_ := range _arr_ {
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_)
}
_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_)
}
return
}
func DeserializeGameNewSmithyData(_buf map[string]interface{}) (*GameNewSmithyData, error) {
v := &GameNewSmithyData{}
if err := v.Deserialize(_buf); err == nil {
return v, nil
} else {
return nil, err
}
v := &GameNewSmithyData{}
if err := v.Deserialize(_buf); err == nil {
return v, nil
} else {
return nil, err
}
}