drop_pool.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. var DropPool = &dropPoolConfig{}
  4. func init() {
  5. _allList = append(_allList, DropPool)
  6. }
  7. type (
  8. DropPoolRow struct {
  9. ID int32 `json:"ID"` // ID
  10. ItemID int32 `json:"ItemID"` // 道具ID
  11. Num int64 `json:"Num"` // 数量
  12. Weight int32 `json:"Weight"` // 权重
  13. }
  14. dropPoolConfig struct {
  15. baseConfig
  16. list []*DropPoolRow // all list
  17. idListMaps map[int32][]*DropPoolRow // key:id
  18. }
  19. )
  20. func (p *dropPoolConfig) Name() string {
  21. return "drop_pool"
  22. }
  23. func (p *dropPoolConfig) Init() {
  24. p.idListMaps = map[int32][]*DropPoolRow{}
  25. }
  26. func (p *dropPoolConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  27. if reload && p.denyLoad {
  28. return 0, nil
  29. }
  30. var list []*DropPoolRow
  31. if err := DecodeData(maps, &list); err != nil {
  32. return 0, err
  33. }
  34. p.list = list
  35. idListMaps := map[int32][]*DropPoolRow{}
  36. for _, row := range list {
  37. idListMaps[row.ID] = append(idListMaps[row.ID], row)
  38. }
  39. p.idListMaps = idListMaps
  40. return len(list), nil
  41. }
  42. // func (p *dropPoolConfig) OnAfterLoad(_ bool) {
  43. // }
  44. func (p *dropPoolConfig) List() []*DropPoolRow {
  45. return p.list
  46. }
  47. func (p *dropPoolConfig) ListByID(id int32) ([]*DropPoolRow, bool) {
  48. value, found := p.idListMaps[id]
  49. return value, found
  50. }
  51. func (p *dropPoolConfig) ListContainID(id int32) bool {
  52. _, found := p.idListMaps[id]
  53. return found
  54. }