item.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. import (
  4. "f1-game/internal/types"
  5. )
  6. var Item = &itemConfig{}
  7. func init() {
  8. _allList = append(_allList, Item)
  9. }
  10. type (
  11. ItemRow struct {
  12. ID int32 `json:"ID"` // ID
  13. ParseType int32 `json:"ParseType"` // 解析类型
  14. ItemSubType int32 `json:"ItemSubType"` // 二级类型
  15. CanUse bool `json:"CanUse"` // 是否可使用
  16. CanSale bool `json:"CanSale"` // 是否可出售
  17. SalePrice types.Assets `json:"SalePrice"` // 出售价格
  18. Quality int32 `json:"Quality"` // 品质
  19. IsBind bool `json:"IsBind"` // 是否绑定
  20. IsMarquee bool `json:"IsMarquee"` // 跑马灯
  21. }
  22. itemConfig struct {
  23. baseConfig
  24. list []*ItemRow // all list
  25. idUniMaps map[int32]*ItemRow // key:id
  26. }
  27. )
  28. func (p *itemConfig) Name() string {
  29. return "item"
  30. }
  31. func (p *itemConfig) Init() {
  32. p.idUniMaps = map[int32]*ItemRow{}
  33. }
  34. func (p *itemConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  35. if reload && p.denyLoad {
  36. return 0, nil
  37. }
  38. var list []*ItemRow
  39. if err := DecodeData(maps, &list); err != nil {
  40. return 0, err
  41. }
  42. p.list = list
  43. idUniMaps := map[int32]*ItemRow{}
  44. for _, row := range list {
  45. idUniMaps[row.ID] = row
  46. }
  47. p.idUniMaps = idUniMaps
  48. return len(list), nil
  49. }
  50. // func (p *itemConfig) OnAfterLoad(_ bool) {
  51. // }
  52. func (p *itemConfig) List() []*ItemRow {
  53. return p.list
  54. }
  55. func (p *itemConfig) GetByID(id int32) (*ItemRow, bool) {
  56. value, found := p.idUniMaps[id]
  57. return value, found
  58. }
  59. func (p *itemConfig) ContainID(id int32) bool {
  60. _, found := p.idUniMaps[id]
  61. return found
  62. }