| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- // Code generated by excel export. DO NOT EDIT.
- package data
- import (
- "f1-game/internal/enum"
- "f1-game/internal/types"
- )
- var ExchangeSlot = &exchangeSlotConfig{}
- func init() {
- _allList = append(_allList, ExchangeSlot)
- }
- type (
- ExchangeSlotRow struct {
- SlotType enum.ExchangeActType `json:"SlotType"` // 类型
- ExchangeType enum.ExchangeType `json:"ExchangeType"` // 交易所类型
- FreeCount int32 `json:"FreeCount"` // 免费数量
- Cost types.Assets `json:"Cost"` // 解锁消耗
- }
- exchangeSlotConfig struct {
- baseConfig
- list []*ExchangeSlotRow // all list
- slotTypeExchangeTypeUniMaps map[enum.ExchangeActType]map[enum.ExchangeType]*ExchangeSlotRow // key:slotType, exchangeType
- }
- )
- func (p *exchangeSlotConfig) Name() string {
- return "exchange_slot"
- }
- func (p *exchangeSlotConfig) Init() {
- p.slotTypeExchangeTypeUniMaps = map[enum.ExchangeActType]map[enum.ExchangeType]*ExchangeSlotRow{}
- }
- func (p *exchangeSlotConfig) OnLoad(maps interface{}, reload bool) (int, error) {
- if reload && p.denyLoad {
- return 0, nil
- }
- var list []*ExchangeSlotRow
- if err := DecodeData(maps, &list); err != nil {
- return 0, err
- }
- p.list = list
- slotTypeExchangeTypeUniMaps := map[enum.ExchangeActType]map[enum.ExchangeType]*ExchangeSlotRow{}
- for _, row := range list {
- itemMap := slotTypeExchangeTypeUniMaps[row.SlotType]
- if itemMap == nil {
- itemMap = map[enum.ExchangeType]*ExchangeSlotRow{}
- slotTypeExchangeTypeUniMaps[row.SlotType] = itemMap
- }
- itemMap[row.ExchangeType] = row
- }
- p.slotTypeExchangeTypeUniMaps = slotTypeExchangeTypeUniMaps
- return len(list), nil
- }
- // func (p *exchangeSlotConfig) OnAfterLoad(_ bool) {
- // }
- func (p *exchangeSlotConfig) List() []*ExchangeSlotRow {
- return p.list
- }
- func (p *exchangeSlotConfig) GetBySlotTypeExchangeType(slotType enum.ExchangeActType, exchangeType enum.ExchangeType) (*ExchangeSlotRow, bool) {
- mapItem, found := p.slotTypeExchangeTypeUniMaps[slotType]
- if !found {
- return nil, false
- }
- value, found := mapItem[exchangeType]
- return value, found
- }
- func (p *exchangeSlotConfig) ContainSlotTypeExchangeType(slotType enum.ExchangeActType, exchangeType enum.ExchangeType) bool {
- mapItem, found := p.slotTypeExchangeTypeUniMaps[slotType]
- if !found {
- return false
- }
- _, found = mapItem[exchangeType]
- return found
- }
|