| | |
| | | import ShareDefine
|
| | | import PlayerAttrFruit
|
| | | import DataRecordPack
|
| | | import PyMapTable
|
| | | import ChPyNetSendPack
|
| | | import NetPackCommon
|
| | | import IpyGameDataPY
|
| | |
| | | Def_Discount_ItemType, #折扣卡物品类型
|
| | | Def_SelectMore_ItemType #多选礼包物品类型
|
| | | ) = range(2)
|
| | |
|
| | | #//A3 21 使用特殊运营物品 #tagCMUseSpecialItem
|
| | | #
|
| | | #struct tagCMUseSpecialItem
|
| | | #{
|
| | | # tagHead Head;
|
| | | # BYTE SpeicalItemType; //特殊运营物品类型,0打折卡,1多选礼包
|
| | | # int ItemID; //物品ID
|
| | | # BYTE ItemIndex; //物品在背包中的索引位置
|
| | | # BYTE Select; //选择,只对多选礼包有用 |
| | | #};
|
| | | ## 使用特殊运营物品(封包参数) |
| | | # @param index 玩家索引
|
| | | # @param packData 接收到的封包数据
|
| | | # @param tick 当前时间
|
| | | # @return None
|
| | | def OnUseSpecialItem(index, packData, tick):
|
| | | # #GameWorld.Log("OnUseSpecialItem")
|
| | | # curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | # specialItemType = packData.SpeicalItemType
|
| | | # itemID = packData.ItemID
|
| | | # itemIndex = packData.ItemIndex
|
| | | # selectIndex = packData.Select
|
| | | # |
| | | # curPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
| | | # curItem = curPack.GetAt(itemIndex)
|
| | | # if curItem.GetItemTypeID() != itemID:
|
| | | # GameWorld.Log("使用特殊运营物品失败,物品ID不一致")
|
| | | # return
|
| | | # isBind = curItem.GetIsBind()#继承被使用物品的绑定属性,先记录
|
| | | # itemName = curItem.GetName()
|
| | | # |
| | | # needGold = 0 #需要消耗多少钻石
|
| | | # itemInfoList = []
|
| | | # useMoneyInfo = ""
|
| | | # #如果是打折卡类型
|
| | | # if specialItemType == Def_Discount_ItemType:
|
| | | # #GameWorld.Log("处理打折卡物品类型")
|
| | | # discountItem = ReadChConfig.GetEvalChConfig("DiscountItem")
|
| | | # #GameWorld.Log("读取到的打折卡物品配置信息=%s"%discountItem)
|
| | | # itemSetInfo = discountItem.get(itemID, None)
|
| | | # if not itemSetInfo:
|
| | | # GameWorld.ErrLog("折扣卡,没有找到对应物品的配置信息,物品ID:%s"%itemID)
|
| | | # return
|
| | | # needGold, itemInfo = itemSetInfo
|
| | | # itemInfoList.append(itemInfo)
|
| | | # useMoneyInfo = "UseSpecialItem_Discount"
|
| | | # else:
|
| | | # #GameWorld.Log("处理多选礼包物品类型")
|
| | | # selectMoreItem = ReadChConfig.GetEvalChConfig("SelectMoreItem")
|
| | | # #GameWorld.Log("读取到的多选礼包物品配置信息=%s"%selectMoreItem)
|
| | | # itemSetInfo = selectMoreItem.get(itemID, None)
|
| | | # if not itemSetInfo:
|
| | | # GameWorld.ErrLog("多选礼包,没有找到对应物品的配置信息,物品ID:%s"%itemID)
|
| | | # return
|
| | | # if selectIndex < 0 or selectIndex >= len(itemSetInfo):
|
| | | # GameWorld.ErrLog("多选礼包,选择索引越界,物品ID:%s 选择索引:%s"%(itemID, selectIndex))
|
| | | # return
|
| | | # itemSetInfo = itemSetInfo[selectIndex]
|
| | | # needGold, itemInfoList = itemSetInfo
|
| | | # useMoneyInfo = "UseSpecialItem_SelectMore"
|
| | | # #GameWorld.Log("needGold=%s itemInfoList=%s"%(needGold, itemInfoList))
|
| | | # |
| | | # #钻石不足
|
| | | # if not PlayerControl.HaveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, needGold):
|
| | | # GameWorld.ErrLog("钻石不足")
|
| | | # return
|
| | | # #背包剩余空间
|
| | | # packSpace = ItemControler.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem)
|
| | | # if packSpace < len(itemInfoList):
|
| | | # PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")
|
| | | # GameWorld.ErrLog("背包空间不足")
|
| | | # return
|
| | | # #给物品
|
| | | # for itemInfo in itemInfoList:
|
| | | # newItemId, itemCount, bind, isAppoint = itemInfo
|
| | | # makeItemID = newItemId
|
| | | # #是定制物品
|
| | | # if isAppoint:
|
| | | # appointItemList = PyMapTable.GetPyMapTable("AppointItemList") #定制物品列表
|
| | | # itemData = appointItemList.GetRecord("ItemIndex", str(newItemId))
|
| | | # if not itemData:
|
| | | # GameWorld.ErrLog("使用特殊运营物品 找不到定制物品数据, itemID = %s"%newItemId)
|
| | | # return False
|
| | | # |
| | | # if len(itemData) != 1:
|
| | | # GameWorld.ErrLog("使用特殊运营物品 定制表配置的数据有误, itemID = %s"%newItemId)
|
| | | # return False
|
| | | # |
| | | # itemDictData = itemData[0]
|
| | | # makeItemID = int(itemDictData['ItemID'])
|
| | | # itemCount = 1
|
| | | # itemDictData['IsBind'] = isBind
|
| | | # if not ItemControler.GivePlayerEquip(curPlayer, itemDictData):
|
| | | # GameWorld.ErrLog("使用特殊运营物品 给予定制物品失败")
|
| | | # return
|
| | | # else:
|
| | | # #给予物品
|
| | | # if not ItemControler.GivePlayerItem(curPlayer, newItemId, itemCount, 0, [IPY_GameWorld.rptItem]):
|
| | | # GameWorld.ErrLog("使用特殊运营物品 给予普通物品失败")
|
| | | # return
|
| | | # #PlayerControl.NotifyCode(curPlayer, "ObtainRes01", [makeItemID, itemCount])
|
| | | # |
| | | # #扣除物品
|
| | | # itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
| | | # #扣除物品
|
| | | # ItemCommon.ReduceItem(curPlayer, itemPack, [itemIndex], 1, False)
|
| | | # |
| | | # #扣金钱
|
| | | # addDataDict = {"SpecialItemType":specialItemType, "UseItemID":itemID, "SelectIndex":selectIndex, ChConfig.Def_Cost_Reason_SonKey:itemName}
|
| | | # PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, needGold, ChConfig.Def_Cost_GiftBag, addDataDict)
|
| | | return
|
| | |
|
| | | #// A3 07 过期物品续费 #tagCMItemRenew
|
| | | #
|