随机掉落逻辑

This commit is contained in:
meixiongfeng 2022-08-18 11:35:47 +08:00
parent bad7c44903
commit 117019a57d
9 changed files with 1000 additions and 33 deletions

756
bin/json/game_drop.json Normal file
View File

@ -0,0 +1,756 @@
[
{
"id": 1,
"dropid": 1001,
"prize": [
{
"a": "equi",
"t": "10001",
"n": 1
}
],
"star": 1,
"p": 333
},
{
"id": 2,
"dropid": 1001,
"prize": [
{
"a": "equi",
"t": "10002",
"n": 1
}
],
"star": 1,
"p": 333
},
{
"id": 3,
"dropid": 1001,
"prize": [
{
"a": "equi",
"t": "10003",
"n": 1
}
],
"star": 1,
"p": 333
},
{
"id": 4,
"dropid": 1002,
"prize": [
{
"a": "equi",
"t": "10004",
"n": 1
}
],
"star": 1,
"p": 333
},
{
"id": 5,
"dropid": 1002,
"prize": [
{
"a": "equi",
"t": "10005",
"n": 1
}
],
"star": 1,
"p": 333
},
{
"id": 6,
"dropid": 1002,
"prize": [
{
"a": "equi",
"t": "10006",
"n": 1
}
],
"star": 1,
"p": 333
},
{
"id": 7,
"dropid": 1003,
"prize": [
{
"a": "equi",
"t": "10011",
"n": 1
}
],
"star": 2,
"p": 333
},
{
"id": 8,
"dropid": 1003,
"prize": [
{
"a": "equi",
"t": "10012",
"n": 1
}
],
"star": 2,
"p": 333
},
{
"id": 9,
"dropid": 1003,
"prize": [
{
"a": "equi",
"t": "10013",
"n": 1
}
],
"star": 2,
"p": 333
},
{
"id": 10,
"dropid": 1004,
"prize": [
{
"a": "equi",
"t": "10014",
"n": 1
}
],
"star": 2,
"p": 333
},
{
"id": 11,
"dropid": 1004,
"prize": [
{
"a": "equi",
"t": "10015",
"n": 1
}
],
"star": 2,
"p": 333
},
{
"id": 12,
"dropid": 1004,
"prize": [
{
"a": "equi",
"t": "10016",
"n": 1
}
],
"star": 2,
"p": 333
},
{
"id": 13,
"dropid": 1005,
"prize": [
{
"a": "equi",
"t": "10021",
"n": 1
}
],
"star": 3,
"p": 333
},
{
"id": 14,
"dropid": 1005,
"prize": [
{
"a": "equi",
"t": "10022",
"n": 1
}
],
"star": 3,
"p": 333
},
{
"id": 15,
"dropid": 1005,
"prize": [
{
"a": "equi",
"t": "10023",
"n": 1
}
],
"star": 3,
"p": 333
},
{
"id": 16,
"dropid": 1006,
"prize": [
{
"a": "equi",
"t": "10024",
"n": 1
}
],
"star": 3,
"p": 333
},
{
"id": 17,
"dropid": 1006,
"prize": [
{
"a": "equi",
"t": "10025",
"n": 1
}
],
"star": 3,
"p": 333
},
{
"id": 18,
"dropid": 1006,
"prize": [
{
"a": "equi",
"t": "10026",
"n": 1
}
],
"star": 3,
"p": 333
},
{
"id": 19,
"dropid": 1007,
"prize": [
{
"a": "equi",
"t": "10031",
"n": 1
}
],
"star": 4,
"p": 333
},
{
"id": 20,
"dropid": 1007,
"prize": [
{
"a": "equi",
"t": "10032",
"n": 1
}
],
"star": 4,
"p": 333
},
{
"id": 21,
"dropid": 1007,
"prize": [
{
"a": "equi",
"t": "10033",
"n": 1
}
],
"star": 4,
"p": 333
},
{
"id": 22,
"dropid": 1008,
"prize": [
{
"a": "equi",
"t": "10034",
"n": 1
}
],
"star": 4,
"p": 333
},
{
"id": 23,
"dropid": 1008,
"prize": [
{
"a": "equi",
"t": "10035",
"n": 1
}
],
"star": 4,
"p": 333
},
{
"id": 24,
"dropid": 1008,
"prize": [
{
"a": "equi",
"t": "10036",
"n": 1
}
],
"star": 4,
"p": 333
},
{
"id": 25,
"dropid": 1009,
"prize": [
{
"a": "equi",
"t": "10041",
"n": 1
}
],
"star": 5,
"p": 333
},
{
"id": 26,
"dropid": 1009,
"prize": [
{
"a": "equi",
"t": "10042",
"n": 1
}
],
"star": 5,
"p": 333
},
{
"id": 27,
"dropid": 1009,
"prize": [
{
"a": "equi",
"t": "10043",
"n": 1
}
],
"star": 5,
"p": 333
},
{
"id": 28,
"dropid": 1010,
"prize": [
{
"a": "equi",
"t": "10044",
"n": 1
}
],
"star": 5,
"p": 333
},
{
"id": 29,
"dropid": 1010,
"prize": [
{
"a": "equi",
"t": "10045",
"n": 1
}
],
"star": 5,
"p": 333
},
{
"id": 30,
"dropid": 1010,
"prize": [
{
"a": "equi",
"t": "10046",
"n": 1
}
],
"star": 5,
"p": 333
},
{
"id": 31,
"dropid": 1011,
"prize": [
{
"a": "equi",
"t": "10051",
"n": 1
}
],
"star": 6,
"p": 333
},
{
"id": 32,
"dropid": 1011,
"prize": [
{
"a": "equi",
"t": "10052",
"n": 1
}
],
"star": 6,
"p": 333
},
{
"id": 33,
"dropid": 1011,
"prize": [
{
"a": "equi",
"t": "10053",
"n": 1
}
],
"star": 6,
"p": 333
},
{
"id": 34,
"dropid": 1012,
"prize": [
{
"a": "equi",
"t": "10054",
"n": 1
}
],
"star": 6,
"p": 333
},
{
"id": 35,
"dropid": 1012,
"prize": [
{
"a": "equi",
"t": "10055",
"n": 1
}
],
"star": 6,
"p": 333
},
{
"id": 36,
"dropid": 1012,
"prize": [
{
"a": "equi",
"t": "10056",
"n": 1
}
],
"star": 6,
"p": 333
},
{
"id": 37,
"dropid": 1013,
"prize": [
{
"a": "equi",
"t": "11001",
"n": 1
}
],
"star": 1,
"p": 333
},
{
"id": 38,
"dropid": 1013,
"prize": [
{
"a": "equi",
"t": "11002",
"n": 1
}
],
"star": 1,
"p": 333
},
{
"id": 39,
"dropid": 1013,
"prize": [
{
"a": "equi",
"t": "11003",
"n": 1
}
],
"star": 1,
"p": 333
},
{
"id": 40,
"dropid": 1014,
"prize": [
{
"a": "equi",
"t": "11004",
"n": 1
}
],
"star": 1,
"p": 1000
},
{
"id": 41,
"dropid": 1015,
"prize": [
{
"a": "equi",
"t": "11005",
"n": 1
}
],
"star": 1,
"p": 1000
},
{
"id": 42,
"dropid": 1016,
"prize": [
{
"a": "equi",
"t": "11006",
"n": 1
}
],
"star": 1,
"p": 1000
},
{
"id": 43,
"dropid": 1017,
"prize": [
{
"a": "equi",
"t": "11011",
"n": 1
}
],
"star": 2,
"p": 1000
},
{
"id": 44,
"dropid": 1018,
"prize": [
{
"a": "equi",
"t": "11012",
"n": 1
}
],
"star": 2,
"p": 1000
},
{
"id": 45,
"dropid": 1019,
"prize": [
{
"a": "equi",
"t": "11013",
"n": 1
}
],
"star": 2,
"p": 1000
},
{
"id": 46,
"dropid": 1020,
"prize": [
{
"a": "equi",
"t": "11014",
"n": 1
}
],
"star": 2,
"p": 1000
},
{
"id": 47,
"dropid": 1021,
"prize": [
{
"a": "equi",
"t": "11015",
"n": 1
}
],
"star": 2,
"p": 1000
},
{
"id": 48,
"dropid": 1022,
"prize": [
{
"a": "equi",
"t": "11016",
"n": 1
}
],
"star": 2,
"p": 1000
},
{
"id": 49,
"dropid": 1023,
"prize": [
{
"a": "equi",
"t": "11021",
"n": 1
}
],
"star": 3,
"p": 1000
},
{
"id": 50,
"dropid": 1024,
"prize": [
{
"a": "equi",
"t": "11022",
"n": 1
}
],
"star": 3,
"p": 1000
},
{
"id": 51,
"dropid": 1025,
"prize": [
{
"a": "equi",
"t": "11023",
"n": 1
}
],
"star": 3,
"p": 1000
},
{
"id": 52,
"dropid": 1026,
"prize": [
{
"a": "equi",
"t": "11024",
"n": 1
}
],
"star": 3,
"p": 1000
},
{
"id": 53,
"dropid": 1027,
"prize": [
{
"a": "equi",
"t": "11025",
"n": 1
}
],
"star": 3,
"p": 1000
},
{
"id": 54,
"dropid": 1028,
"prize": [
{
"a": "equi",
"t": "11026",
"n": 1
}
],
"star": 3,
"p": 1000
},
{
"id": 55,
"dropid": 1029,
"prize": [
{
"a": "equi",
"t": "11031",
"n": 1
}
],
"star": 4,
"p": 1000
},
{
"id": 56,
"dropid": 1030,
"prize": [
{
"a": "equi",
"t": "11032",
"n": 1
}
],
"star": 4,
"p": 333
},
{
"id": 57,
"dropid": 1030,
"prize": [
{
"a": "equi",
"t": "11033",
"n": 1
}
],
"star": 4,
"p": 333
},
{
"id": 58,
"dropid": 1030,
"prize": [
{
"a": "equi",
"t": "11034",
"n": 1
}
],
"star": 4,
"p": 333
}
]

