50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
![]() |
package data
|
||
|
|
||
|
import (
|
||
|
"github.com/oylshe1314/framework/errors"
|
||
|
"sort"
|
||
|
)
|
||
|
|
||
|
func (this *ShopPoolTable) check() error {
|
||
|
for _, d := range this.l {
|
||
|
if len(d.DiscountWeight) != len(d.Discount) {
|
||
|
return errors.Error("incorrect 'ShopPool' table, error: len(d.DiscountWeight) != len(d.Discount), id: ", d.id())
|
||
|
}
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
type ShopPoolTableExtend struct {
|
||
|
*ShopPoolTable
|
||
|
|
||
|
extList [][]*ShopPool
|
||
|
extMap map[int][]*ShopPool
|
||
|
}
|
||
|
|
||
|
func (this *ShopPoolTableExtend) init() error {
|
||
|
if this.ShopPoolTable == nil {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
this.extMap = map[int][]*ShopPool{}
|
||
|
for _, d := range this.l {
|
||
|
this.extMap[d.ShopType] = append(this.extMap[d.ShopType], d)
|
||
|
}
|
||
|
|
||
|
for _, list := range this.extMap {
|
||
|
sort.Slice(list, func(i, j int) bool {
|
||
|
return list[i].SceneId < list[j].SceneId
|
||
|
})
|
||
|
this.extList = append(this.extList, list)
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (this *ShopPoolTableExtend) Lists() [][]*ShopPool {
|
||
|
return this.extList
|
||
|
}
|
||
|
|
||
|
func (this *ShopPoolTableExtend) List(shopType int) []*ShopPool {
|
||
|
return this.extMap[shopType]
|
||
|
}
|