package logic //type PlayerGiftPack struct { // Id uint32 `bson:"id" key:"1"` // OpenTime int64 `bson:"open_time"` // CloseTime int64 `bson:"close_time"` // GetTime int64 `bson:"get_time"` // EndTime int64 `bson:"end_time"` // Expired bool `bson:"expired"` //} // //func (this *PlayerGiftPack) BuildMsgLimitGiftPack() *proto.LimitGiftPack { // return &proto.LimitGiftPack{Id: this.Id, OpenTime: this.OpenTime, CloseTime: this.CloseTime, GetTime: this.GetTime, EndTime: this.EndTime} //} // //func (this *Player) checkGiftPackTimeout(now int64) (dirty bool) { // for _, giftPack := range this.GiftPack { // if giftPack.Expired { // continue // } // // if now >= giftPack.EndTime { // giftPack.Expired = true // this.SaveModel(giftPack) // dirty = true // } // } // // if dirty { // _ = this.Send(proto.ModIdStore, proto.MsgIdLimitGiftPackList, this.BuildMsgLimitGiftPackListAck()) // } // return //} // //func (this *Player) checkChapterGiftPack(openType, openArg uint32) bool { // var now = util.Unix() // var giftTables = this.manager.tables.ChargeGiftExtend.List(int(proto.ChargeTypeLimitGiftPack)) // // var list []*proto.LimitGiftPack // for _, giftTable := range giftTables { // if _, ok := this.GiftPack[uint32(giftTable.Id)]; ok { // continue // } // // if uint32(giftTable.OpenType) != openType { // continue // } // // if giftTable.BeginTime > 0 && now < giftTable.BeginTime { // continue // } // // if giftTable.EndTime > 0 && now >= giftTable.EndTime { // continue // } // // if giftTable.OpenArg > 0 && openArg < uint32(giftTable.OpenArg) { // continue // } // // var giftPack = &PlayerGiftPack{ // Id: uint32(giftTable.Id), // OpenTime: giftTable.BeginTime, // CloseTime: giftTable.EndTime, // GetTime: now, // EndTime: now + 3600*int64(giftTable.Duration), // } // // this.GiftPack[giftPack.Id] = giftPack // this.SaveModel(giftPack) // // list = append(list, giftPack.BuildMsgLimitGiftPack()) // } // // if len(list) == 0 { // return false // } // // _ = this.Send(proto.ModIdStore, proto.MsgIdLimitGiftPackList, this.BuildMsgLimitGiftPackListAck()) // return true //} // //func (this *Player) BuildMsgLimitGiftPackListAck() *proto.MsgLimitGiftPackListAck { // var list []*proto.LimitGiftPack // for _, giftPack := range this.GiftPack { // if !giftPack.Expired { // list = append(list, giftPack.BuildMsgLimitGiftPack()) // } // } // return &proto.MsgLimitGiftPackListAck{List: list} //}