#!/usr/bin/python # -*- coding: GBK -*- #--------------------------------------------------------------------- # #--------------------------------------------------------------------- ##@package FunctionNPCCommon # @todo: ¹¦ÄÜNPC¹ÜÀíÆ÷ # # @author: panwei # @date 2010-4-26 # @version 4.4 # # @note: #--------------------------------------------------------------------- # @change: "2013-04-18 17:00" wdb ÎïÆ·ÑÕɫʹÓÃÐÞ¸Ä # @change: "2013-04-26 16:00" wdb npcÉ̵êÐÞ¸Ä # @change: "2013-05-03 17:00" wdb npcÉ̵êÅä±í·½Ê½ÐÞ¸Ä # @change: "2013-05-20 15:00" wdb ×°±¸¸½¼ÓÊôÐÔ½Ó¿ÚÐÞ¸Ä # @change: "2013-05-30 10:30" wdb ×°±¸±¦Ê¯ÏâǶµ÷Õû # @change: "2013-07-19 20:00" Alee Ìí¼Ó»Ø¹º # @change: "2013-07-22 17:00" Alee ÎïÆ·¿É°´ÊýÁ¿¹ºÂò # @change: "2013-10-12 21:10" Alee ϵͳÌáʾ # @change: "2013-10-22 11:10" Alee ÎïÆ·¼¼ÄÜÔöǿЧ¹û,ͳһº¯ÊýEquipAddAdditionEx # @change: "2013-11-08 22:30" Alee É̳ÇÌí¼Ó´ò¿× # @change: "2013-11-19 11:00" hxp Ð޸ijöÊÛÎïÆ·ÅжϽðÇ®ÉÏÏÞÂß¼­ # @change: "2014-01-16 13:54" xmnathan Õ½ÃËÉ̳ǹºÂò # @change: "2014-01-28 00:55" Alee ¶ñħÉ̵êĬÈÏ׿ԽºÍÌ××° # @change: "2014-02-12 14:00" Alee È¡ÏûºìÃû¹ºÂò³Í·£ # @change: "2014-04-07 11:30" Alee ·â°üDWORDµ¼Ö½ӿÚint±¨´í£¬·À·¶·¶Î§¹ý´ó # @change: "2014-05-05 15:00" xmnathan Ìæ»»ÏµÍ³Ìáʾ # @change: "2014-05-21 17:25" xcc Ôö¼Óħ·½Ñ°±¦»ý·Ö¶Ò»»ÎïÆ·¹¦ÄÜ # @change: "2014-06-05 15:30" hxp É̵êNPCÎïÆ·¹ºÂòÔö¼ÓÿÈտɹºÂò´ÎÊýÉÏÏÞÖ§³Ö # @change: "2014-08-04 16:00" Alee Ì××°ÎïÆ·É̵êÐÞ¸Ä # @change: "2014-08-07 20:40" Alee ±¦²Ø»ý·Ö¶Ò»»×¿Ô½ÊôÐÔ×°±¸¹Ì¶¨2ÌõÊôÐÔ # @change: "2014-08-12 11:30" xmnathan ÌìÌݾº¼¼ µãÊý¹ºÂò°ó¶¨ # @change: "2014-10-20 16:20" Alee ¶Ò»»Ì××°3׿Խ # @change: "2014-11-05 15:00" Alee É̵깺Âò°ó¶¨ÐÞ¸Ä # @change: "2014-12-11 16:30" hxp É̵ê¶Ò»»×°±¸Ôö¼ÓÖ§³ÖÅäÖÃ×°±¸¶ÔӦ׿ԽÌõÊý # @change: "2015-01-14 00:30" hxp Ôö¼ÓÎïÆ·±ä¸üʼþ»ã±¨ # @change: "2015-01-14 16:40" ljd Ôö¼ÓÎïÆ·¶Ò»»É̵ê # @change: "2015-01-27 10:50" ljd Ôö¼Ó×°±¸ÎïÆ·À´Ô´±ê¼Ç # @change: "2015-04-03 18:00" hxp ·À·¶»ØÊÕÕ¾Òì³£Çé¿öÎïÆ·Ïûʧ¶øÃ»ÓÐÖØÖñê¼Çλµ¼ÖÂÊýÖµÔ½½ç # @change: "2015-04-16 19:10" ljd É̵긶Ǯʱ´«ÈëÖ§¸¶ÀàÐÍ # @change: "2015-04-27 22:00" hxp Ôö¼ÓBuyItemÁ÷Ïò # @change: "2016-07-20 14:30" hxp »õ±ÒÖ§¸¶Á÷ÏòÕûºÏ # @change: "2016-08-04 18:00" hxp ³öÊۻعº¼Û¸ñÐÞ¸Ä #--------------------------------------------------------------------- #"""Version = 2016-08-04 18:00""" #--------------------------------------------------------------------- import ChPyNetSendPack import NetPackCommon import GameWorld import EventShell import IPY_GameWorld import ItemControler import ChConfig import PlayerControl import ItemCommon import ShareDefine import PlayerFlashSale #import EventSrc import ChItem import IpyGameDataPY import PlayerRune import GameFuncComm import PlayerFairyCeremony import PlayerNewFairyCeremony import PlayerSpringSale import PyGameData import random import math import time #--------------------------------------------------------------------- ##¿ªÊ¼½»Ò× # @param curPlayer Íæ¼ÒʵÀý # @param tick ʱ¼ä´Á # @return ·µ»ØÖµÕæ, Âß¼­ÔËÐгɹ¦ # @remarks ¿ªÊ¼½»Ò× def StartTrade(curPlayer, tick): curActionObj = curPlayer.GetActionObj() if curActionObj == None: return if curActionObj.GetGameObjType() != IPY_GameWorld.gotNPC: return curActionNPC = GameWorld.GetNPCManager().GetNPCByIndex(curActionObj.GetIndex()) curActionNPCID = curActionNPC.GetNPCID() # ÉèÖõ±Ç°É̵êµÄnpcid curPlayer.SetDict(ChConfig.Def_PlayerKey_TradeTagNPC, curActionNPCID) #É趨Ϊ½ûÖ¹ÕûÀí±³°ü curPlayer.SetForbiddenResetItem(1) curPlayer.BeginSpecialEvent(ShareDefine.TYPE_Event_Shop) return True #------------------------------------------------------------------------------ ## »ñȡԶ³ÌÉ̵êµÄnpc # @param curPlayer Íæ¼ÒʵÀý # @return Ô¶³ÌÉ̵êµÄnpc def GetDirectNpcID(): return 0 #--------------------------------------------------------------------- ##½áÊøÊ¼þ # @param curPlayer Íæ¼ÒʵÀý # @param tick ʱ¼ä´Á # @return ·µ»ØÖµÕæ, Âß¼­ÔËÐгɹ¦ # @remarks ½áÊøÊ¼þ def ExitEvent(curPlayer, tick): EventShell.DoExitEvent(curPlayer) return True #--------------------------------------------------------------------- ##ÇëÇóÉ̵êÎïÆ·Áбí # @param curPlayer Íæ¼ÒʵÀý # @param tick ʱ¼ä´Á # @return ·µ»ØÖµÕæ, Âß¼­ÔËÐгɹ¦ def QueryNPCShopItem(playerIndex, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex) #ʱ¼ä¼ä¸ôδµ½ if tick - curPlayer.GetTickByType(ChConfig.TYPE_Player_Tick_QueryFuncData) \ < ChConfig.TYPE_Player_Tick_Time[ChConfig.TYPE_Player_Tick_QueryFuncData]: return curPlayer.SetTickByType(ChConfig.TYPE_Player_Tick_QueryFuncData, tick) #Ö±½Ó²éѯ£¬´æÔÚ¸ÃNPCID¾Í·¢°ü tradeTagNPC = clientData.NPCShopID GameWorld.GetGameData().FilterShopItemByShopType(tradeTagNPC) shopItemCount = GameWorld.GetGameData().GetFilterShopItemCount() if shopItemCount <= 0: return # # É̵ênpcidÓ뵱ǰ¶Ô»°npc¶ÔÓ¦,0ΪԶ³ÌÉ̵ê # tradeTagNPC = clientData.NPCShopID # if tradeTagNPC != 0 and not CheckTradeTagNPC(curPlayer, tradeTagNPC): # return # ·¢ËÍÉÌÆ·½ñÈÕÒѹºÂò´ÎÊý #SyncShopItemTodayBuyCount(curPlayer) # ·¢ËÍÉ̵êÎïÆ·Áбí curPlayer.BeginShopEx(tradeTagNPC) return ##ͬ²½É̵êNPCÎïÆ·½ñÈÕ¹ºÂò´ÎÊý # @param curPlayer Íæ¼ÒʵÀý # @param npcID # @param itemIndex -1ʱͬ²½¸ÃNPCËùÓÐÎïÆ· # @return def SyncShopItemTodayBuyCount(curPlayer, itemIndexList=[], isReset=False): dayBuyCntInfo = ChPyNetSendPack.tagMCShopItemDayBuyCntInfo() dayBuyCntInfo.DayBuyCntList = [] if itemIndexList: for itemIndex in itemIndexList: __AppendShopItemDayBuyCntInfo(curPlayer, itemIndex, dayBuyCntInfo.DayBuyCntList, isReset) else: ipyDataMgr = IpyGameDataPY.IPY_Data() for i in xrange(ipyDataMgr.GetStoreCount()): shopItem = ipyDataMgr.GetStoreByIndex(i) if not shopItem.GetLimitCnt(): continue dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % shopItem.GetID() curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey) if curDayBuyCnt <= 0: continue __AppendShopItemDayBuyCntInfo(curPlayer, shopItem.GetID(), dayBuyCntInfo.DayBuyCntList, isReset) dayBuyCntInfo.Count = len(dayBuyCntInfo.DayBuyCntList) NetPackCommon.SendFakePack(curPlayer, dayBuyCntInfo) return ##Ôö¼ÓÉ̵êÎïÆ·½ñÈÕ¹ºÂò´ÎÊýÐÅÏ¢ # @param curPlayer Íæ¼ÒʵÀý # @param npcID # @param itemIndex # @return def __AppendShopItemDayBuyCntInfo(curPlayer, itemIndex, dayBuyCntList, isReset): itemDayBuyCnt = ChPyNetSendPack.tagMCShopItemDayBuyCnt() itemDayBuyCnt.ItemIndex = itemIndex dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey) itemDayBuyCnt.BuyCnt = curDayBuyCnt itemDayBuyCnt.IsReset = int(isReset) dayBuyCntList.append(itemDayBuyCnt) return ## µÇ¼ def ShopItemOnLogin(curPlayer): if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_VersionFix, ChConfig.Def_VerFix_SuperGift): GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_VersionFix, ChConfig.Def_VerFix_SuperGift, 1) isGet = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldGiftFirstRecord) if isGet:#Ê׳佱ÀøÒÑÁìÈ¡Ôò´ú±í³¬ÖµÀñ°üÒÑ¿ªÆô¹ý£¬ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SuperGiftHasOpen, 1) SyncMysticalShopInfo(curPlayer) SyncShopItemTodayBuyCount(curPlayer) SyncSuperGiftInfo(curPlayer) return ##É̵êÎïÆ·OnDay # @param curPlayer Íæ¼ÒʵÀý # @return def ShopItemOnDay(curPlayer, onEventType): if onEventType == ShareDefine.Def_OnEventType: UpdataSuperGiftTime(curPlayer, True) OSSaleOpenMail(curPlayer) refreshType = [3] elif onEventType == ShareDefine.Def_OnEventTypeEx: refreshType = [4] openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) if openServerDay % 3 == 0: refreshType = [4,7] else: return __ResetShopItemBuyCount(curPlayer, refreshType) return ##É̵êÎïÆ·OnWeek # @param curPlayer Íæ¼ÒʵÀý # @return def ShopItemOnWeek(curPlayer, onEventType): __ResetShopItemBuyCount(curPlayer, [onEventType]) return ##É̵êÎïÆ·OnMonth # @param curPlayer Íæ¼ÒʵÀý # @return def ShopItemOnMonth(curPlayer, onEventType): if onEventType == ShareDefine.Def_OnEventType: refreshType = 5 elif onEventType == ShareDefine.Def_OnEventTypeEx: refreshType = 6 else: return __ResetShopItemBuyCount(curPlayer, [refreshType]) return def ShopItemOnCrossPKSeasonChange(curPlayer): ## °´¿ç·þPKÈü¼¾ÖØÖà refreshType = 8 __ResetShopItemBuyCount(curPlayer, [refreshType]) return def __ResetShopItemBuyCount(curPlayer, onEventTypeList): #ÖØÖÃÉ̵êÎïÆ·¹ºÂò´ÎÊý 1£ºÖÜÒ»0µãˢР2£ºÖÜÒ»5µãˢР3£ºÃ¿ÈÕ0µãˢР4£ºÃ¿ÈÕ5µãˢР5ÿÔÂ0µã 6ÿÔÂ5µã 7ÿ3Ìì5µã 8ÿÈü¼¾ 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: continue dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % shopItem.GetID() curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey) if curDayBuyCnt <= 0: continue PlayerControl.NomalDictSetProperty(curPlayer, dayBuyCntKey, 0) syncIndexList.append(shopItem.GetID()) if syncIndexList: SyncShopItemTodayBuyCount(curPlayer, syncIndexList, True) return def ResetShopItemBuyCountByShopType(curPlayer, shopTypeList): ##¸ù¾ÝÉ̵êÀàÐÍÖØÖÃÉ̵êÏÞ¹ºÎïÆ·´ÎÊý syncIndexList = [] ipyDataMgr = IpyGameDataPY.IPY_Data() for i in xrange(ipyDataMgr.GetStoreCount()): shopItem = ipyDataMgr.GetStoreByIndex(i) if not shopItem.GetLimitCnt(): continue if shopItem.GetShopType() not in shopTypeList: continue dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % shopItem.GetID() curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey) if curDayBuyCnt <= 0: continue PlayerControl.NomalDictSetProperty(curPlayer, dayBuyCntKey, 0) syncIndexList.append(shopItem.GetID()) if syncIndexList: SyncShopItemTodayBuyCount(curPlayer, syncIndexList, True) return def MysticalShopOpen(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: SyncMysticalShopInfo(curPlayer) return def SyncMysticalShopInfo(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 ## »Ø¹ºÎïÆ· # @param None # @return None def BuyItemBack(curPlayer, clientPack, tick): index = clientPack.Index backPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptRecycle) if index >= backPack.GetCount(): #¼Ù°üÍ˳ö return curItem = backPack.GetAt(index) if not curItem or curItem.IsEmpty(): #ûÓÐÎïÆ·Í˳ö return realPutCount = curItem.GetCount() itemControl = ItemControler.PlayerItemControler(curPlayer) if not itemControl.CanPutInItem(IPY_GameWorld.rptItem, curItem.GetItemTypeID(), realPutCount, curItem.GetIsBind()): #ÎïÆ·²»ÄÜ·ÅÈëÍ˳ö PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [IPY_GameWorld.rptItem]) return itemPrice, priceType = __GetItemSellPrice(curPlayer, curItem) itemPrice = int(itemPrice) * realPutCount if not priceType or not itemPrice: return #¸¶Ç® infoDict = {ChConfig.Def_Cost_Reason_SonKey:curItem.GetItemTypeID()} if not PlayerControl.PayMoney(curPlayer, priceType, itemPrice, ChConfig.Def_Cost_BuyItemBack, infoDict): return itemControl.PutInItem(IPY_GameWorld.rptItem, curItem, event=["BuyItemBack", False, {}]) itemIndexs = str(curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_DelPackIndex)) itemIndexs = itemIndexs.replace(str(index + 1), '') if itemIndexs == '': #ûÓÐÎïÆ·±£Áô 0 itemIndexs = '0' PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_DelPackIndex, int(itemIndexs)) return ##¹ºÂòÎïÆ· # @param curPlayer Íæ¼ÒʵÀý # @param tick ʱ¼ä´Á # @return ·µ»ØÖµÕæ, Âß¼­ÔËÐгɹ¦ def BuyItem(curPlayer, tick): if GameWorld.IsCrossServer(): return buyItemList = IPY_GameWorld.IPY_CBuyItemList() itemIndex = buyItemList.GetBuyItemIndex() if itemIndex < 0: return clientBuyCount = buyItemList.GetBuyCount() if not clientBuyCount: return ipyData = IpyGameDataPY.GetIpyGameData("Store", itemIndex) if not ipyData: return shopType = ipyData.GetShopType() 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 = PlayerSpringSale.GetShopTypeList(actInfo.get(ShareDefine.ActKey_CfgID, 0), actInfo.get(ShareDefine.ActKey_DayIndex, 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) 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 # ÎïÆ·ÐÅÏ¢ limitLV = ipyData.GetLimitLV() if limitLV and curPlayer.GetLV() < limitLV: return LimitVIPLVList = ipyData.GetLimitVIPLV() LimitCntList = ipyData.GetLimitCnt() limitBuyCnt = 0 if LimitVIPLVList or LimitCntList: if not LimitVIPLVList: LimitVIPLVList = [0] if not LimitCntList: LimitCntList = [0] if len(LimitVIPLVList) != len(LimitCntList): GameWorld.Log(" ¹ºÂòÎïÆ·LimitVIPLV LimitCnt ³¤¶È²»Í¬") return curVIPlv = curPlayer.GetVIPLv() limitBuyCnt = -1 for i, viplv in enumerate(LimitVIPLVList): if curVIPlv < viplv: break limitBuyCnt = LimitCntList[i] if limitBuyCnt == -1: GameWorld.DebugLog(" vip%s²ÅÄܹºÂò"%viplv) return curDayBuyCnt = 0 dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex if limitBuyCnt > 0: curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey) canBuyCnt = max(0, limitBuyCnt - curDayBuyCnt) if canBuyCnt <= 0: GameWorld.DebugLog("BuyShopItem ½ñÈÕ¹ºÂò´ÎÊýÒÑÂú£¡shopType=%s,itemIndex=%s" % (shopType, itemIndex)) return if clientBuyCount > canBuyCnt: 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() itemPrice *= clientBuyCount job = curPlayer.GetJob() jobItemList = ipyData.GetJobItem() totalItemList = [] if itemID: jobItemID = GetShopJobItem(job, itemID, jobItemList) totalItemList.append([jobItemID, itemCount * clientBuyCount, isBind]) for itemIDEx, itemCountEx, isBindEx in itemListEx: jobItemID = GetShopJobItem(job, itemIDEx, jobItemList) totalItemList.append([jobItemID, itemCountEx * clientBuyCount, isBindEx]) #ÔÊÐí¼ÛÇ®ÅäÖÃ0£¬ÓÃÀ´Ãâ·Ñ¹ºÂò if not totalItemList: GameWorld.ErrLog("Store shop item error! shopType=%s,totalItemList=%s,itemPrice=%s" % (shopType, totalItemList, itemPrice)) return mainItemID = 0 needPackSpaceDict = {} for i, itemInfo in enumerate(totalItemList): itemID = itemInfo[0] itemCnt = itemInfo[1] curItem = GameWorld.GetGameData().GetItemByTypeID(itemID) if not curItem: GameWorld.ErrLog("Store shop item error! shopType=%s,itemID=%s" % (shopType, itemID)) return packType = ChConfig.GetItemPackType(curItem.GetType()) needSpace = ItemControler.GetItemNeedPackCount(packType, curItem, itemCnt) needPackSpaceDict[packType] = needPackSpaceDict.get(packType, 0) + needSpace if i == 0: mainItemID = itemID if not mainItemID: return 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): 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()): 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} 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]) dataDict = {"ShopType":shopType, "ShopItemIndex":itemIndex, "ClientBuyCount":clientBuyCount, "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) if not curItemObj: continue userData = curItemObj.GetUserData() 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() EventShell.EventRespons_BuyItem(curPlayer, itemID, itemCount) if ipyData.GetNotifyMark() and itemID == mainItemID: PlayerControl.WorldNotify(0, ipyData.GetNotifyMark(), [curPlayer.GetName(), mainItemID, userData]) 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 itemIndex in IpyGameDataPY.GetFuncEvalCfg('NewCeremonyFireParty', 1, {}).values(): PlayerNewFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_Fireworks, clientBuyCount) return def GetShopJobItem(job, itemID, jobItemList): ## »ñÈ¡É̳ÇÎïÆ·¶ÔÓ¦µÄÖ°ÒµÎïÆ·£¬ Ö°Òµ´Ó1¿ªÊ¼ for jobItemIDList in jobItemList: if type(jobItemIDList) not in [list, tuple]: GameWorld.ErrLog("É̳ÇÖ°ÒµÎïÆ·×é¸ñʽ´íÎó!shopItemID=%s,jobItemList=%s" % (itemID, jobItemList)) return itemID if itemID in jobItemIDList: if job <= 0 or job > len(jobItemIDList): GameWorld.ErrLog("É̳ÇÖ°ÒµÎïÆ·ÅäÖôíÎó,ûÓиÃÖ°Òµ¶ÔÓ¦ÎïÆ·ID!shopItemID=%s,job=%s" % (itemID, job)) return itemID return jobItemIDList[job - 1] return itemID def SyncShoppingResult(curPlayer, itemIndex, itemCnt): #֪ͨ¹ºÂò½á¹û resultInfo = ChPyNetSendPack.tagMCShoppingResult() resultInfo.ItemIndex = itemIndex resultInfo.ItemCnt = itemCnt NetPackCommon.SendFakePack(curPlayer, resultInfo) return ## É̵깺ÂòÎïÆ·ÏÞÖÆÌõ¼þÀ©Õ¹ # @param curPlayer Íæ¼ÒʵÀý # @return def CheckBuyItemLimitEx(curPlayer, shopNPCID, itemIndex, curItemID, limitValue): if shopNPCID == 7: #·ûÓ¡É̵ê return not PlayerRune.GetIsOpenByRuneID(curPlayer, curItemID) if shopNPCID in [8, 9, 10]: #ÏÉÃËÉ̵ê if curPlayer.GetFamilyID() == 0: #ÎÞ¼Ò×å return True curFamilyLV = curPlayer.GetFamilyLV() if curFamilyLV <= 0: curFamilyLV = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyLV) return curFamilyLV < limitValue if shopNPCID in [15]: # ¿ª·þÌØ»ÝÉ̵ê #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 itemIndex in IpyGameDataPY.GetFuncEvalCfg('NewCeremonyFireParty', 1, {}).values(): return not PlayerNewFairyCeremony.IsCanBuyFireworks(curPlayer, itemIndex) # if itemIndex in dict(IpyGameDataPY.GetFuncEvalCfg('SuperGiftTimeList')): # return not CheckSuperGiftBuy(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(), # shopItem.GetLimitPlusType3():shopItem.GetLimitPlusValue3(), # } # # for limitType, limitValue in limitPlusDict.items(): # if limitType <= 0: # continue # # # ÓÅÏÈÅжÏNPC¶ÀÓÐµÄ # callFunc = GameWorld.GetExecFunc(EventSrc, "FunctionNPCShopBuyCheck.CheckByNPC_%s_%s" # % (shopNPCID, limitType)) # # if callFunc: # return callFunc(curPlayer, shopItem.GetItemID(), limitValue) # # # ¹«¹²ÏÞÖÆÌõ¼þÅÐ¶Ï # callFunc = GameWorld.GetExecFunc(EventSrc, "FunctionNPCShopBuyCheck.CheckPublic_%s" % limitType) # # if callFunc: # return callFunc(curPlayer, shopItem.GetItemID(), limitValue) # ĬÈϲ»ÏÞÖÆ 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 #³¬ÖµÀñ°ü¹ºÂòʱ¼ä def UpdataSuperGiftTime(curPlayer, isOnday=False): curTime = int(time.time()) if isOnday: startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SuperGiftStartTime) if not startTime: return superGiftTimeList = IpyGameDataPY.GetFuncEvalCfg('SuperGiftTimeList') maxDay = max([info[1] for info in superGiftTimeList]) if curTime - startTime >= maxDay * 86400: #»î¶¯½áÊø ÖØÖà PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SuperGiftStartTime, 0) else: if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SuperGiftHasOpen): #ÀϺÅÒÑ¿ªÆô¹ý³¬ÖµÀñ°üÔò²»ÔÙ¿ªÆô return PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SuperGiftStartTime, curTime) addItemList = IpyGameDataPY.GetFuncEvalCfg('SuperGiftTimeList', 2) PlayerControl.SendMailByKey('SellMail2', [curPlayer.GetID()], addItemList) SyncSuperGiftInfo(curPlayer) return True def SyncSuperGiftInfo(curPlayer): startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SuperGiftStartTime) if not startTime: return packData = ChPyNetSendPack.tagMCSuperGiftInfo() packData.StartTime = startTime NetPackCommon.SendFakePack(curPlayer, packData) return def CheckSuperGiftBuy(curPlayer, giftID): #³¬ÖµÀñ°üÊÇ·ñ¿É¹ºÂò startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SuperGiftStartTime) if not startTime: return superGiftTimeDict = dict(IpyGameDataPY.GetFuncEvalCfg('SuperGiftTimeList')) totalDay = superGiftTimeDict.get(giftID, 0) if not totalDay: return curTime = int(time.time()) if (curTime - startTime)/86400 >= totalDay: #ÒѽáÊø return return True ## É̵ênpcid # @param curPlayer Íæ¼ÒʵÀý # @return def GetCurTradeTagNPC(curPlayer): curActionNPCID = -1 # µ±Ç°É̵êµÄnpcid tradeTagNPC = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_TradeTagNPC) # Ô¶³ÌÉ̵ê if not tradeTagNPC: return GetDirectNpcID() # É̵ênpcidÓ뵱ǰ¶Ô»°npc¶ÔÓ¦ elif CheckTradeTagNPC(curPlayer, tradeTagNPC): return tradeTagNPC else: GameWorld.ErrLog("GetCurStoreItemList:trade tag NPC not match:%s"%tradeTagNPC, curPlayer.GetPlayerID()) return curActionNPCID ## ÅжϼǼµÄÉ̵ênpcidÊÇ·ñÕýÈ· # @param curPlayer Íæ¼ÒʵÀý # @param tradeTagNPC # @return def CheckTradeTagNPC(curPlayer, tradeTagNPC): curActionObj = curPlayer.GetActionObj() if not curActionObj: return False if curActionObj.GetGameObjType() != IPY_GameWorld.gotNPC: return False curActionNPC = GameWorld.GetNPCManager().GetNPCByIndex(curActionObj.GetIndex()) if curActionNPC.GetNPCID() != tradeTagNPC: return False 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 Íæ¼ÒʵÀý # @param tick ʱ¼ä´Á # @return ·µ»ØÖµÕæ, Âß¼­ÔËÐгɹ¦ # @remarks ³öÊÛÎïÆ· def SellItem(curPlayer, tick): #1¼ì²éʼþ·¢ÉúµÄ˳Ðò sendData = IPY_GameWorld.IPY_CPlayerSellItem() packType = sendData.GetPackType() itemIndex = sendData.GetItemIndex() shopType = ChConfig.Def_ShopType_NpcShop return SellPackItem(curPlayer, packType, [itemIndex], shopType) #// A3 11 ÅúÁ¿³öÊÛÎïÆ· #tagCMSellItem # #struct tagCMSellItem #{ # tagHead Head; # BYTE PackType; //±³°üÀàÐÍ # BYTE Count; //Ë÷ÒýÊýÁ¿ # BYTE ItemIndex[Count]; //ÎïÆ·Ë÷Òý #}; def OnSellManyItem(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) packType = clientData.PackType ItemIndexList = clientData.ItemIndex if not ItemIndexList: return shopType = ChConfig.Def_ShopType_NpcShop isOk = SellPackItem(curPlayer, packType, ItemIndexList, shopType) if isOk: curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitKeySell, 1) return #--------------------------------------------------------------------- ##³öÊÛÖ¸¶¨±³°üÎïÆ· # @param curPlayer Íæ¼ÒʵÀý # @param packType ±³°üÀàÐÍ # @param itemIndex ÎïÆ·Ë÷Òý # @param shopType É̵êÀàÐÍ,1NPCÉ̵꣬2Ô¶³Ì··ÊÛ # @return ·µ»ØÖµÕæ, ¼ì²éͨ¹ý # @remarks ³öÊÛÖ¸¶¨±³°üÎïÆ· def SellPackItem(curPlayer, packType, itemIndexList, shopType): totalSellPrice = 0 backPack = curPlayer.GetItemManager().GetPack(packType) if backPack == None: return False hasSellOK = False notForceRecordEquipTypeList = range(ChConfig.Def_ItemType_retWeapon, ChConfig.Def_ItemType_retNeck) for itemIndex in itemIndexList: curItem = backPack.GetAt(itemIndex) if not __CheckItemSell(curPlayer, curItem): continue hasSellOK = True #µ±Ç°ÎïÆ·ÊýÁ¿ curItemCount = curItem.GetCount() #itemName = curItem.GetName() #»ñµÃµ¥¸öÎïÆ·ÏúÊÛ¼Û¸ñ curItemSellPrice, curItemSellType = __GetItemSellPrice(curPlayer, curItem) #»ñµÃÕû×éÏúÊÛ¼Û¸ñ curAllItemSellPrice = int(curItemSellPrice) * curItemCount totalSellPrice += curAllItemSellPrice #GameWorld.Log('curItemSellPrice=%s,curAllItemSellPrice=%s,curItemCount=%s'%(curItemSellPrice,curAllItemSellPrice,curItemCount)) #=========================================================================================== # #ÒòÈռǼǼ¹ý´ó, Ìí¼Ó¼Ç¼ɸѡÌõ¼þ # if ItemControler.ItemNeedRecord(curItem): # #Ïêϸ¼Ç¼װ±¸ÐÅÏ¢ # DataRecordPack.DR_GetMoneyBySellPackItem(curPlayer, curItemSellType, curAllItemSellPrice) #=========================================================================================== isForceDR = curItem.GetType() not in notForceRecordEquipTypeList and not ItemControler.ItemNotNeedRecord(curItem) #ÎïÆ·Ïûʧ ItemCommon.DelItem(curPlayer, curItem, curItemCount, False, ChConfig.ItemDel_SellPackItem, isForceDR=isForceDR) #PutItemInBuyBackPack(curPlayer, curItem) if not hasSellOK: return False #Íæ¼ÒÇ®Ôö¼Ó addDataDict = {} PlayerControl.GiveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, totalSellPrice, ChConfig.Def_GiveMoney_SellPackItem, addDataDict, False) PlayerControl.NotifyCode(curPlayer, "GetMoney01", [IPY_GameWorld.TYPE_Price_Silver_Money, totalSellPrice]) return True ## ÊÛÂôÎïÆ·»Ø¹º±³°üµÄ´¦Àí, ·ÅÈë¿Õλ²»µþ¼Ó(±¾ÏîĿûÓлعº£¬ÏÈÆÁ±Î) # @param None # @return None def PutItemInBuyBackPack(curPlayer, curItem): return itemIndexs = str(curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_DelPackIndex)) backPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptRecycle) emptyIndex = ItemCommon.GetEmptyIndexInPack(curPlayer, IPY_GameWorld.rptRecycle) if emptyIndex == -1: #Çå³ý¾ÉÎïÆ· emptyIndex = int(itemIndexs[0]) - 1 item = backPack.GetAt(emptyIndex) item.Clear() itemIndexs = itemIndexs[1:] else: # Çå¿Õ¿Õ¸ñλ·À·¶, ·ÀÖ¹Òì³£Çé¿öÎïÆ·Ïûʧ¶øÃ»ÓÐÖØÖñê¼Çλµ¼ÖÂÊýÖµÔ½½ç itemIndexs = itemIndexs.replace(str(emptyIndex + 1), '') item = backPack.GetAt(emptyIndex) itemIndexs = "%s%s"%(itemIndexs, emptyIndex + 1) #·ÅÈëÐÂÎïÆ· item.PutIn(curItem) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_DelPackIndex, int(itemIndexs)) return ##¼ì²éÎïÆ·ÊÇ·ñ¿ÉÒÔ³öÊÛ # @param curPlayer Íæ¼ÒʵÀý # @param curItem ÎïÆ·ÊµÀý # @return ·µ»ØÖµÕæ, ¼ì²éͨ¹ý # @remarks ¼ì²éÎïÆ·ÊÇ·ñ¿ÉÒÔ³öÊÛ def __CheckItemSell(curPlayer, curItem) : if not ItemCommon.CheckItemCanUse(curItem): PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_644055") return if ItemControler.IsEventItem(curItem): PlayerControl.NotifyCode(curPlayer, "itemuse_chenxin_31379") return if curItem.GetCanSell() == 0: #²»ÄܳöÊÛµÄÎïÆ·,ÎÞ·¨³öÊÛ PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_272921") return #»ñµÃµ¥¸öÎïÆ·ÏúÊÛ¼Û¸ñ itemPrice , priceType = __GetItemSellPrice(curPlayer, curItem) itemPrice = int(itemPrice) * curItem.GetCount() if not itemPrice or not priceType: PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_272921") return if not PlayerControl.CanGiveMoney(curPlayer, priceType, itemPrice): # ¶Ô²»Æð£¬ÄúЯ´øµÄ½ðÇ®ÒѾ­´ïÉÏÏÞ,²Ù×÷ÎÞЧ #PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_609765") return return True #--------------------------------------------------------------------- ##»ñµÃÎïÆ·µÄ³öÊÛ¼Û¸ñ # @param curPlayer Íæ¼ÒʵÀý # @param curItem ÎïÆ·ÊµÀý # @return ·µ»ØÖµ, ÎïÆ·µÄ³öÊÛ¼Û¸ñ # @remarks »ñµÃÎïÆ·µÄ³öÊÛ¼Û¸ñ def __GetItemSellPrice(curPlayer, curItem): #ΪÅäºÏ¿Í»§¶Ë,½øÐÐÒÔÏÂÂß¼­(ÏòÉÏÈ¡Õû) #2012-03-26 jiang Ä;ÃÕâÀï²»½øÐгýChConfig.Def_EndureRepairParameterµÄת»»¸ÃÓй«Ê½×Ô¼º¼ÆËã #curItemEndure = curItem.GetCurDurg() #curItemMaxEndure = curItem.GetMaxEndure() # Ð޸Ĵ˺¯ÊýÇëͬʱÐÞ¸Ä ÍÑ»ú¹Ò³öÊÛ #µ±Ç°ÎïÆ·¼Û¸ñ Ô­¼Û³öÊÛ 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 ·µ»ØÖµÕæ, ¼ì²éͨ¹ý # @remarks ¼ì²éÍæ¼Ò¿É·ñ¿ªÊ¼NPCʼþ def CheckPlayerCanStateEvent(curPlayer): if curPlayer.GetPlayerAction() not in ChConfig.Def_Player_DoEvent_State : #CannotDoing ¶Ô²»Æð£¬Äúµ±Ç°×´Ì¬ÎÞ·¨½øÐд˲Ù×÷£¬²Ù×÷ÎÞЧ PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_740826") return False return True #--------------------------------------------------------------------- ##¼ì²éÎïÆ·ÊÇ·ñ¿ÉÒÔ·ÅÈëºÏ³É±³°ü. # @param curItem ÎïÆ·ÊµÀý # @return ²¼¶ûÖµ # @remarks ¼ì²éÎïÆ·ÊÇ·ñ¿ÉÒÔ·ÅÈëºÏ³É±³°ü def __CheckItemCanPutInComposePack(curItem): return curItem.GetType() in ChConfig.Def_Compose_Can_Put_List #--------------------------------------------------------------------- ##ͨÓñ³°ü·ÅÈë²Ù×÷ # @param curPlayer Íæ¼ÒʵÀý # @param srcBackpack Æðµã±³°ü # @param desBackPack Ä¿±ê±³°ü # @param srcIndex ÆðµãË÷Òý # @param destIndex Ä¿±êË÷Òý # @param putItemCount ·ÅÈëÊýÁ¿ # @param tick ʱ¼ä´Á # @return ·µ»ØÖµÎÞÒâÒå # @remarks ͨÓñ³°ü·ÅÈë²Ù×÷ def BackpackOperate(curPlayer, srcBackpack, desBackPack, srcIndex, destIndex, putItemCount, tick): #»ñµÃÐèÒª²Ù×÷µÄÎïÆ·µÄÎïÆ· scrItem = __GetBackPackOperateItem(curPlayer, srcBackpack, desBackPack, srcIndex) if scrItem == None: return itemControl = ItemControler.PlayerItemControler(curPlayer) if not itemControl.CanPutInItem(desBackPack, scrItem.GetItemTypeID(), putItemCount, scrItem.GetIsBind()): PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [desBackPack]) return #ÍÏ×§ÎïÆ· ItemControler.DragItem(curPlayer, srcBackpack, srcIndex, desBackPack, destIndex, putItemCount) return #--------------------------------------------------------------------- ##ͨÓñ³°ü²Ù×÷¼ì²é # @param scrItem ·ÅÈëÎïÆ· # @param desBackPack Ä¿±ê±³°ü # @return ²¼¶ûÖµ # @remarks ͨÓñ³°ü²Ù×÷¼ì²é def __CheckBackPackOperate(scrItem, desBackPack): #ÌØÊâ¼ì²é if desBackPack in ChConfig.Def_ComposePack_List: if not __CheckItemCanPutInComposePack(scrItem): GameWorld.ErrLog('BackpackOperate ItemErr = %s, ItemType = %s'%(scrItem.GetItemTypeID(), scrItem.GetType())) return False return True #--------------------------------------------------------------------- ##»ñµÃ±³°üµ±Ç°²Ù×÷µÄÎïÆ· # @param curPlayer Íæ¼ÒʵÀý # @param srcBackpack Æðʼ±³°ü # @param desBackPack Ä¿µÄ±³°ü # @param srcIndex ÆðʼÎïÆ·Ë÷Òý # @return ²Ù×÷ÎïÆ·ÊµÀý»òÕßNone # @remarks »ñµÃ±³°üµ±Ç°²Ù×÷µÄÎïÆ· def __GetBackPackOperateItem(curPlayer, srcBackpack, desBackPack, srcIndex): #²Ù×÷±³°ü¼ì²é if srcBackpack not in ChConfig.Def_BackpackOperate_List or desBackPack not in ChConfig.Def_BackpackOperate_List: GameWorld.ErrLog('PackItemExchange packErr, srcBackpack = %s, \ desBackPack = %s'%(srcBackpack, desBackPack), curPlayer.GetID()) return #»ñµÃ·ÅÈëµÄÎïÆ· scrItem = curPlayer.GetItemManager().GetPack(srcBackpack).GetAt(srcIndex) #---ÎïÆ·¼ì²é--- if not ItemCommon.CheckItemCanUse(scrItem): return #ÌØÊâ¼ì²é if not __CheckBackPackOperate(scrItem, desBackPack): return return scrItem #--------------------------------------------------------------------- ##ͨÓñ³°ü½»»»²Ù×÷ # @param curPlayer Íæ¼ÒʵÀý # @param srcBackpack Æðµã±³°ü # @param destBackPack Ä¿±ê±³°ü # @param srcIndex ÆðµãË÷Òý # @param destIndex Ä¿±êË÷Òý # @param tick ʱ¼ä´Á # @return ·µ»ØÖµÎÞÒâÒå # @remarks ͨÓñ³°ü½»»»²Ù×÷ def PackItemExchange(curPlayer, srcBackpack, destBackPack, srcIndex, destIndex, tick): #»ñµÃÐèÒª²Ù×÷µÄÎïÆ·µÄÎïÆ· scrItem = __GetBackPackOperateItem(curPlayer, srcBackpack, destBackPack, srcIndex) if scrItem == None: return #---Ñé֤Ŀ±ê±³°ü¸ñ×Ó-- destItem = curPlayer.GetItemManager().GetPack(destBackPack).GetAt(destIndex) #Ä¿±ê¸ñ×ÓÖ»ÑéÖ¤Ëø¶¨, ¿ÉÒÔÔÊÐí¿Õλ if destItem == None or destItem.GetIsLocked(): return ItemCommon.DoLogicSwitchItem(curPlayer, scrItem, destItem, destBackPack) return ## »ñµÃ½ðÇ®¸¶·Ñ×Öµä # @param moneyList ½ðÇ®Áбí [½ðÇ®ÀàÐÍ£¬ ½ðÇ®ÊýÁ¿£¬¡£¡£¡£] # @param payMoneyDict ½ðÇ®ÀÛ¼Ó×Öµä # @return ½ðÇ®ÀÛ¼Ó×Öµä # @remarks »ñµÃ½ðÇ®¸¶·Ñ×Öµä def GetPayMoneyDict(moneyList, payMoneyDict={}): length = len(moneyList) for index in range(0, length, 2): moneyType = moneyList[index] money = moneyList[index + 1] payMoney = payMoneyDict.get(moneyType) if payMoney == None: payMoneyDict[moneyType] = money else: payMoneyDict[moneyType] += money return payMoneyDict ## ¼ì²é½ðÇ® # @param curPlayer Íæ¼Ò # @param payMoneyDict ¸¶Ç®×Öµä # @return BOOLÊÇ·ñ×ã¹» # @remarks ¼ì²é½ðÇ® def CheckPayMoney(curPlayer, payMoneyDict): for moneyType, money in payMoneyDict.items(): #ÑéÖ¤ÊÖÐø·Ñ if not PlayerControl.HaveMoney(curPlayer, moneyType, money): return False return True