| | |
| | | import PlayerControl
|
| | | import ItemCommon
|
| | | import ShareDefine
|
| | | import DataRecordPack
|
| | | import EventSrc
|
| | | import PlayerFlashSale
|
| | | #import EventSrc
|
| | | import ChItem
|
| | | import IpyGameDataPY
|
| | | import PlayerRune
|
| | | import PlayerSuccess
|
| | | import GameFuncComm
|
| | | import PlayerFairyCeremony
|
| | | import PlayerNewFairyCeremony
|
| | | import PlayerSpringSale
|
| | | import PyGameData
|
| | |
|
| | | import random
|
| | | import math
|
| | | import time
|
| | |
|
| | | # 商店类型定义
|
| | | ShopType_FairyCeremony = 19 # 仙界盛典烟花
|
| | |
|
| | | g_mysticalShopDict = {} #神秘商店{等级范围:[等级段,{金钱类型:库}]}
|
| | | #---------------------------------------------------------------------
|
| | | ##开始交易
|
| | | # @param curPlayer 玩家实例
|
| | |
| | | return
|
| | |
|
| | | ## 登录
|
| | | def ShopItemOnLogin(curPlayer):
|
| | | def ShopItemOnLogin(curPlayer): |
| | | SyncMysticalLimitShopInfo(curPlayer)
|
| | | SyncShopItemTodayBuyCount(curPlayer)
|
| | | if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopGoods % 0):
|
| | | __DoMysticalShopRefresh(curPlayer, True, GameWorld.GetGameWorld().GetTick())
|
| | | SyncMysticalShopInfo(curPlayer)
|
| | | return
|
| | |
|
| | | ##商店物品OnDay
|
| | |
| | | # @return
|
| | | def ShopItemOnDay(curPlayer, onEventType):
|
| | | if onEventType == ShareDefine.Def_OnEventType:
|
| | | OSSaleOpenMail(curPlayer)
|
| | | refreshType = [3]
|
| | | #神秘商店刷新次数重置
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MysticalShopRefreshCnt, 0)
|
| | | SyncMysticalShopInfo(curPlayer)
|
| | | |
| | | elif onEventType == ShareDefine.Def_OnEventTypeEx:
|
| | | refreshType = [4]
|
| | | openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)
|
| | | if openServerDay % 3 == 0:
|
| | | refreshType = [4,7]
|
| | | isMixServer = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_IsMixServer)
|
| | | if isMixServer:
|
| | | mixServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_MixServerDay)
|
| | | if mixServerDay % 3 == 0:
|
| | | refreshType.append(7)
|
| | | elif openServerDay % 3 == 0:
|
| | | refreshType.append(7)
|
| | | else:
|
| | | return
|
| | | __ResetShopItemBuyCount(curPlayer, refreshType)
|
| | | ResetShopItemBuyCount(curPlayer, refreshType)
|
| | | return
|
| | |
|
| | | ##商店物品OnWeek
|
| | | # @param curPlayer 玩家实例
|
| | | # @return
|
| | | def ShopItemOnWeek(curPlayer, onEventType):
|
| | | __ResetShopItemBuyCount(curPlayer, [onEventType])
|
| | | if onEventType == ShareDefine.Def_OnEventType:
|
| | | refreshType = [1]
|
| | | elif onEventType == ShareDefine.Def_OnEventTypeEx:
|
| | | refreshType = [2]
|
| | | else:
|
| | | return
|
| | | ResetShopItemBuyCount(curPlayer, refreshType)
|
| | | return
|
| | |
|
| | | ##商店物品OnMonth
|
| | |
| | | refreshType = 6
|
| | | else:
|
| | | return
|
| | | __ResetShopItemBuyCount(curPlayer, [refreshType])
|
| | | ResetShopItemBuyCount(curPlayer, [refreshType])
|
| | | return
|
| | |
|
| | | def __ResetShopItemBuyCount(curPlayer, onEventTypeList):
|
| | | #重置商店物品购买次数 1:周一0点刷新 2:周一5点刷新 3:每日0点刷新 4:每日5点刷新 5每月0点 6每月5点
|
| | | def ShopItemOnCrossPKSeasonChange(curPlayer):
|
| | | ## 按跨服PK赛季重置
|
| | | refreshType = 8
|
| | | ResetShopItemBuyCount(curPlayer, [refreshType])
|
| | | return
|
| | |
|
| | | def ResetShopItemBuyCount(curPlayer, resetTypeList):
|
| | | #@param resetTypeList: 需要重置的类型列表
|
| | | #重置商店物品购买次数 1:周一0点刷新 2:周一5点刷新 3:每日0点刷新 4:每日5点刷新 5每月0点 6每月5点 7每3天5点 8每赛季
|
| | | if not resetTypeList:
|
| | | # 暂定必须指定类型列表,防止终身限购的误被重置
|
| | | return
|
| | | |
| | | syncIndexList = []
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | for i in xrange(ipyDataMgr.GetStoreCount()):
|
| | | shopItem = ipyDataMgr.GetStoreByIndex(i)
|
| | | if not shopItem.GetLimitCnt():
|
| | | continue
|
| | | if shopItem.GetRefreshType() not in onEventTypeList:
|
| | | if shopItem.GetRefreshType() not in resetTypeList:
|
| | | continue
|
| | | dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % shopItem.GetID()
|
| | | curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey)
|
| | |
| | | syncIndexList.append(shopItem.GetID())
|
| | | if syncIndexList:
|
| | | SyncShopItemTodayBuyCount(curPlayer, syncIndexList, True)
|
| | | return
|
| | |
|
| | | def MysticalLimitShopOpen(curPlayer, befLV, aftLV):
|
| | | ##神秘限购开启
|
| | | ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('Store', {'ShopType':16}, True)
|
| | | if not ipyDataList:
|
| | | return
|
| | | curTime = int(time.time())
|
| | | syncGoodsList = []
|
| | | for ipyData in ipyDataList:
|
| | | limitLV = ipyData.GetLimitLV()
|
| | | if befLV < limitLV and aftLV >= limitLV:
|
| | | goodsID = ipyData.GetID()
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ShopItemStartTime % goodsID, curTime)
|
| | | syncGoodsList.append(goodsID)
|
| | | GameWorld.DebugLog('神秘限购商品%s 开卖'%goodsID, curPlayer.GetID())
|
| | | if syncGoodsList:
|
| | | SyncMysticalLimitShopInfo(curPlayer)
|
| | | return
|
| | |
|
| | | def SyncMysticalLimitShopInfo(curPlayer):
|
| | | ##神秘限购通知
|
| | | packData = ChPyNetSendPack.tagMCMysticalShopTimeInfo()
|
| | | packData.ShopTimeList = []
|
| | | ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('Store', {'ShopType':16}, True)
|
| | | curTime = int(time.time())
|
| | | for ipyData in ipyDataList:
|
| | | goodsID = ipyData.GetID()
|
| | | startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopItemStartTime % goodsID)
|
| | | if not startTime:
|
| | | continue
|
| | | if curTime - startTime >= ipyData.GetLimitValue():
|
| | | #超时的重置
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ShopItemStartTime % goodsID, 0)
|
| | | else:
|
| | | goodsTime = ChPyNetSendPack.tagMCMysticalShopTime()
|
| | | goodsTime.GoodsID = goodsID
|
| | | goodsTime.StartTime = startTime
|
| | | packData.ShopTimeList.append(goodsTime)
|
| | | if not packData.ShopTimeList:
|
| | | return
|
| | | packData.Count = len(packData.ShopTimeList)
|
| | | NetPackCommon.SendFakePack(curPlayer, packData)
|
| | | return
|
| | |
|
| | | def CheckMysticalShopRefresh(curPlayer, tick):
|
| | | ##神秘商店刷新
|
| | | createRoleTime = curPlayer.GetCreateRoleTime()
|
| | | diffTime = GameWorld.GetCurrentTime() - GameWorld.GetDateTimeByStr(createRoleTime, ChConfig.TYPE_Time_Format)
|
| | | pastSeconds = diffTime.days*24*60*60 + diffTime.seconds
|
| | | refreshTime = IpyGameDataPY.GetFuncCfg('MysteryShopRefresh', 4)
|
| | | if refreshTime and pastSeconds % refreshTime == 0:
|
| | | __DoMysticalShopRefresh(curPlayer, True, tick)
|
| | | return
|
| | |
|
| | | #// A2 32 神秘商店刷新 #tagCMRefreshMysticalShop
|
| | | #struct tagCMRefreshMysticalShop
|
| | | #{
|
| | | # tagHead Head;
|
| | | #};
|
| | | def OnMysticalShopRefresh(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | __DoMysticalShopRefresh(curPlayer, False, tick)
|
| | | return
|
| | |
|
| | | def __DoMysticalShopRefresh(curPlayer, isFree, tick):
|
| | | global g_mysticalShopDict #{等级范围:[等级段,{金钱类型:库}]}
|
| | | refreshTime = IpyGameDataPY.GetFuncCfg('MysteryShopRefresh', 4)
|
| | | if not refreshTime:
|
| | | return
|
| | |
|
| | | lastTime = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_MysticalShopLastTime)
|
| | | if lastTime and tick - lastTime < 1000:
|
| | | #GameWorld.DebugLog('神秘商店刷新,过于频繁!')
|
| | | return
|
| | | curPlayer.SetDict(ChConfig.Def_PlayerKey_MysticalShopLastTime, tick)
|
| | | if not g_mysticalShopDict:
|
| | | ipyMgr= IpyGameDataPY.IPY_Data()
|
| | | for i in xrange(ipyMgr.GetMysteryShopCount()):
|
| | | ipyData = ipyMgr.GetMysteryShopByIndex(i)
|
| | | lvRange = ipyData.GetLVRange()
|
| | | goodsID = ipyData.GetGoodsID()
|
| | | goodsIpyData = IpyGameDataPY.GetIpyGameData('Store', goodsID)
|
| | | if not goodsIpyData:
|
| | | continue
|
| | | moneyType = goodsIpyData.GetMoneyType()
|
| | | weight = goodsIpyData.GetLimitValue()
|
| | | lvkey = tuple(lvRange)
|
| | | if lvkey not in g_mysticalShopDict:
|
| | | g_mysticalShopDict[lvkey] = [lvkey[0], {}]
|
| | | weightDict = {}
|
| | | if moneyType not in g_mysticalShopDict[lvkey][1]:
|
| | | g_mysticalShopDict[lvkey][1][moneyType] = []
|
| | | weightDict[moneyType] = weightDict.get(moneyType, 0) + weight
|
| | | g_mysticalShopDict[lvkey][1][moneyType].append([weightDict[moneyType], goodsID])
|
| | | if not g_mysticalShopDict:
|
| | | return |
| | | playerLV = curPlayer.GetLV()
|
| | | curLVDan, shopDict = GameWorld.GetDictValueByRangeKey(g_mysticalShopDict, playerLV)
|
| | | if not shopDict:
|
| | | return
|
| | | maxCnt = IpyGameDataPY.GetFuncCfg('MysteryShopGoods', 1)
|
| | | goldGoodsCnt =GameWorld.GetResultByRandomList(IpyGameDataPY.GetFuncEvalCfg('MysteryShopGoods', 2))
|
| | | if not goldGoodsCnt:
|
| | | return
|
| | | specialGoodsID = 0 #必出的商品ID
|
| | | if not isFree:
|
| | | #优先道具,再仙玉
|
| | | itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
| | | costItemID = IpyGameDataPY.GetFuncCfg('MysteryShopRefresh', 1)
|
| | | costItemCntDict = IpyGameDataPY.GetFuncEvalCfg('MysteryShopRefresh', 2)
|
| | | curRefreshCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopRefreshCnt)
|
| | | cntList = [int(cnt) for cnt in costItemCntDict.keys()]
|
| | | cntList.sort()
|
| | | costItemCnt = costItemCntDict[str(cntList[-1])]
|
| | | for cnt in cntList:
|
| | | if curRefreshCnt < cnt:
|
| | | costItemCnt = costItemCntDict[str(cnt)]
|
| | | break
|
| | | enough, indexList, hasBind, lackCnt = ItemCommon.GetItem_FromPack_ByID_ExEx(costItemID, itemPack, costItemCnt)
|
| | | costGold = 0
|
| | | if not enough:
|
| | | costGold = lackCnt * IpyGameDataPY.GetFuncCfg('MysteryShopRefresh', 3)
|
| | | if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, costGold, ChConfig.Def_Cost_MysteryShopRefresh):
|
| | | return
|
| | | ItemCommon.ReduceItem(curPlayer, itemPack, indexList, costItemCnt, False, "MysteryShopRefresh")
|
| | | curLVRefreshData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopLVRefreshCnt)
|
| | | curLVRefreshCnt, lvDan = curLVRefreshData / 10000, curLVRefreshData % 10000 |
| | | updLVRefreshCnt = 1 if curLVDan != lvDan else curLVRefreshCnt + 1 #等级段变更,重置该等级段的刷新次数
|
| | | updLVRefreshData = min(updLVRefreshCnt * 10000+curLVDan, ChConfig.Def_UpperLimit_DWord)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MysticalShopLVRefreshCnt, updLVRefreshData)
|
| | | specialRefreshCfg = IpyGameDataPY.GetFuncEvalCfg('MysteryShopRefresh', 5)
|
| | | if curLVDan in specialRefreshCfg and updLVRefreshCnt == specialRefreshCfg[curLVDan][0]:
|
| | | specialGoodsID = specialRefreshCfg[curLVDan][1]
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MysticalShopRefreshCnt, curRefreshCnt+1)
|
| | | |
| | | goldGoodsCnt = min(goldGoodsCnt, maxCnt)
|
| | | sliverGoodsCnt = maxCnt - goldGoodsCnt
|
| | | goodsResultList = []
|
| | | if goldGoodsCnt:
|
| | | goodsResultList += GameWorld.GetResultByRandomListEx(shopDict.get(IPY_GameWorld.TYPE_Price_Gold_Money, []), goldGoodsCnt, [])
|
| | | if sliverGoodsCnt:
|
| | | goodsResultList += GameWorld.GetResultByRandomListEx(shopDict.get(IPY_GameWorld.TYPE_Price_Silver_Money, []), sliverGoodsCnt, [])
|
| | | if specialGoodsID and specialGoodsID not in goodsResultList:
|
| | | goodsResultList[0] = specialGoodsID
|
| | | GameWorld.DebugLog('神秘商店刷新特殊规则,等级段:%s,updLVRefreshCnt=%s,specialGoodsID=%s'%(curLVDan, updLVRefreshCnt, specialGoodsID))
|
| | | |
| | | GameWorld.DebugLog('神秘商店刷新isFree=%s,goldGoodsCnt=%s,sliverGoodsCnt=%s,goodsResultList=%s'%(isFree, goldGoodsCnt, sliverGoodsCnt, goodsResultList))
|
| | | syncIndexList = []
|
| | | for i in xrange(maxCnt):
|
| | | goodsID = goodsResultList[i] if i < len(goodsResultList) else 0
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MysticalShopGoods % i, goodsID)
|
| | | |
| | | dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % goodsID
|
| | | curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey)
|
| | | if curDayBuyCnt:
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, dayBuyCntKey, 0)
|
| | | syncIndexList.append(goodsID)
|
| | | if syncIndexList:
|
| | | SyncShopItemTodayBuyCount(curPlayer, syncIndexList, True)
|
| | | #֪ͨ
|
| | | SyncMysticalShopInfo(curPlayer)
|
| | | return
|
| | |
|
| | | def SyncMysticalShopInfo(curPlayer):
|
| | | ##神秘商店通知
|
| | | packData = ChPyNetSendPack.tagMCMysticalShopInfo()
|
| | | packData.RefreshCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopRefreshCnt)
|
| | | packData.GoodsList = []
|
| | | maxCnt = IpyGameDataPY.GetFuncCfg('MysteryShopGoods', 1)
|
| | | for i in xrange(maxCnt):
|
| | | goodsID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopGoods % i)
|
| | | goodsInfo = ChPyNetSendPack.tagMCMysticalShopGoods()
|
| | | goodsInfo.GoodsID = goodsID
|
| | | packData.GoodsList.append(goodsInfo)
|
| | | packData.Count = len(packData.GoodsList)
|
| | | NetPackCommon.SendFakePack(curPlayer, packData)
|
| | | return
|
| | |
|
| | | ## 回购物品
|
| | |
| | | # @param tick 时间戳
|
| | | # @return 返回值真, 逻辑运行成功
|
| | | def BuyItem(curPlayer, tick):
|
| | |
|
| | | |
| | | if GameWorld.IsCrossServer():
|
| | | return
|
| | | |
| | | buyItemList = IPY_GameWorld.IPY_CBuyItemList()
|
| | | itemIndex = buyItemList.GetBuyItemIndex()
|
| | | if itemIndex < 0:
|
| | |
| | | if not ipyData:
|
| | | return
|
| | | shopType = ipyData.GetShopType()
|
| | | |
| | | if ipyData.GetOperationActionShop():
|
| | | operationActionShopType = ipyData.GetOperationActionShop()
|
| | | if operationActionShopType == 1:
|
| | | actInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_SpringSale, {})
|
| | | state = actInfo.get(ShareDefine.ActKey_State, 0)
|
| | | if not state:
|
| | | GameWorld.DebugLog("限时特惠非活动中!state=%s" % (state), curPlayer.GetPlayerID())
|
| | | return
|
| | | shopTypeList = actInfo.get(ShareDefine.ActKey_ShopTypeList, [])
|
| | | shopTypeList = PlayerSpringSale.GetShopTypeList(actInfo.get(ShareDefine.ActKey_CfgID, 0), actInfo.get(ShareDefine.ActKey_DayIndex, 0), actInfo.get(ShareDefine.ActKey_WorldLV, 0))
|
| | | if not shopTypeList:
|
| | | return
|
| | | actShopType = shopTypeList[-1] if state > len(shopTypeList) else shopTypeList[state - 1]
|
| | | if shopType != actShopType:
|
| | | GameWorld.DebugLog("限时特惠非活动中的商店类型!state=%s,shopType=%s,actShopType=%s,shopTypeList=%s"
|
| | | % (state, shopType, actShopType, shopTypeList), curPlayer.GetPlayerID())
|
| | | return
|
| | | elif operationActionShopType == 2:
|
| | | actInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FlashSale, {})
|
| | | state = actInfo.get(ShareDefine.ActKey_State, 0)
|
| | | if not state:
|
| | | GameWorld.DebugLog("限时抢购非活动中!state=%s" % (state), curPlayer.GetPlayerID())
|
| | | return
|
| | | shopTypeList = PlayerFlashSale.GetShopTypeList(actInfo.get(ShareDefine.ActKey_CfgID, 0), actInfo.get(ShareDefine.ActKey_DayIndex, 0), state, actInfo.get(ShareDefine.ActKey_WorldLV, 0))
|
| | | if not shopTypeList:
|
| | | return
|
| | | actShopType = shopTypeList[0]
|
| | | if shopType != actShopType:
|
| | | GameWorld.DebugLog("限时抢购非活动中的商店类型!state=%s,shopType=%s,actShopType=%s,shopTypeList=%s" |
| | | % (state, shopType, actShopType, shopTypeList), curPlayer.GetPlayerID())
|
| | | return
|
| | |
|
| | |
| | | if limitBuyCnt == -1:
|
| | | GameWorld.DebugLog(" vip%s才能购买"%viplv)
|
| | | return
|
| | | |
| | | |
| | | curDayBuyCnt = 0
|
| | | dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex
|
| | | if limitBuyCnt > 0:
|
| | |
| | | GameWorld.DebugLog("BuyShopItem 修正购买次数!shopType=%s,itemIndex=%s,clientBuyCount=%s,canBuyCnt=%s"
|
| | | % (shopType, itemIndex, clientBuyCount, canBuyCnt))
|
| | | clientBuyCount = canBuyCnt
|
| | | |
| | | serverLimitCnt = ipyData.GetServerLimitCnt()
|
| | | if serverLimitCnt > 0:
|
| | | clientBuyCount = min(serverLimitCnt, clientBuyCount)
|
| | | |
| | | itemID, itemCount, isBind = ipyData.GetItemID(), ipyData.GetItemCnt(), ipyData.GetIsBind()
|
| | | itemListEx = ipyData.GetItemListEx()
|
| | | priceType, itemPrice = ipyData.GetMoneyType(), ipyData.GetMoneyNum()
|
| | |
| | | jobItemList = ipyData.GetJobItem()
|
| | | totalItemList = []
|
| | | if itemID:
|
| | | jobItemID = __GetShopJobItem(job, itemID, jobItemList)
|
| | | jobItemID = GetShopJobItem(job, itemID, jobItemList)
|
| | | totalItemList.append([jobItemID, itemCount * clientBuyCount, isBind])
|
| | | for itemIDEx, itemCountEx, isBindEx in itemListEx:
|
| | | jobItemID = __GetShopJobItem(job, itemIDEx, jobItemList)
|
| | | jobItemID = GetShopJobItem(job, itemIDEx, jobItemList)
|
| | | totalItemList.append([jobItemID, itemCountEx * clientBuyCount, isBindEx])
|
| | | #允许价钱配置0,用来免费购买
|
| | | if not totalItemList:
|
| | |
| | | if not curItem:
|
| | | GameWorld.ErrLog("Store shop item error! shopType=%s,itemID=%s" % (shopType, itemID))
|
| | | return
|
| | | packType = ShareDefine.rptRune if curItem.GetType() == ChConfig.Def_ItemType_Rune else IPY_GameWorld.rptItem
|
| | | needSpace = int(math.ceil(float(itemCnt) / curItem.GetPackCount()))
|
| | | packType = ChConfig.GetItemPackType(curItem.GetType())
|
| | | needSpace = ItemControler.GetItemNeedPackCount(packType, curItem, itemCnt)
|
| | | needPackSpaceDict[packType] = needPackSpaceDict.get(packType, 0) + needSpace
|
| | |
|
| | | if i == 0:
|
| | |
| | |
|
| | | GameWorld.DebugLog("购买物品: shopType=%s,itemIndex=%s,clientBuyCount=%s,totalItemList=%s,mainItemID=%s,needPackSpaceDict=%s"
|
| | | % (shopType, itemIndex, clientBuyCount, totalItemList, mainItemID, needPackSpaceDict), curPlayer.GetPlayerID())
|
| | | |
| | | mailKey = ipyData.GetMailKey()
|
| | | isLackPack = False #是否背包不足
|
| | | for packType, needSpace in needPackSpaceDict.items():
|
| | | if needSpace > ItemCommon.GetItemPackSpace(curPlayer, packType, needSpace):
|
| | | curPlayer.ShopResult(itemIndex, IPY_GameWorld.tsrNoPlace)
|
| | | PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packType])
|
| | | return
|
| | | isLackPack = True
|
| | | if mailKey:
|
| | | break
|
| | | else:
|
| | | curPlayer.ShopResult(itemIndex, IPY_GameWorld.tsrNoPlace)
|
| | | PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packType])
|
| | | return
|
| | | sendMailKey = mailKey if isLackPack and mailKey else '' #背包不足且配置了mailKey的才发邮件
|
| | |
|
| | | # 购买限制条件扩展
|
| | | if CheckBuyItemLimitEx(curPlayer, shopType, itemIndex, mainItemID, ipyData.GetLimitValue()):
|
| | | if CheckBuyItemLimitEx(curPlayer, shopType, itemIndex, mainItemID, ipyData.GetLimitValue(), clientBuyCount):
|
| | | GameWorld.Log("Store shop item buy limit! shopType=%s,itemIndex=%s,limitValue=%s"
|
| | | % (shopType, itemIndex, ipyData.GetLimitValue()), curPlayer.GetPlayerID())
|
| | | return
|
| | | if not PlayerControl.HaveMoney(curPlayer, priceType, itemPrice):
|
| | | curPlayer.ShopResult(itemIndex, IPY_GameWorld.tsrNoMoney)
|
| | | return
|
| | |
|
| | | if serverLimitCnt > 0: #全服限购判断放到最后面,GameServer直接加次数
|
| | | if curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_StoreQueryState) == 1:
|
| | | #已经在查询中, 不重复查询
|
| | | GameWorld.DebugLog("全服购买次数已经在查询中, 不重复查询 itemIndex=%s" % itemIndex)
|
| | | return
|
| | | cmdStr = '%s' % ([itemIndex, serverLimitCnt, clientBuyCount, totalItemList, mainItemID, limitBuyCnt, sendMailKey])
|
| | | GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0,
|
| | | "GetStoreServerBuyCnt", cmdStr, len(cmdStr))
|
| | | #设置状态查询中
|
| | | curPlayer.SetDict(ChConfig.Def_PlayerKey_StoreQueryState, 1)
|
| | | return
|
| | | #-------------------------开始购买物品-----------------------------
|
| | | DoBuyStoreItem(curPlayer, itemIndex, clientBuyCount, totalItemList, mainItemID, limitBuyCnt, sendMailKey, ipyData)
|
| | | |
| | | return
|
| | |
|
| | | def DoBuyStoreItem(curPlayer, itemIndex, clientBuyCount, totalItemList, mainItemID, limitBuyCnt, sendMailKey, ipyData=None):
|
| | | if not ipyData:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("Store", itemIndex)
|
| | | priceType, itemPrice = ipyData.GetMoneyType(), ipyData.GetMoneyNum()
|
| | | itemPrice *= clientBuyCount
|
| | | shopType = ipyData.GetShopType()
|
| | | |
| | | beforeMoney = PlayerControl.GetMoney(curPlayer, priceType)
|
| | | infoDict = {"TotalItemList":totalItemList, "ClientBuyCount":clientBuyCount, "ShopType":shopType,
|
| | | "ShopItemIndex":itemIndex, ChConfig.Def_Cost_Reason_SonKey:mainItemID}
|
| | | if not PlayerControl.PayMoney(curPlayer, priceType, itemPrice, ChConfig.Def_Cost_BuyStoreItem, infoDict, clientBuyCount):
|
| | | curPlayer.ShopResult(itemIndex, IPY_GameWorld.tsrNoMoney)
|
| | | return
|
| | | PlayerControl.PayMoney(curPlayer, priceType, itemPrice, ChConfig.Def_Cost_BuyStoreItem, infoDict, clientBuyCount)
|
| | | |
| | | afterMoney = PlayerControl.GetMoney(curPlayer, priceType)
|
| | |
|
| | | # 今日购买次数+1
|
| | | if limitBuyCnt > 0:
|
| | | dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex
|
| | | curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, dayBuyCntKey, curDayBuyCnt + clientBuyCount)
|
| | | SyncShopItemTodayBuyCount(curPlayer, [itemIndex])
|
| | |
|
| | |
| | | "ItemPrice":itemPrice, "MoneyType":priceType,
|
| | | "BeforeMoney":beforeMoney, "AfterMoney":afterMoney}
|
| | | isForceEvent = priceType not in [IPY_GameWorld.TYPE_Price_Silver_Money]
|
| | | |
| | |
|
| | | itemControl = ItemControler.PlayerItemControler(curPlayer)
|
| | | for itemID, itemCount, isBind in totalItemList:
|
| | | curItemObj = ItemControler.GetOutPutItemObj(itemID, itemCount, isBind)
|
| | | curItemObj = ItemControler.GetOutPutItemObj(itemID, itemCount, False, curPlayer=curPlayer)
|
| | | if not curItemObj:
|
| | | continue
|
| | | userData = curItemObj.GetUserData()
|
| | | packType = ShareDefine.rptRune if curItemObj.GetType() == ChConfig.Def_ItemType_Rune else IPY_GameWorld.rptItem
|
| | | if not itemControl.PutInItem(packType, curItemObj, event=[ChConfig.ItemGive_BuyItem, isForceEvent, dataDict]):
|
| | | if not sendMailKey:
|
| | | packType = ChConfig.GetItemPackType(curItemObj.GetType())
|
| | | if not itemControl.PutInItem(packType, curItemObj, event=[ChConfig.ItemGive_BuyItem, isForceEvent, dataDict]):
|
| | | curItemObj.Clear()
|
| | | continue
|
| | | else:
|
| | | curItemObj.Clear()
|
| | | continue
|
| | | |
| | | EventShell.EventRespons_BuyItem(curPlayer, itemID, itemCount)
|
| | |
|
| | | if ipyData.GetNotifyMark() and itemID == mainItemID:
|
| | | PlayerControl.WorldNotify(0, ipyData.GetNotifyMark(), [curPlayer.GetName(), mainItemID, userData])
|
| | |
|
| | | # 购买永久守护时删除限时守护
|
| | | if itemID == 4101:
|
| | | delGuardItem = ItemCommon.FindItemInPackByItemID(curPlayer, 4105, IPY_GameWorld.rptItem)
|
| | | if delGuardItem:
|
| | | ItemCommon.DelItem(curPlayer, delGuardItem, 1)
|
| | | |
| | | if sendMailKey:
|
| | | PlayerControl.SendMailByKey(sendMailKey, [curPlayer.GetID()], totalItemList, detail=dataDict)
|
| | | #触发任务购买物品
|
| | | EventShell.EventRespons_ShopBuy(curPlayer, shopType)
|
| | | #curPlayer.ShopResult(itemIndex, IPY_GameWorld.tsrShopOK)
|
| | | SyncShoppingResult(curPlayer, itemIndex, clientBuyCount)
|
| | | if itemIndex in IpyGameDataPY.GetFuncEvalCfg('CeremonyFireParty', 1, {}).values():
|
| | | PlayerFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_Fireworks, clientBuyCount)
|
| | | |
| | | if shopType == ShopType_FairyCeremony:
|
| | | PlayerFairyCeremony.OnBuyFireworks(curPlayer, itemIndex, clientBuyCount)
|
| | | # if itemIndex in IpyGameDataPY.GetFuncEvalCfg('NewCeremonyFireParty', 1, {}).values():
|
| | | # PlayerNewFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_Fireworks, clientBuyCount)
|
| | | return
|
| | |
|
| | | def __GetShopJobItem(job, itemID, jobItemList):
|
| | | def GetShopJobItem(job, itemID, jobItemList):
|
| | | ## 获取商城物品对应的职业物品, 职业从1开始
|
| | | for jobItemIDList in jobItemList:
|
| | | if type(jobItemIDList) not in [list, tuple]:
|
| | |
| | | ## 商店购买物品限制条件扩展
|
| | | # @param curPlayer 玩家实例
|
| | | # @return
|
| | | def CheckBuyItemLimitEx(curPlayer, shopNPCID, itemIndex, curItemID, limitValue):
|
| | | def CheckBuyItemLimitEx(curPlayer, shopNPCID, itemIndex, curItemID, limitValue, clientBuyCount):
|
| | | if shopNPCID == 7: #符印商店
|
| | | return not PlayerRune.GetIsOpenByRuneID(curPlayer, curItemID)
|
| | | if shopNPCID in [8, 9, 10]: #仙盟商店
|
| | |
| | | #playerCreateRoleDays = GameWorld.GetCreateRoleDays(curPlayer)
|
| | | openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)+1
|
| | | return openServerDay != limitValue
|
| | | #烟花狂欢
|
| | | if itemIndex in IpyGameDataPY.GetFuncEvalCfg('CeremonyFireParty', 1, {}).values():
|
| | | return not PlayerFairyCeremony.IsCanBuyFireworks(curPlayer, itemIndex)
|
| | | |
| | | #仙界盛典 - 烟花狂欢
|
| | | if shopNPCID == ShopType_FairyCeremony:
|
| | | return not PlayerFairyCeremony.IsCanBuyFireworks(curPlayer, itemIndex, clientBuyCount)
|
| | | |
| | | #另一个仙界盛典可用其他商店NPCID,这里先注释,之后再改
|
| | | # if itemIndex in IpyGameDataPY.GetFuncEvalCfg('NewCeremonyFireParty', 1, {}).values():
|
| | | # return not PlayerNewFairyCeremony.IsCanBuyFireworks(curPlayer, itemIndex)
|
| | | |
| | | if shopNPCID == 16:#神秘限购
|
| | | startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopItemStartTime % itemIndex)
|
| | | curTime = int(time.time())
|
| | | return not startTime or curTime - startTime >= limitValue
|
| | | |
| | | #
|
| | | # limitPlusDict = {shopItem.GetLimitPlusType1():shopItem.GetLimitPlusValue1(),
|
| | | # shopItem.GetLimitPlusType2():shopItem.GetLimitPlusValue2(),
|
| | |
| | |
|
| | | # 默认不限制
|
| | | return False
|
| | |
|
| | | def OSSaleOpenMail(curPlayer):
|
| | | #开服特惠开启邮件
|
| | | if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_OSSail):
|
| | | return
|
| | | openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)+1
|
| | | if openServerDay not in IpyGameDataPY.GetFuncEvalCfg('OSSaleOpenMail'):
|
| | | return
|
| | | addItemList = IpyGameDataPY.GetFuncEvalCfg('OSSaleOpenMail', 2)
|
| | | PlayerControl.SendMailByKey('SellMail1', [curPlayer.GetID()], addItemList)
|
| | | return
|
| | |
|
| | |
|
| | | ## 商店npcid
|
| | | # @param curPlayer 玩家实例
|
| | |
| | |
|
| | | return True
|
| | |
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | | ##检查物品可否修理
|
| | | # @param curPlayer 玩家实例
|
| | | # @param curItem 物品实例
|
| | | # @param farRepair 是否远程修理
|
| | | # @return 返回值真, 检查通过
|
| | | # @remarks 检查物品可否修理
|
| | | #===============================================================================
|
| | | # def __CheckRepairItem(curPlayer, curItem, farRepair):
|
| | | # |
| | | # if not ItemCommon.CheckItemCanUse(curItem):
|
| | | # if not farRepair:
|
| | | # #封包信息不正确
|
| | | # PlayerControl.NotifyCode(curPlayer, "UseResLost04")
|
| | | # |
| | | # return
|
| | | # |
| | | # if curItem.GetCanRepair() == 0:
|
| | | # if not farRepair:
|
| | | # #物品不可修理
|
| | | # PlayerControl.NotifyCode(curPlayer, "UseResLost13") |
| | | # |
| | | # return
|
| | | # |
| | | # if ItemControler.IsEventItem(curItem):
|
| | | # if not farRepair:
|
| | | # PlayerControl.NotifyCode(curPlayer, "itemuse_chenxin_31379")
|
| | | # |
| | | # return
|
| | | # |
| | | # if curItem.GetEndureReduceType() == ChConfig.Def_EquipReduceType_None or curItem.GetMaxEndure() == 0:
|
| | | # if not farRepair:
|
| | | # #耐久字段为0,不符合要求,返回
|
| | | # PlayerControl.NotifyCode(curPlayer, "UseResLost13")
|
| | | # |
| | | # return
|
| | | # |
| | | # return True
|
| | | #===============================================================================
|
| | | #--------------------出售物品
|
| | | ##出售物品
|
| | | # @param curPlayer 玩家实例
|
| | |
| | | # @return 返回值真, 检查通过
|
| | | # @remarks 检查物品是否可以出售
|
| | | def __CheckItemSell(curPlayer, curItem) :
|
| | | if not ItemCommon.CheckItemCanUse(curItem):
|
| | | if not ItemCommon.CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):
|
| | | PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_644055")
|
| | | return
|
| | |
|
| | |
| | | priceType = IPY_GameWorld.TYPE_Price_Silver_Money
|
| | | curItemPrice = curItem.GetSilverPrice()
|
| | | return curItemPrice, priceType
|
| | | #绑定价格售价为0, 2011.4.27
|
| | | # if curItem.GetIsBind():
|
| | | # itrmPrice_bind = eval(ReadChConfig.GetChConfig("ItemSellPrice_Bind"))
|
| | | # return itrmPrice_bind, priceType
|
| | | # |
| | | # #无耐久物品
|
| | | # if curItemEndure == 0 :
|
| | | # return curItemPrice * 0.5, priceType
|
| | | # |
| | | # itrmPrice_notBind = eval(ReadChConfig.GetChConfig("ItemSellPrice_NotBind"))
|
| | | # return itrmPrice_notBind, priceType
|
| | | #===============================================================================
|
| | | # 2010.11.25 绑定售价和非绑定一致
|
| | | # #绑定的
|
| | | # if curItem.GetIsBind():
|
| | | # return curItemPrice * 0.5 * 0.5, curItemType
|
| | | # #非绑定的
|
| | | # return curItemPrice * 0.5, curItemType
|
| | | #===============================================================================
|
| | | #===============================================================================
|
| | | # |
| | | # #绑定正常物品出售价格
|
| | | # if curItem.GetIsBind() :
|
| | | # return eval(ChConfig.Def_Formula_ItemSellPrice) * 0.5, curItemType
|
| | | # |
| | | # #未绑定正常物品出售价格
|
| | | # return eval(ChConfig.Def_Formula_ItemSellPrice), curItemType
|
| | | #===============================================================================
|
| | | #---------------------------------------------------------------------
|
| | |
|
| | | ##检查玩家可否开始NPC事件
|
| | | # @param curPlayer 玩家实例
|
| | | # @return 返回值真, 检查通过
|