map_redeploy.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. var MapRedeploy = &mapRedeployConfig{}
  4. func init() {
  5. _allList = append(_allList, MapRedeploy)
  6. }
  7. type (
  8. MapRedeployRow struct {
  9. ConfigID int32 `json:"ConfigID"` // 配置ID
  10. Level int32 `json:"Level"` // 等级
  11. RedeployLimit int32 `json:"RedeployLimit"` // 调动上限
  12. CanConscript bool `json:"CanConscript"` // 是否可征兵
  13. }
  14. mapRedeployConfig struct {
  15. baseConfig
  16. list []*MapRedeployRow // all list
  17. configIDLevelUniMaps map[int32]map[int32]*MapRedeployRow // key:configID, level
  18. }
  19. )
  20. func (p *mapRedeployConfig) Name() string {
  21. return "map_redeploy"
  22. }
  23. func (p *mapRedeployConfig) Init() {
  24. p.configIDLevelUniMaps = map[int32]map[int32]*MapRedeployRow{}
  25. }
  26. func (p *mapRedeployConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  27. if reload && p.denyLoad {
  28. return 0, nil
  29. }
  30. var list []*MapRedeployRow
  31. if err := DecodeData(maps, &list); err != nil {
  32. return 0, err
  33. }
  34. p.list = list
  35. configIDLevelUniMaps := map[int32]map[int32]*MapRedeployRow{}
  36. for _, row := range list {
  37. itemMap := configIDLevelUniMaps[row.ConfigID]
  38. if itemMap == nil {
  39. itemMap = map[int32]*MapRedeployRow{}
  40. configIDLevelUniMaps[row.ConfigID] = itemMap
  41. }
  42. itemMap[row.Level] = row
  43. }
  44. p.configIDLevelUniMaps = configIDLevelUniMaps
  45. return len(list), nil
  46. }
  47. // func (p *mapRedeployConfig) OnAfterLoad(_ bool) {
  48. // }
  49. func (p *mapRedeployConfig) List() []*MapRedeployRow {
  50. return p.list
  51. }
  52. func (p *mapRedeployConfig) GetByConfigIDLevel(configID int32, level int32) (*MapRedeployRow, bool) {
  53. mapItem, found := p.configIDLevelUniMaps[configID]
  54. if !found {
  55. return nil, false
  56. }
  57. value, found := mapItem[level]
  58. return value, found
  59. }
  60. func (p *mapRedeployConfig) ContainConfigIDLevel(configID int32, level int32) bool {
  61. mapItem, found := p.configIDLevelUniMaps[configID]
  62. if !found {
  63. return false
  64. }
  65. _, found = mapItem[level]
  66. return found
  67. }