| | |
| | | import ItemControler
|
| | | import ItemCommon
|
| | | import ShareDefine
|
| | | import DataRecordPack
|
| | | import PlayerCoat
|
| | | import PlayerGatherSoul
|
| | | import PlayerRune
|
| | |
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | pack = IPY_GameWorld.IPY_COpenPackCount()
|
| | | packType = pack.GetPackType()
|
| | | if packType not in ChConfig.Def_Type_CanBuyPack_PlayerDict.keys():
|
| | | return
|
| | | |
| | | buyCount = pack.GetCount()
|
| | | #buyCount = pack.GetCount()
|
| | | __DoOpenPackCount(curPlayer, packType)
|
| | | return
|
| | |
|
| | | #已购买格子数
|
| | | keyName = ChConfig.Def_Type_CanBuyPack_PlayerDict[packType][ChConfig.Def_PlayerPackDict_Index_Key]
|
| | | curGridCnt = curPlayer.NomalDictGetProperty(keyName) |
| | | |
| | | #默认格子数
|
| | | initCnt = ItemCommon.GetPackInitCount(packType)
|
| | | def __DoOpenPackCount(curPlayer, packType):
|
| | | costMoneyTypeDict = IpyGameDataPY.GetFuncEvalCfg("OpenPack", 1, {})
|
| | | costMoneyValueDict = IpyGameDataPY.GetFuncEvalCfg("OpenPack", 2, {})
|
| | | openGridListDict = IpyGameDataPY.GetFuncEvalCfg("OpenPack", 3, {})
|
| | | if str(packType) not in costMoneyTypeDict or str(packType) not in costMoneyValueDict or str(packType) not in openGridListDict:
|
| | | GameWorld.ErrLog("该背包不可购买! packType=%s" % packType)
|
| | | return
|
| | | moneyType = costMoneyTypeDict[str(packType)]
|
| | | costValueList = costMoneyValueDict[str(packType)]
|
| | | openGridList = openGridListDict[str(packType)]
|
| | |
|
| | | curPack = curPlayer.GetItemManager().GetPack(packType)
|
| | | curPackMaxCnt = curPack.GetMaxCount()
|
| | | openAnonCnt = initCnt + curGridCnt + buyCount
|
| | | initCnt = ItemCommon.GetPackInitCount(packType)
|
| | | alreadyOpenCnt = ItemCommon.GetPackOpenItemCnt(curPlayer, packType)
|
| | | canOpenGridCnt = curPackMaxCnt - initCnt - alreadyOpenCnt
|
| | |
|
| | | if curPackMaxCnt < openAnonCnt:
|
| | | nextBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_PackBuyCnt % packType) + 1
|
| | | nextOpenCnt = openGridList[nextBuyCnt - 1] if len(openGridList) >= nextBuyCnt else openGridList[-1]
|
| | | moneyCnt = costValueList[nextBuyCnt - 1] if len(costValueList) >= nextBuyCnt else costValueList[-1]
|
| | | |
| | | if canOpenGridCnt < nextOpenCnt:
|
| | | #数量超过最大格子数
|
| | | GameWorld.DebugLog("购买背包格子,数量超过最大格子数!packType=%s,buyCount=%s" % (packType, buyCount))
|
| | | return
|
| | | |
| | | isBuyOK, costMoneyList = DoOpenGrid(curPlayer, curGridCnt, packType, buyCount)
|
| | | if not isBuyOK:
|
| | | GameWorld.DebugLog("购买背包格子,数量超过最大格子数!packType=%s,initCnt=%s,alreadyOpenCnt=%s,已购买次数=%s,curPackMaxCnt=%s,canOpenGridCnt=%s < %s" |
| | | % (packType, initCnt, alreadyOpenCnt, nextBuyCnt - 1, curPackMaxCnt, canOpenGridCnt, nextOpenCnt))
|
| | | return
|
| | |
|
| | | #fromIndex, toIndex = curGridCnt + 1, curGridCnt + buyCount |
| | | # GameWorld.Log("fromIndex=%s toIndex=%s"%(fromIndex, toIndex))
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, keyName, curGridCnt + buyCount)
|
| | | infoDict = {"BuyCount":nextBuyCnt, ChConfig.Def_Cost_Reason_SonKey:packType}
|
| | | if not PlayerControl.PayMoney(curPlayer, moneyType, moneyCnt, ChConfig.Def_Cost_BuyPack, infoDict, 1):
|
| | | return
|
| | |
|
| | | if packType == IPY_GameWorld.rptItem:
|
| | | #背包刷新
|
| | | PlayerControl.Init_ItemPack(curPlayer)
|
| | | PlayerControl.NotifyCode(curPlayer, "GeRen_liubo_671654")
|
| | | #PlayerControl.SyncOnLineTimeTotal(curPlayer)
|
| | | #PlayerControl.SyncOnLineTimeLastOpenPack(curPlayer, packType)
|
| | | |
| | | |
| | | elif packType == IPY_GameWorld.rptWarehouse:
|
| | | #仓库刷新
|
| | | PlayerControl.Init_Warehouse(curPlayer)
|
| | | |
| | | else:
|
| | | #收纳柜刷新
|
| | | PlayerControl.Init_CabinetCountByType(curPlayer, packType)
|
| | | |
| | | DataRecordPack.DR_OpenPackCount(curPlayer, packType, buyCount, curPlayer.NomalDictGetProperty(keyName))
|
| | | |
| | | if costMoneyList:
|
| | | #消费记录
|
| | | for moneyType, money in costMoneyList:
|
| | | GameWorld.Login_Interface_GoldRec(curPlayer, 0, 1, 'BuyPackGrid', moneyType, money)
|
| | |
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_PackBuyCnt % packType, nextBuyCnt)
|
| | | PlayerControl.Init_PackCount(curPlayer, packType)
|
| | | ItemCommon.SyncPackBuyCnt(curPlayer, packType)
|
| | | return
|
| | |
|
| | | ##开启格子扣道具钻石
|
| | | # @param curPlayer 玩家对象
|
| | | # @param buyMoney 钻石消耗
|
| | | # @param packType 背包类型
|
| | | # @param curPack 物品管理器
|
| | | # @param buyPackMoneyType 货币类型
|
| | | # @param buyCount 购买格子数
|
| | | # @return None 是否购买成功, 玩家是否有钱款
|
| | | def DoOpenGrid(curPlayer, curGridCnt, packType, buyCount):
|
| | | curPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
| | | |
| | | itemId = IpyGameDataPY.GetFuncCfg('OpenBagItem')
|
| | | itemCntFormula = IpyGameDataPY.GetFuncCompileCfg('OpenBagItem', 2)
|
| | | buyMoney = IpyGameDataPY.GetFuncCfg('OpenBagItem', 3)
|
| | | totalItemCnt = 0
|
| | | for index in range(curGridCnt+1, curGridCnt + buyCount+1):
|
| | | itemcnt = eval(itemCntFormula)
|
| | | totalItemCnt += itemcnt
|
| | | |
| | | hasEnough, indexList, findItemIsBind, lackCnt = ItemCommon.GetItem_FromPack_ByID_ExEx(itemId, curPack, totalItemCnt)
|
| | | |
| | | needMoney = lackCnt * buyMoney if not hasEnough else 0
|
| | | |
| | |
|
| | | # 需要付钱
|
| | | costMoneyList = []
|
| | | if needMoney > 0:
|
| | | costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Paper, needMoney)
|
| | | if costMoneyList == []:
|
| | | #金钱不足
|
| | | return False, costMoneyList
|
| | | |
| | | #付款
|
| | | for moneyType, moneyCnt in costMoneyList:
|
| | | infoDict = {"BuyCount":buyCount, ChConfig.Def_Cost_Reason_SonKey:packType}
|
| | | if not PlayerControl.PayMoney(curPlayer, moneyType, moneyCnt, ChConfig.Def_Cost_BuyPack, infoDict, 1):
|
| | | return False, costMoneyList
|
| | | |
| | | # 扣道具
|
| | | delCnt = max(0, totalItemCnt - lackCnt) # 实际扣除的个数
|
| | | if indexList:
|
| | | ItemCommon.ReduceItem(curPlayer, curPack, indexList, delCnt, True)
|
| | | |
| | | return True, costMoneyList
|
| | |
|
| | | #===============================================================================
|
| | | #//A2 04 请求打开远程仓库 #tagCMOpenLongWarehouse
|