package logic //func (this *Player) Charge(chargeTable *data.Charge, logType LogType) error { // var rewardList []*proto.ItemPair // switch proto.ChargeType(chargeTable.Type) { // case proto.ChargeTypeGeneral: // rewardList = this.ChargeGeneral(chargeTable) // // this.AddCounter(proto.CounterTypeCharge, uint32(chargeTable.Id), 1) // case proto.ChargeTypeMonthliCard: // var monthlyCardTable = this.manager.tables.MonthlyCard.Get(chargeTable.Id) // if monthlyCardTable == nil { // this.manager.logger.Errorf("The monthly card table not found, chargeId: %d", chargeTable.Id) // return proto.ErrDataTablesError // } // // rewardList = this.AddMonthlyCard(monthlyCardTable) // case proto.ChargeTypeGiftPack, proto.ChargeTypeStageGiftPack: // var chargeGiftTable = this.manager.tables.ChargeGift.Get(chargeTable.Id) // if chargeGiftTable == nil { // this.manager.logger.Errorf("The charge gift table not found, chargeId: %d", chargeTable.Id) // return proto.ErrDataTablesError // } // // rewardList = this.OpenGiftPack(chargeGiftTable, LogTypeItemObtainByCharge) // // this.AddCounter(proto.CounterTypeCharge, uint32(chargeGiftTable.Id), 1) // case proto.ChargeTypeLimitGiftPack: // var chargeGiftTable = this.manager.tables.ChargeGift.Get(chargeTable.Id) // if chargeGiftTable == nil { // this.manager.logger.Errorf("The charge gift table not found, chargeId: %d", chargeTable.Id) // return proto.ErrDataTablesError // } // // var giftPack = this.GiftPack[uint32(chargeGiftTable.Id)] // if giftPack == nil { // this.manager.logger.Errorf("The gift pack not found, chargeId: %d", chargeTable.Id) // return proto.ErrStoreNotBuyingTime // } // // rewardList = this.OpenGiftPack(chargeGiftTable, LogTypeItemObtainByCharge) // // this.AddCounter(proto.CounterTypeCharge, uint32(chargeGiftTable.Id), 1) // case proto.ChargeTypeBattlePass: // var err = this.activateBattlePassAdvanced() // if err != nil { // return err // } // } // // _ = this.Send(proto.ModIdStore, proto.MsgIdChargeResult, &proto.MsgChargeResultAck{ // ChargeId: uint32(chargeTable.Id), // Result: 1, // Message: this.manager.tables.TipNotice.GetLang(proto.ErrChargeSuccess.Error(), int(this.Role.Language)), // MsgRewardListAck: &proto.MsgRewardListAck{RewardList: rewardList}, // }) // // this.ResetRequestTime(RequestTimeTypeChargeCreateOrder) // // if this.Role.ChargeTime == 0 { // this.manager.serverManager.AddCharges(1) // } // // this.Role.ChargeTime = util.Unix() // this.SaveField("role.charge_time", this.Role.ChargeTime) // // if logType != LogTypeNone { // this.manager.eventManager.PlayerRecharge(this, logType, uint32(chargeTable.Id), uint32(chargeTable.Type), uint32(chargeTable.Quantity), uint32(chargeTable.ItemNum), 0, uint32(chargeTable.TradePrice), util.Unix(), 1) // } // return nil //} // //func (this *Player) ChargeFailed(chargeTable *data.Charge, logType LogType) { // _ = this.Send(proto.ModIdStore, proto.MsgIdChargeResult, &proto.MsgChargeResultAck{ // ChargeId: uint32(chargeTable.Id), // Result: 2, // Message: this.manager.tables.TipNotice.GetLang(proto.ErrChargeFailed.Error(), int(this.Role.Language)), // }) // // this.ResetRequestTime(RequestTimeTypeChargeCreateOrder) // // if logType != LogTypeNone { // this.manager.eventManager.PlayerRecharge(this, logType, uint32(chargeTable.Id), uint32(chargeTable.Type), uint32(chargeTable.Quantity), uint32(chargeTable.ItemNum), 0, uint32(chargeTable.TradePrice), util.Unix(), 2) // } //} // //func (this *Player) ChargeGeneral(chargeTable *data.Charge) []*proto.ItemPair { // var rewardList []*proto.ItemPair // // _ = this.AddItem(uint32(chargeTable.ItemId), uint32(chargeTable.ItemNum), LogTypeItemObtainByCharge) // rewardList = append(rewardList, &proto.ItemPair{ItemId: uint32(chargeTable.ItemId), ItemNum: uint32(chargeTable.ItemNum)}) // // var counter = this.GetCounterTotal(proto.CounterTypeCharge, uint32(chargeTable.Id)) // if counter == 0 { // _ = this.AddItem(uint32(chargeTable.FirstExItemId), uint32(chargeTable.FirstExItemNum), LogTypeItemObtainByChargeFirstExtra) // rewardList = append(rewardList, &proto.ItemPair{ItemId: uint32(chargeTable.FirstExItemId), ItemNum: uint32(chargeTable.FirstExItemNum)}) // } else { // _ = this.AddItem(uint32(chargeTable.ExItemId), uint32(chargeTable.ExItemNum), LogTypeItemObtainByChargeExtra) // rewardList = append(rewardList, &proto.ItemPair{ItemId: uint32(chargeTable.ExItemId), ItemNum: uint32(chargeTable.ExItemNum)}) // } // // return rewardList //} // //func (this *Player) OpenGiftPack(chargeGiftTable *data.ChargeGift, logType LogType) []*proto.ItemPair { // // var dropResult = this.manager.tables.DropExtend.Drop(chargeGiftTable.DropId, 1) // // var rewardList []*proto.ItemPair // for _, itemPair := range dropResult { // _ = this.AddItem(itemPair[0], itemPair[1], logType) // rewardList = append(rewardList, &proto.ItemPair{ItemId: itemPair[0], ItemNum: itemPair[1]}) // } // // this.checkComponentUnlock(2, uint32(chargeGiftTable.Id)) // this.checkCharacterUnlock(2, uint32(chargeGiftTable.Id)) // // return rewardList //}