View File

@ -2,6 +2,7 @@
{
"id": 10011,
"type": 1001,
"skill_type": 1,
"initial": 1,
"level": 1,
"levelname": {
@ -13,7 +14,7 @@
"key": "gourmet_ln1",
"text": "魔法厨艺"
},
"needtime": 60,
"needtime": 3600,
"display": 1000,
"probability": 1000,
"icon": "ty_wz_k1",
@ -40,6 +41,7 @@
{
"id": 10012,
"type": 1001,
"skill_type": 1,
"initial": 0,
"level": 2,
"levelname": {
@ -51,7 +53,7 @@
"key": "gourmet_ln2",
"text": "魔法厨艺"
},
"needtime": 120,
"needtime": 7200,
"display": 1000,
"probability": 500,
"icon": "ty_wz_k1",
@ -78,6 +80,7 @@
{
"id": 10013,
"type": 1001,
"skill_type": 1,
"initial": 0,
"level": 3,
"levelname": {
@ -89,7 +92,7 @@
"key": "gourmet_ln3",
"text": "魔法厨艺"
},
"needtime": 240,
"needtime": 14400,
"display": 1000,
"probability": 20,
"icon": "ty_wz_k1",
@ -116,6 +119,7 @@
{
"id": 10014,
"type": 1001,
"skill_type": 1,
"initial": 0,
"level": 4,
"levelname": {
@ -127,7 +131,7 @@
"key": "gourmet_ln4",
"text": "魔法厨艺"
},
"needtime": 480,
"needtime": 28800,
"display": 1000,
"probability": 10,
"icon": "ty_wz_k1",
@ -154,6 +158,7 @@
{
"id": 10021,
"type": 1002,
"skill_type": 1,
"initial": 1,
"level": 1,
"levelname": {
@ -165,7 +170,7 @@
"key": "gourmet_ln1",
"text": "功夫厨艺"
},
"needtime": 60,
"needtime": 3600,
"display": 1000,
"probability": 1000,
"icon": "ty_wz_k1",
@ -192,6 +197,7 @@
{
"id": 10022,
"type": 1002,
"skill_type": 1,
"initial": 0,
"level": 2,
"levelname": {
@ -203,7 +209,7 @@
"key": "gourmet_ln2",
"text": "功夫厨艺"
},
"needtime": 120,
"needtime": 7200,
"display": 1000,
"probability": 500,
"icon": "ty_wz_k1",
@ -230,6 +236,7 @@
{
"id": 10023,
"type": 1002,
"skill_type": 1,
"initial": 0,
"level": 3,
"levelname": {
@ -241,7 +248,7 @@
"key": "gourmet_ln3",
"text": "功夫厨艺"
},
"needtime": 240,
"needtime": 14400,
"display": 1000,
"probability": 20,
"icon": "ty_wz_k1",
@ -268,6 +275,7 @@
{
"id": 10024,
"type": 1002,
"skill_type": 1,
"initial": 0,
"level": 4,
"levelname": {
@ -279,7 +287,7 @@
"key": "gourmet_ln4",
"text": "功夫厨艺"
},
"needtime": 480,
"needtime": 28800,
"display": 1000,
"probability": 10,
"icon": "ty_wz_k1",
@ -306,6 +314,7 @@
{
"id": 10031,
"type": 1003,
"skill_type": 1,
"initial": 1,
"level": 1,
"levelname": {
@ -317,7 +326,7 @@
"key": "gourmet_ln1",
"text": "科技厨艺"
},
"needtime": 60,
"needtime": 3600,
"display": 1000,
"probability": 1000,
"icon": "ty_wz_k1",
@ -344,6 +353,7 @@
{
"id": 10032,
"type": 1003,
"skill_type": 1,
"initial": 0,
"level": 2,
"levelname": {
@ -355,7 +365,7 @@
"key": "gourmet_ln2",
"text": "科技厨艺"
},
"needtime": 120,
"needtime": 7200,
"display": 1000,
"probability": 500,
"icon": "ty_wz_k1",
@ -382,6 +392,7 @@
{
"id": 10033,
"type": 1003,
"skill_type": 1,
"initial": 0,
"level": 3,
"levelname": {
@ -393,7 +404,7 @@
"key": "gourmet_ln3",
"text": "科技厨艺"
},
"needtime": 240,
"needtime": 14400,
"display": 1000,
"probability": 20,
"icon": "ty_wz_k1",
@ -420,6 +431,7 @@
{
"id": 10034,
"type": 1003,
"skill_type": 1,
"initial": 0,
"level": 4,
"levelname": {
@ -431,7 +443,7 @@
"key": "gourmet_ln4",
"text": "科技厨艺"
},
"needtime": 480,
"needtime": 28800,
"display": 1000,
"probability": 10,
"icon": "ty_wz_k1",
@ -458,6 +470,7 @@
{
"id": 10041,
"type": 1004,
"skill_type": 1,
"initial": 1,
"level": 1,
"levelname": {
@ -469,7 +482,7 @@
"key": "gourmet_ln1",
"text": "月能厨艺"
},
"needtime": 60,
"needtime": 3600,
"display": 1000,
"probability": 1000,
"icon": "ty_wz_k1",
@ -496,6 +509,7 @@
{
"id": 10042,
"type": 1004,
"skill_type": 1,
"initial": 0,
"level": 2,
"levelname": {
@ -507,7 +521,7 @@
"key": "gourmet_ln2",
"text": "月能厨艺"
},
"needtime": 120,
"needtime": 7200,
"display": 1000,
"probability": 500,
"icon": "ty_wz_k1",
@ -534,6 +548,7 @@
{
"id": 10043,
"type": 1004,
"skill_type": 1,
"initial": 0,
"level": 3,
"levelname": {
@ -545,7 +560,7 @@
"key": "gourmet_ln3",
"text": "月能厨艺"
},
"needtime": 240,
"needtime": 14400,
"display": 1000,
"probability": 20,
"icon": "ty_wz_k1",
@ -572,6 +587,7 @@
{
"id": 10044,
"type": 1004,
"skill_type": 1,
"initial": 0,
"level": 4,
"levelname": {
@ -583,7 +599,7 @@
"key": "gourmet_ln4",
"text": "月能厨艺"
},
"needtime": 480,
"needtime": 28800,
"display": 1000,
"probability": 10,
"icon": "ty_wz_k1",
@ -610,6 +626,7 @@
{
"id": 10051,
"type": 1005,
"skill_type": 2,
"initial": 1,
"level": 1,
"levelname": {
@ -621,7 +638,7 @@
"key": "gourmet_ln1",
"text": "高效制作"
},
"needtime": -5,
"needtime": -300,
"display": 1000,
"probability": 1000,
"icon": "ty_wz_k1",
@ -642,6 +659,7 @@
{
"id": 10052,
"type": 1005,
"skill_type": 2,
"initial": 0,
"level": 2,
"levelname": {
@ -653,7 +671,7 @@
"key": "gourmet_ln2",
"text": "高效制作"
},
"needtime": -10,
"needtime": -600,
"display": 1000,
"probability": 500,
"icon": "ty_wz_k1",
@ -674,6 +692,7 @@
{
"id": 10053,
"type": 1005,
"skill_type": 2,
"initial": 0,
"level": 3,
"levelname": {
@ -685,7 +704,7 @@
"key": "gourmet_ln3",
"text": "高效制作"
},
"needtime": -15,
"needtime": -900,
"display": 1000,
"probability": 20,
"icon": "ty_wz_k1",
@ -706,6 +725,7 @@
{
"id": 10054,
"type": 1005,
"skill_type": 2,
"initial": 0,
"level": 4,
"levelname": {
@ -717,7 +737,7 @@
"key": "gourmet_ln4",
"text": "高效制作"
},
"needtime": -20,
"needtime": -1200,
"display": 1000,
"probability": 10,
"icon": "ty_wz_k1",

View File

@ -2,8 +2,10 @@ package comm
import (
"context"
"crypto/rand"
"fmt"
"go_dreamfactory/pb"
"math/big"
"reflect"
"go_dreamfactory/lego/core"
@ -85,3 +87,23 @@ func ProtoMarshal(rsp proto.Message, msg *pb.UserMessage) (ok bool) {
msg.Data = any
return true
}
/// 参数 权重数组 返回值 数组下标
func GetRandW(sz []int32) int32 {
if len(sz) > 0 {
var _totalW int64 // 总权重
var _tmpW int64 // 临时权重
for _, v := range sz {
_totalW += int64(v)
}
// 随机权重
n, _ := rand.Int(rand.Reader, big.NewInt(_totalW))
for i, v := range sz {
_tmpW += int64(v)
if n.Int64() < _tmpW {
return int32(i)
}
}
}
return 0
}

View File

@ -13,6 +13,7 @@ import (
const (
game_gourmet = "game_gourmet.json"
game_gourmetskill = "game_gourmetskill.json"
game_drop = "game_drop.json"
)
///配置管理基础组件
@ -22,6 +23,7 @@ type configureComp struct {
modules.MCompConfigure
_gourmetMap map[int64]*cfg.GameGourmetData
_gourmetSkillMap map[int64]*cfg.GameGourmetSkillData
_dropMap map[int32][]*cfg.GameDropData // 掉落表 key 是DiropId
}
//组件初始化接口
@ -58,10 +60,25 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
log.Errorf("get game_pagoda conf err:%v", err)
return
})
this._dropMap = make(map[int32][]*cfg.GameDropData, 0)
configure.RegisterConfigure(game_drop, cfg.NewGameDrop, func() {
if v, err := this.GetConfigure(game_drop); err == nil {
if configure, ok := v.(*cfg.GameDrop); ok {
this.hlock.Lock()
defer this.hlock.Unlock()
for _, value := range configure.GetDataList() {
this._dropMap[value.Dropid] = append(this._dropMap[value.Dropid], value)
}
return
}
}
log.Errorf("get game_pagoda conf err:%v", err)
return
})
// _data := this.GetGourmetConfigData(1002, 4) // 测试配置文件读取
// _dataskill := this.GetGourmetSkillConfigData(1001, 4)
// fmt.Printf("%v,%v", _data, _dataskill)
// _data := this.GetDropData(1001)
// fmt.Printf("%v", _data)
return
}
@ -89,6 +106,22 @@ func (this *configureComp) GetGourmetSkillConfigBySkillID(skillId int) (data *cf
return
}
func (this *configureComp) GetGourmetSkillConfigBySkillType(skillType int) (szSkill []int32) {
szSkill = make([]int32, 0)
if v, err := this.GetConfigure(game_gourmetskill); err == nil {
if configure, ok := v.(*cfg.GameGourmetSkill); ok {
for _, data := range configure.GetDataList() {
if skillType == int(data.SkillType) && data.Initial == 1 {
szSkill = append(szSkill, data.Type)
}
}
//data = configure.Get(int32(skillId))
return
}
}
return
}
//加载多个配置文件
func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err error) {
for k, v := range confs {
@ -105,3 +138,8 @@ func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err
func (this *configureComp) GetConfigure(name string) (v interface{}, err error) {
return configure.GetConfigure(name)
}
func (this *configureComp) GetDropData(dropId int32) (data []*cfg.GameDropData) {
data = this._dropMap[dropId]
return
}

View File

@ -6,6 +6,7 @@ import (
"go_dreamfactory/lego/sys/redis"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
@ -28,14 +29,20 @@ func (this *modelGourmet) getGourmetList(uid string) (result *pb.DBGourmet, err
result = &pb.DBGourmet{}
if err = this.Get(uid, result); err != nil {
if redis.RedisNil != err { // 没有数据直接创建新的数据
result.Id = primitive.NewObjectID().Hex()
result.Uid = uid
result.Skill = make(map[int32]int32, 0)
result.Skill[1001] = 1
result.Skill[1002] = 1
result.Skill[1003] = 1
result.Skill[1004] = 1 // 需要后续查询初始为1 的技能id 临时push
szSkill := this.module.configure.GetGourmetSkillConfigBySkillType(1) // 查表获取初始技能
for _, v := range szSkill {
result.Skill[v] = 1
}
szSpecailSkill := this.module.configure.GetGourmetSkillConfigBySkillType(2) // 高效制作 等通用技能
result.SpecialSkill = make(map[int32]int32, 0)
for _, v := range szSpecailSkill {
result.SpecialSkill[v] = 1
}
result.SpecialSkill[1005] = 1 // 通用技能
if err = this.Add(uid, result); err != nil {
this.module.Errorf("err:%v", err)
@ -53,7 +60,18 @@ func (this *modelGourmet) modifyGourmetDataByObjId(uid string, data map[string]i
}
// todo 调用drop 表 获取掉落信息
func GetDropReward(count, dropId int32) (res []*pb.UserAssets) {
func (this *modelGourmet) GetDropReward(count, dropId int32) (res []*cfg.Gameatn) {
for i := 0; i < int(count); i++ {
data := this.module.configure.GetDropData(dropId)
szW := make([]int32, 0)
for _, value := range data {
szW = append(szW, value.P)
}
index := comm.GetRandW(szW)
res = append(res, data[index].Prize...)
}
return
}
@ -88,8 +106,23 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
for i := 0; i < int(order.FoodCount); i++ {
curTime += _skillCfg.Needtime
order.FoodCount--
gourmet.Items = GetDropReward(_gourmetcfg.Using, _gourmetcfg.Propsgroup)
// 累计时间也减少
res := this.GetDropReward(_gourmetcfg.Using, _gourmetcfg.Propsgroup)
for _, v := range res {
bFind := false
for _, v1 := range gourmet.Items {
if v.A == v1.A && v.T == v1.T {
v1.N += v.N
bFind = true
}
}
if !bFind {
gourmet.Items = append(gourmet.Items, &pb.UserAssets{
A: v.A,
T: v.T,
N: v.N,
})
}
}
if curTime > costTime {
// 转时间戳

View File

@ -557,10 +557,8 @@ func (this *ModelHero) CheckPool(drawCount int32, config *cfg.GameglobalData) (p
return config.BasePool2.P
} else if config.BasePool3.S <= drawCount && config.BasePool3.E >= drawCount {
return config.BasePool3.P
} else {
return config.BasePool4.P
}
return
return config.BasePool4.P
}
// 通数组里的权重随机命中 返回值为数组的下标
@ -576,7 +574,7 @@ func (this *ModelHero) GetRandW(sz []int32) int32 {
n, _ := rand.Int(rand.Reader, big.NewInt(_totalW))
for i, v := range sz {
_tmpW += int64(v)
if n.Int64() < _tmpW { // 种族保底卡池命中
if n.Int64() < _tmpW {
return int32(i)
}
}

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 GameDrop struct {
_dataMap map[int32]*GameDropData
_dataList []*GameDropData
}
func NewGameDrop(_buf []map[string]interface{}) (*GameDrop, error) {
_dataList := make([]*GameDropData, 0, len(_buf))
dataMap := make(map[int32]*GameDropData)
for _, _ele_ := range _buf {
if _v, err2 := DeserializeGameDropData(_ele_); err2 != nil {
return nil, err2
} else {
_dataList = append(_dataList, _v)
dataMap[_v.Id] = _v
}
}
return &GameDrop{_dataList:_dataList, _dataMap:dataMap}, nil
}
func (table *GameDrop) GetDataMap() map[int32]*GameDropData {
return table._dataMap
}
func (table *GameDrop) GetDataList() []*GameDropData {
return table._dataList
}
func (table *GameDrop) Get(key int32) *GameDropData {
return table._dataMap[key]
}

View File

@ -0,0 +1,56 @@
//------------------------------------------------------------------------------
// <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 GameDropData struct {
Id int32
Dropid int32
Prize []*Gameatn
Star int32
P int32
}
const TypeId_GameDropData = 901242325
func (*GameDropData) GetTypeId() int32 {
return 901242325
}
func (_v *GameDropData)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["dropid"].(float64); !_ok_ { err = errors.New("dropid error"); return }; _v.Dropid = int32(_tempNum_) }
{
var _arr_ []interface{}
var _ok_ bool
if _arr_, _ok_ = _buf["prize"].([]interface{}); !_ok_ { err = errors.New("prize error"); return }
_v.Prize = 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.Prize = append(_v.Prize, _list_v_)
}
}
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["star"].(float64); !_ok_ { err = errors.New("star error"); return }; _v.Star = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["p"].(float64); !_ok_ { err = errors.New("p error"); return }; _v.P = int32(_tempNum_) }
return
}
func DeserializeGameDropData(_buf map[string]interface{}) (*GameDropData, error) {
v := &GameDropData{}
if err := v.Deserialize(_buf); err == nil {
return v, nil
} else {
return nil, err
}
}

View File

@ -13,6 +13,7 @@ import "errors"
type GameGourmetSkillData struct {
Id int32
Type int32
SkillType int32
Initial int32
Level int32
Levelname string
@ -37,6 +38,7 @@ func (*GameGourmetSkillData) GetTypeId() int32 {
func (_v *GameGourmetSkillData)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 _tempNum_ float64; if _tempNum_, _ok_ = _buf["skill_type"].(float64); !_ok_ { err = errors.New("skill_type error"); return }; _v.SkillType = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["initial"].(float64); !_ok_ { err = errors.New("initial error"); return }; _v.Initial = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["level"].(float64); !_ok_ { err = errors.New("level error"); return }; _v.Level = int32(_tempNum_) }
{var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["levelname"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.Levelname error"); return }; { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.Levelname, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } }