| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- // Code generated by excel export. DO NOT EDIT.
- package data
- import (
- "f1-game/internal/types"
- )
- var ShopGoods = &shopGoodsConfig{}
- func init() {
- _allList = append(_allList, ShopGoods)
- }
- type (
- ShopGoodsRow struct {
- ShopPoolID int32 `json:"ShopPoolID"` // 商品库ID
- GoodsID int32 `json:"GoodsID"` // 商品ID
- BuyCost types.Pair[int32, int32] `json:"BuyCost"` // 购买消耗
- BuyCondition types.Pair[int32, int32] `json:"BuyCondition"` // 购买条件
- BuyLimit int32 `json:"BuyLimit"` // 购买上限
- Rewards types.Pair[int32, int32] `json:"Rewards"` // 购买奖励
- }
- shopGoodsConfig struct {
- baseConfig
- list []*ShopGoodsRow // all list
- shopPoolIDListMaps map[int32][]*ShopGoodsRow // key:shopPoolID
- shopPoolIDGoodsIDUniMaps map[int32]map[int32]*ShopGoodsRow // key:shopPoolID, goodsID
- }
- )
- func (p *shopGoodsConfig) Name() string {
- return "shop_goods"
- }
- func (p *shopGoodsConfig) Init() {
- p.shopPoolIDListMaps = map[int32][]*ShopGoodsRow{}
- p.shopPoolIDGoodsIDUniMaps = map[int32]map[int32]*ShopGoodsRow{}
- }
- func (p *shopGoodsConfig) OnLoad(maps interface{}, reload bool) (int, error) {
- if reload && p.denyLoad {
- return 0, nil
- }
- var list []*ShopGoodsRow
- if err := DecodeData(maps, &list); err != nil {
- return 0, err
- }
- p.list = list
- shopPoolIDListMaps := map[int32][]*ShopGoodsRow{}
- for _, row := range list {
- shopPoolIDListMaps[row.ShopPoolID] = append(shopPoolIDListMaps[row.ShopPoolID], row)
- }
- p.shopPoolIDListMaps = shopPoolIDListMaps
- shopPoolIDGoodsIDUniMaps := map[int32]map[int32]*ShopGoodsRow{}
- for _, row := range list {
- itemMap := shopPoolIDGoodsIDUniMaps[row.ShopPoolID]
- if itemMap == nil {
- itemMap = map[int32]*ShopGoodsRow{}
- shopPoolIDGoodsIDUniMaps[row.ShopPoolID] = itemMap
- }
- itemMap[row.GoodsID] = row
- }
- p.shopPoolIDGoodsIDUniMaps = shopPoolIDGoodsIDUniMaps
- return len(list), nil
- }
- // func (p *shopGoodsConfig) OnAfterLoad(_ bool) {
- // }
- func (p *shopGoodsConfig) List() []*ShopGoodsRow {
- return p.list
- }
- func (p *shopGoodsConfig) ListByShopPoolID(shopPoolID int32) ([]*ShopGoodsRow, bool) {
- value, found := p.shopPoolIDListMaps[shopPoolID]
- return value, found
- }
- func (p *shopGoodsConfig) ListContainShopPoolID(shopPoolID int32) bool {
- _, found := p.shopPoolIDListMaps[shopPoolID]
- return found
- }
- func (p *shopGoodsConfig) GetByShopPoolIDGoodsID(shopPoolID int32, goodsID int32) (*ShopGoodsRow, bool) {
- mapItem, found := p.shopPoolIDGoodsIDUniMaps[shopPoolID]
- if !found {
- return nil, false
- }
- value, found := mapItem[goodsID]
- return value, found
- }
- func (p *shopGoodsConfig) ContainShopPoolIDGoodsID(shopPoolID int32, goodsID int32) bool {
- mapItem, found := p.shopPoolIDGoodsIDUniMaps[shopPoolID]
- if !found {
- return false
- }
- _, found = mapItem[goodsID]
- return found
- }
|