91 lines
3.5 KiB
Go
91 lines
3.5 KiB
Go
![]() |
package handler
|
||
|
|
||
|
//func (this *PlayerHandler) AdGetReward(player *logic.Player, msg *net.Message) {
|
||
|
// var req = new(proto.MsgAdGetRewardReq)
|
||
|
// var err = msg.Read(req)
|
||
|
// if err != nil {
|
||
|
// this.logger.Error("Read message failed, ", err)
|
||
|
// _ = player.TipNotice(proto.ErrMessageError)
|
||
|
// return
|
||
|
// }
|
||
|
//
|
||
|
// if req.Id == 0 {
|
||
|
// this.logger.Error("Parameter error, req.Id == 0")
|
||
|
// _ = player.TipNotice(proto.ErrParameterError)
|
||
|
// return
|
||
|
// }
|
||
|
//
|
||
|
// var adTable = this.tables.Ad.Get(int(req.Id))
|
||
|
// if adTable == nil {
|
||
|
// this.logger.Error("Parameter or data error, Table 'Ad' was not found, id: ", req.Id)
|
||
|
// _ = player.TipNotice(proto.ErrDataTablesError)
|
||
|
// return
|
||
|
// }
|
||
|
//
|
||
|
// var counter = player.GetCounterDaily(proto.CounterTypeAdWatching, uint32(adTable.Id))
|
||
|
// if adTable.DailyLimit >= 0 && counter >= uint32(adTable.DailyLimit) {
|
||
|
// this.logger.Error("Daily ad watching times over, counter: ", counter)
|
||
|
// _ = player.TipNotice(proto.ErrTodayTimesOver)
|
||
|
// return
|
||
|
// }
|
||
|
//
|
||
|
// var rewardList []*proto.ItemPair
|
||
|
// switch functionType := proto.AdFunctionType(adTable.FunctionType); functionType {
|
||
|
// case proto.AdFunctionTypeGiftPack, proto.AdFunctionTypeCopy, proto.AdFunctionTypeIdle:
|
||
|
// var counterType = proto.CounterTypeNone
|
||
|
// switch functionType {
|
||
|
// case proto.AdFunctionTypeGiftPack:
|
||
|
// counterType = proto.CounterTypeCharge
|
||
|
// case proto.AdFunctionTypeCopy:
|
||
|
// switch proto.CopyType(adTable.FunctionArg1) {
|
||
|
// case proto.CopyTypeMaterial:
|
||
|
// counterType = proto.CounterTypeCopyMaterial
|
||
|
// case proto.CopyTypeSpeed:
|
||
|
// counterType = proto.CounterTypeCopySpeed
|
||
|
// case proto.CopyTypeArena:
|
||
|
// counterType = proto.CounterTypeCopyArena
|
||
|
// default:
|
||
|
// this.logger.Errorf("Data error, The 'FunctionArg1' of the ad table as to 'CopyType' error, id: %d, functionArg1: %d", adTable.Id, adTable.FunctionArg1)
|
||
|
// _ = player.TipNotice(proto.ErrDataTablesError)
|
||
|
// return
|
||
|
// }
|
||
|
// case proto.AdFunctionTypeIdle:
|
||
|
// counterType = proto.CounterTypeIdleQuickBattle
|
||
|
// }
|
||
|
//
|
||
|
// var functionCounter = int(player.GetCounterDaily(counterType, uint32(adTable.FunctionArg2)))
|
||
|
// if functionCounter > 0 {
|
||
|
// functionCounter -= adTable.FunctionArg3
|
||
|
// if functionCounter < 0 {
|
||
|
// functionCounter = 0
|
||
|
// }
|
||
|
//
|
||
|
// player.SetCounter(counterType, uint32(adTable.FunctionArg2), uint32(functionCounter), true)
|
||
|
// if adTable.DailyLimit > 0 {
|
||
|
// player.AddCounter(proto.CounterTypeAdWatching, uint32(adTable.Id), 1)
|
||
|
// }
|
||
|
// }
|
||
|
// case proto.AdFunctionTypeRadar, proto.AdFunctionTypeSmelt, proto.AdFunctionTypeShopPoolRefresh:
|
||
|
// player.AddAdFunction(adTable)
|
||
|
// case proto.AdFunctionTypeItem:
|
||
|
// if adTable.FunctionArg3 <= 0 {
|
||
|
// this.logger.Error("Data error, Table 'Ad' was not found, functionArg3: ", adTable.FunctionArg3)
|
||
|
// _ = player.TipNotice(proto.ErrDataTablesError)
|
||
|
// return
|
||
|
// }
|
||
|
//
|
||
|
// _ = player.AddItem(uint32(adTable.FunctionArg2), uint32(adTable.FunctionArg3), logic.LogTypeItemObtainByAdReward)
|
||
|
// rewardList = append(rewardList, &proto.ItemPair{ItemId: uint32(adTable.FunctionArg2), ItemNum: uint32(adTable.FunctionArg3)})
|
||
|
//
|
||
|
// if adTable.DailyLimit > 0 {
|
||
|
// player.AddCounter(proto.CounterTypeAdWatching, uint32(adTable.Id), 1)
|
||
|
// }
|
||
|
// default:
|
||
|
// this.logger.Error("Data error, Table 'Ad' was not found, functionType: ", adTable.FunctionType)
|
||
|
// _ = player.TipNotice(proto.ErrDataTablesError)
|
||
|
// return
|
||
|
// }
|
||
|
//
|
||
|
// _ = player.Send(proto.ModIdAd, proto.MsgIdAdGetReward, &proto.MsgAdGetRewardAck{MsgRewardListAck: &proto.MsgRewardListAck{RewardList: rewardList}, Id: req.Id})
|
||
|
//}
|