ecs/servers/game/logic/player_store_pool.go
2025-06-04 18:17:39 +08:00

110 lines
3.7 KiB
Go

package logic
//type PlayerStorePool struct {
// Type uint32 `bson:"type" key:"1"`
// Id uint32 `bson:"id"`
// NextTime int64 `bson:"next_time"`
// Discount uint32 `bson:"discount"`
// ItemList []uint32 `bson:"item_list"`
//}
//
//func (this *Player) refreshStorePool(storePool *PlayerStorePool, counter *PlayerCounter, manual bool, now int64, poolTable *data.ShopPool) {
// var todaySeconds = (now + util.UTC8TimezoneOffset) % util.DayTotalSeconds
// var refreshSeconds = int64(poolTable.RefreshInterval) * 3600
//
// storePool.NextTime = now - todaySeconds%refreshSeconds + refreshSeconds
// if len(poolTable.Discount) > 0 {
// storePool.Discount = uint32(util.RandomWeights(poolTable.Discount, func(i int) int {
// return poolTable.DiscountWeight[i]
// }))
// }
//
// var exclude = map[int]struct{}{}
//
// storePool.ItemList = nil
// if len(poolTable.IncentivesList) > 0 && poolTable.RefreshIncentives > 0 && counter.Total >= uint32(poolTable.RefreshIncentives) {
// var shopTable = this.manager.tables.Shop.Get(util.RandomSelect(poolTable.IncentivesList, 1)[0])
// if shopTable != nil {
// storePool.ItemList = append(storePool.ItemList, uint32(shopTable.Id))
// exclude[shopTable.Id] = struct{}{}
// }
// if manual {
// counter.Time = now
// counter.Daily += 1
// }
// counter.Total = 0
// } else {
// if manual {
// counter.Time = now
// counter.Daily += 1
// counter.Total += 1
// } else {
// if !poolTable.OnlyManual {
// counter.Total += 1
// }
// }
// }
//
// for len(storePool.ItemList) < poolTable.ItemNum {
// var shopTable = this.manager.tables.ShopExtend.Random(poolTable.ShopType, poolTable.Id, exclude)
// if shopTable == nil {
// break
// }
//
// storePool.ItemList = append(storePool.ItemList, uint32(shopTable.Id))
// exclude[shopTable.Id] = struct{}{}
// }
//}
//
//func (this *Player) RefreshStorePool(storePool *PlayerStorePool, manual bool, now int64, poolTable *data.ShopPool) {
// var counter = this.getCounter(proto.CounterTypeStorePoolRefresh, storePool.Type)
//
// this.refreshStorePool(storePool, counter, manual, now, poolTable)
// this.SaveModel(storePool)
// this.SaveModel(counter)
//
// for _, shopId := range storePool.ItemList {
// this.ResetCounterDaily(proto.CounterTypeStoreBuy, shopId)
// }
//
// _ = this.Send(proto.ModIdStore, proto.MsgIdStorePoolChange, &proto.MsgStorePoolChangeAck{StorePool: storePool.BuildMsgStorePool()})
// _ = this.Send(proto.ModIdCounter, proto.MsgIdCounterChange, &proto.MsgCounterChangeAck{Counter: counter.BuildMsgCounter()})
//}
//
//func (this *PlayerStorePool) BuildMsgStorePool() *proto.StorePool {
// return &proto.StorePool{Type: this.Type, Id: this.Id, NextTime: this.NextTime, Discount: this.Discount, ItemList: this.ItemList}
//}
//
//func (this *Player) copyStorePoolUnlock(sceneId uint32, now int64) {
// for _, poolTables := range this.manager.tables.ShopPoolExtend.Lists() {
// for i := len(poolTables) - 1; i >= 0; i-- {
// var poolTable = poolTables[i]
// if uint32(poolTable.SceneId) > sceneId {
// continue
// }
//
// var storePool = this.StorePool[uint32(poolTable.ShopType)]
// if storePool == nil {
// storePool = &PlayerStorePool{Type: uint32(poolTable.ShopType), Id: uint32(poolTable.Id)}
// this.StorePool[storePool.Type] = storePool
// } else {
// if storePool.Id == uint32(poolTable.Id) {
// break
// }
// storePool.Id = uint32(poolTable.Id)
// }
//
// this.RefreshStorePool(storePool, false, now, poolTable)
// break
// }
// }
//}
//
//func (this *Player) BuildMsgStorePoolListAck() *proto.MsgStorePoolListAck {
// var list []*proto.StorePool
// for _, storePool := range this.StorePool {
// list = append(list, storePool.BuildMsgStorePool())
// }
// return &proto.MsgStorePoolListAck{List: list}
//}