#!/usr/bin/python # -*- coding: GBK -*- # # ##@package PlayerBourseTube.py # # @todo:Íæ¼Ò½»Ò×Ëù µØͼ·þÎñÆ÷´¦ÀíÄ£¿é # # @author xmnathan # @date 2010-01-01 21:30 # @version 1.6 # @note: # @change: "2014-05-21 20:00" xmnathan Íæ¼Ò½»Ò×Ëù # @change: "2014-06-03 13:00" xmnathan ÈÕÖ¾Êä³ö¸Ä³ÉDebug # @change: "2014-07-14 18:30" hxp Ôö¼ÓÿÈÕ»îÔ¾¶È # @change: "2015-01-14 00:30" hxp Ôö¼Ó½»Ò×ʼþ»ã±¨ # @change: "2015-08-24 11:00" xdh Ôö¼Ó½»Ò×´ÎÊý³É¾Í # @change: "2017-03-27 16:00" hxp Ôö¼Ó¹ó×å½µµÍ½»Ò×ËùÊÖÐø·ÑÌØȨ #------------------------------------------------------------------------------ #"""Version = 2017-03-27 16:00""" #------------------------------------------------------------------------------ import IPY_GameWorld import GameWorld import ChConfig import ShareDefine import NetPackCommon import PlayerControl import ItemCommon import ItemControler import ChMapToGamePyPack import PlayerVip import PlayerSuccess import IpyGameDataPY import EventShell #------------------------------------------------------------------------------ #// B5 01 ½»Ò×ËùÍæ¼ÒÉϼÜÎïÆ·#tagCMPYPlayerSellBourseItem #struct tagCMPYPlayerSellBourseItem #{ # tagHead Head; # BYTE ItemIndex; //ÎïÆ·ÔÚ±³°üÖÐË÷Òý # WORD Count; //³öÊÛÊýÁ¿ # BYTE PriceType; //³öÊÛ¼Û¸ñÀàÐÍ # DWORD PriceCount; //³öÊÛ¼Û¸ñ # char Pwd[8]; //½»Ò×ÃÜÂë #}; def OnPlayerSellBourseItem(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) GameWorld.DebugLog("Bourse### PlayerSellBourseItem in, PlayerID %s"%curPlayer.GetPlayerID()) playerPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem) itemIndex = clientData.ItemIndex curItem = playerPack.GetAt(itemIndex) if curItem.IsEmpty(): #´íÎóµÄ±³°üË÷Òý GameWorld.DebugLog("Bourse### PlayerSellBourseItem ItemIndex = %s IsEmpty"%itemIndex) return if curItem.GetIsBind() or (not curItem.GetCanTrade()): #°ó¶¨ÎïÆ·²»¿É½»Ò× GameWorld.DebugLog("Bourse### PlayerSellBourseItem ItemIndex = %s IsBind"%itemIndex) return if curItem.GetIsSuite(): GameWorld.DebugLog("Bourse### PlayerSellBourseItem ItemIndex = %s IsSuite"%itemIndex) return if clientData.PriceCount <= 0: GameWorld.DebugLog("Bourse### PlayerSellBourseItem PriceCount <= 0"%itemIndex) return if clientData.Count > curItem.GetCount(): GameWorld.Log(' Bourse### ¿Í»§¶Ë·¢µÄÎïÆ·ÊýÁ¿´óÓÚʵ¼ÊÊýÁ¿£¡£¡') sellCount = min(clientData.Count, curItem.GetCount()) if sellCount <= 0: return password = clientData.Pwd #ÅжÏvipȨÏÞ if password and not PlayerVip.GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_BoursePwd): GameWorld.DebugLog("Bourse### PlayerSellBourseItem VIPȨÏÞ²»×㣬²»ÄÜÓÃÉϼÜÃÜÂë") return #·¢°üµ½GameServer//02 01 ѯÎÊÊÇ·ñ¿ÉÒÔÌí¼ÓÍæ¼Ò½»Ò×ËùÎïÆ·#tagMGCheckAddPlayerBourseItem sendPack = ChMapToGamePyPack.tagMGCheckAddPlayerBourseItem() sendPack.PlayerID = curPlayer.GetPlayerID() sendPack.ItemIndex = itemIndex sendPack.Count = sellCount sendPack.PriceType = clientData.PriceType sendPack.PriceCount = clientData.PriceCount sendPack.Pwd = password NetPackCommon.SendPyPackToGameServer(sendPack) GameWorld.DebugLog("Bourse### PlayerSellBourseItem out") return ##//02 01 ²éѯÍæ¼ÒÊÇ·ñ¿ÉÒÔÌí¼Ó½»Ò×ËùÎïÆ·½á¹û#tagGMCheckAddPlayerBourseItemResult # @param curPackData:·â°ü½á¹¹Ìå # @param tick:ʱ¼ä´Á # @return None def OnGMCheckAddPlayerBourseItemResult(curPackData, tick): GameWorld.DebugLog("Bourse### GMCheckAddPlayerBourseItemResult in, PlayerID %s"%curPackData.PlayerID) curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(curPackData.PlayerID) if not curPlayer: GameWorld.DebugLog("Bourse### GMCheckAddPlayerBourseItemResult curPlayer no found, PlayerID %s"%curPackData.PlayerID) return if not curPackData.Result: #Íæ¼Ò½»Ò×ËùÎïÆ·ÒÑ´ïÉÏÏÞ£¬ÎÞ·¨¼ÌÐøÌí¼Ó PlayerControl.NotifyCode(curPlayer, 'GeRen_liubo_318640', []) GameWorld.DebugLog('Bourse### GMCheckAddPlayerBourseItemResult False') return playerPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem) curItem = playerPack.GetAt(curPackData.ItemIndex) if curItem.IsEmpty(): #´íÎóµÄ±³°üË÷Òý GameWorld.DebugLog('Bourse### GMCheckAddPlayerBourseItemResult ItemIndex=%s IsEmpty'%curPackData.ItemIndex) return minPrice = IpyGameDataPY.GetFuncCfg('BoursePriceLimit') maxPrice = IpyGameDataPY.GetFuncCfg('BoursePriceLimit', 2) if curPackData.PriceCount < minPrice or curPackData.PriceCount > maxPrice: GameWorld.DebugLog('Bourse### GMCheckAddPlayerBourseItemResult PriceCount = %s err'%curPackData.PriceCount) return singleItem = curItem.GetItem() #if singleItem.GetPackCount() == curPackData.Count: #·¢°üµ½GameServer//02 02 Íæ¼Ò½»Ò×ËùÌí¼Ó³öÊÛµÄÎïÆ·#tagMGAddPlayerSellBourseItem sendPack = ChMapToGamePyPack.tagMGAddPlayerSellBourseItem() sendPack.PlayerID = curPackData.PlayerID sendPack.PlayerName = curPlayer.GetPlayerName() sendPack.OperateInfo = curPlayer.GetOperateInfo() sendPack.ItemGUID = singleItem.GetGUID() sendPack.Count = curPackData.Count #roleItem sendPack.PriceType = curPackData.PriceType sendPack.PriceCount = curPackData.PriceCount sendPack.ItemTypeID = singleItem.GetItemTypeID() sendPack.UserData = singleItem.GetUserData() sendPack.UserDataLen = len(sendPack.UserData) sendPack.Type = singleItem.GetType() sendPack.EquipPlace = singleItem.GetEquipPlace() sendPack.LV = singleItem.GetLV() sendPack.UseLV = singleItem.GetUseLV() sendPack.JobLimit = singleItem.GetJobLimit() sendPack.SuiteID = singleItem.GetSuiteID() sendPack.ItemQuality = singleItem.GetItemQuality() sendPack.ItemColor = singleItem.GetItemColor() sendPack.Pwd = curPackData.Pwd sendPack.EquipGS = ItemCommon.GetEquipGearScore(curItem) itemName = singleItem.GetName().decode(ShareDefine.Def_Game_Character_Encoding).encode(GameWorld.GetCharacterEncoding()) sendPack.ItemName = itemName NetPackCommon.SendPyPackToGameServer(sendPack) #¿ÛÎïÆ· ItemCommon.DelItem(curPlayer, curItem, curPackData.Count, True, ChConfig.ItemDel_AddBourseItem, isForceDR=True) GameWorld.DebugLog('Bourse### GMCheckAddPlayerBourseItemResult out 1 ItemGUID=%s'%sendPack.ItemGUID) #ÉϼÜÎïÆ·ÈÎÎñ½Ó¿Ú EventShell.EventRespons_AddBourseItem(curPlayer) return #------------------------------------------------------------------------------ ##//1B 03 ½»Ò×ËùÍæ¼ÒÈ¡ÏÂÕýÔÚ³öÊÛµÄÎïÆ·»ò³öÊÛÊÕÒæ#tagCMPlayerRecaptureBourseItem #tagCMPlayerRecaptureBourseItem #struct tagCMPlayerRecaptureBourseItem #{ # tagHead Head; # char ItemGUID[40]; #}; ##1B 03 ½»Ò×ËùÍæ¼ÒÈ¡ÏÂÕýÔÚ³öÊÛµÄÎïÆ·»ò³öÊÛÊÕÒæ#tagCMPlayerRecaptureBourseItem # @param index:Íæ¼ÒË÷Òý # @param tick:ʱ¼ä´Á # @return None def OnPlayerRecaptureBourseItem(index, tick): clientPack = IPY_GameWorld.IPY_CMPlayerRecaptureBourseItem() curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) GameWorld.DebugLog("Bourse### PlayerRecaptureBourseItem in, PlayerID %s"%curPlayer.GetPlayerID()) #»ñÈ¡±³°ü¿Õ¸ñ itemPackSpace = ItemControler.GetItemPackSpace(curPlayer,IPY_GameWorld.rptItem) #·¢°üµ½GameServer//02 05 ½»Ò×ËùÍæ¼ÒÈ¡ÏÂÕýÔÚ³öÊÛµÄÎïÆ·»ò³öÊÛÊÕÒæ#tagMGPlayerRecaptureBourseItem sendPack = ChMapToGamePyPack.tagMGPlayerRecaptureBourseItem() sendPack.PlayerID = curPlayer.GetPlayerID() sendPack.ItemGUID = clientPack.GetItemGUID() sendPack.PackSpaceCount = itemPackSpace #//µ±Ç°±³°üÊ£Óà¿Õ¼ä GameWorld.DebugLog("Bourse### PlayerRecaptureBourseItem,ItemGUID %s, itemPackSpace = %s"%(sendPack.ItemGUID, itemPackSpace)) NetPackCommon.SendPyPackToGameServer(sendPack) GameWorld.DebugLog("Bourse### PlayerRecaptureBourseItem out") return #------------------------------------------------------------------------------ ##//02 03 Íæ¼Ò»ñÈ¡½»Ò×ËùÎïÆ·½á¹û#tagGMGiveBourseItem # @param curPackData:·â°ü½á¹¹Ìå # @param tick:ʱ¼ä´Á # @return None def OnGMGiveBourseItem(curPackData, tick): GameWorld.DebugLog("Bourse### GMGiveBourseItem in, PlayerID %s"%curPackData.PlayerID) curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(curPackData.PlayerID) if not curPlayer: GameWorld.DebugLog("Bourse### GMGiveBourseItem , PlayerID %s no found "%curPackData.PlayerID) return #´´½¨ÐÂÎïÆ· curCreateItem = ItemCommon.CreateSingleItem(curPackData.ItemID) if not curCreateItem: return #if curPackData.PriceCount > 0: # #ÐèÒª¸¶Ç®¹ºÂò²ÅÄÜ»ñµÃÎïÆ· # infoDict = {ChConfig.Def_Cost_Reason_SonKey:curCreateItem.GetName()} # PlayerControl.PayMoney(curPlayer, curPackData.PriceType, curPackData.PriceCount, ChConfig.Def_Cost_BourseBuy, infoDict) # ¹ºÂòÎïÆ·Ëã½»Ò×Ëù»îÔ¾¶È # »îÔ¾¶È #PlayerActivity.AddActivityFinishCnt(curPlayer, ShareDefine.ActivityNum_FinishTrade) #¸øÎïÆ· ItemControler.SetItemCount(curCreateItem, curPackData.Count) if curCreateItem.GetPackCount() == 1: ItemCommon.SetEquipGearScore(curCreateItem, curPackData.EquipGS) curCreateItem.SetUserData(curPackData.UserData, curPackData.UserDataLen) GameWorld.DebugLog("Bourse### GMGiveBourseItem curPackData.ItemID %s"%(curPackData.ItemID)) #·ÅÈëÎïÆ· ItemControler.PlayerItemControler(curPlayer).PutInItem(IPY_GameWorld.rptItem, curCreateItem, event=[ChConfig.ItemGive_BourseItem, True, {}]) GameWorld.DebugLog("Bourse### GMGiveBourseItem out") return def OnGivePlayerBourseGains(curPlayer, msgList): ## Íæ¼Ò»ñµÃ½»Ò×ËùÊÕÒæ moneyType, priceCount, itemName, soldOutTime, itemInfo = msgList bourseTaxPer = PlayerVip.GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_BourseTax) chargeMin = IpyGameDataPY.GetFuncCfg('BourseCharge') taxMoney = max(chargeMin, priceCount * bourseTaxPer / ShareDefine.Def_MaxRateValue) giveMoney = priceCount - taxMoney if giveMoney <0: GameWorld.ErrLog(' ½»Ò×Ëù¸ø½»Ò×ÊÕÒæÒì³£ priceCount=%s, taxMoney=%s'%(priceCount, taxMoney), curPlayer.GetID()) return GameWorld.DebugLog('·¢ËͲ¹³¥Óʼþ ÎïÆ·ÊÛ³ö Ç®·¢¸øÍæ¼Ò') PlayerControl.SendMailByKey('BourseSellVip' if curPlayer.GetVIPLv() else 'BourseSell', [curPlayer.GetPlayerID()], [], [itemName, priceCount, taxMoney, giveMoney], giveMoney) # # addDataDict = {ChConfig.Def_Give_Reason_SonKey:"Gains"} # PlayerControl.GiveMoney(curPlayer, moneyType, giveMoney, ChConfig.Def_GiveMoney_Bourse, addDataDict) resultInfo = str([soldOutTime, taxMoney, giveMoney, itemInfo]) GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0, "GivePlayerBourseGainsResult", resultInfo, len(resultInfo)) return ##//02 04 Íæ¼Ò»ñµÃ½»Ò×ËùÊÕÒæ#tagGMGivePlayerBourseGains # @param curPackData:·â°ü½á¹¹Ìå # @param tick:ʱ¼ä´Á # @return None def OnGMGivePlayerBourseGains(curPackData, tick): # GameWorld.DebugLog("Bourse### GMGivePlayerBourseGains in, PlayerID %s"%curPackData.PlayerID) # curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(curPackData.PlayerID) # if not curPlayer: # GameWorld.DebugLog("Bourse### GMGivePlayerBourseGains , PlayerID %s no found "%curPackData.PlayerID) # return # BourseCharge = ReadChConfig.GetEvalChConfig("BourseCharge") # chargeRate, chargeMin= BourseCharge[1] # if poundageReducePer > 0: # chargeRate = int(chargeRate * max(0, 100 - poundageReducePer) / 100.0) # GameWorld.DebugLog("¹ó×å½µµÍ½»Ò×ÊÖÐø·Ñ: poundageReducePer=%s,chargeRate=%s" % (poundageReducePer, chargeRate)) # chargeMoney = max(chargeMin, curPackData.MoneyCount*chargeRate/10000) # # #¸øÍæ¼Ò½»Ò×ËùÊÕÒæ # addDataDict = {ChConfig.Def_Give_Reason_SonKey:"Gains"} # PlayerControl.GiveMoney(curPlayer, curPackData.MoneyType, curPackData.MoneyCount, ChConfig.Def_GiveMoney_Bourse, addDataDict) # GameWorld.DebugLog("Bourse### GMGivePlayerBourseGains out,MoneyType = %s MoneyCount = %s chargeRate = %s chargeMoney %s" # % (curPackData.MoneyType, curPackData.MoneyCount, chargeRate, chargeMoney)) # # ½»Ò×Ëù»ñÈ¡ÊÕÒ棬»ã±¨½»Ò××êʯ # playerName = curPlayer.GetPlayerName() # leftGold = curPlayer.GetGold() # eventParam = "RoleID=%s,Price=%s,TradeType=Get,LeftGold=%s" \ # % (playerName, curPackData.MoneyCount, leftGold) # EventReport.EventReport(ShareDefine.Def_UserAction_TradeGold, eventParam, curPlayer) # # #¿Û³ýÍæ¼Ò½»Ò×ÊÖÐø·Ñ # PlayerControl.PayMoney(curPlayer, curPackData.MoneyType, chargeMoney, ChConfig.Def_Cost_BourseCharge) # # # »ØÊÕÊÕÒæËã½»Ò×Ëù»îÔ¾¶È # # »îÔ¾¶È # PlayerActivity.AddActivityFinishCnt(curPlayer, ShareDefine.ActivityNum_FinishTrade) # # Íê³ÉX´ÎÅÄÂôÐн»Ò×³É¾Í # PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_Exchange, 1) return #------------------------------------------------------------------------------ #// B3 02 ½»Ò×Ëù¹ºÂòÎïÆ·#tagCMPYBuyBourseItem #struct tagCMPYBuyBourseItem #{ # tagHead Head; # char ItemGUID[40]; # char Pwd[8]; //½»Ò×ÃÜÂë #}; ##///B5 02 ½»Ò×Ëù¹ºÂòÎïÆ·#tagCMPYBuyBourseItem # @param index:Íæ¼ÒË÷Òý # @param tick:ʱ¼ä´Á # @return None def OnPlayerBuyBourseItem(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) GameWorld.DebugLog("Bourse### PlayerBuyBourseItem in, PlayerID %s"%curPlayer.GetPlayerID()) itemPackSpace = ItemControler.GetItemPackSpace(curPlayer,IPY_GameWorld.rptItem) if itemPackSpace <= 0: #ûÓпռ乺ÂòÎïÆ· GameWorld.DebugLog("Bourse### PlayerBuyBourseItem , PlayerID %s no space"%curPlayer.GetPlayerID()) return #//02 03 Íæ¼ÒѯÎʹºÂò½»Ò×ËùÎïÆ·#tagMGCheckBuyBourseItem sendPack = ChMapToGamePyPack.tagMGCheckBuyBourseItem() sendPack.PlayerID = curPlayer.GetPlayerID() sendPack.ItemGUID = clientData.ItemGUID sendPack.Pwd = clientData.Pwd GameWorld.DebugLog("Bourse### PlayerBuyBourseItem send ItemGUID %s"%sendPack.ItemGUID) NetPackCommon.SendPyPackToGameServer(sendPack) GameWorld.DebugLog("Bourse### PlayerBuyBourseItem out") return ##//02 02 Íæ¼Ò¹ºÂò½»Ò×ËùÎïÆ·²éѯ½á¹û#tagGMCheckBuyBourseItemResult # @param curPackData:·â°ü½á¹¹Ìå # @param tick:ʱ¼ä´Á # @return None def OnGMCheckBuyBourseItemResult(curPackData, tick): GameWorld.DebugLog("Bourse### GMCheckBuyBourseItemResult in, PlayerID %s"%curPackData.PlayerID) playerName = __CheckBuyBourseItemResult(curPackData) #//02 04 Íæ¼ÒÈ·ÈϹºÂò½»Ò×ËùÎïÆ·#tagMGBuyBourseItemSure sendPack = ChMapToGamePyPack.tagMGBuyBourseItemSure() sendPack.PlayerID = curPackData.PlayerID sendPack.PlayerName = playerName #·¢¿Õ´ú±í¹ºÂòʧ°Ü sendPack.ItemGUID = curPackData.ItemGUID NetPackCommon.SendPyPackToGameServer(sendPack) GameWorld.DebugLog("Bourse### GMCheckBuyBourseItemResult out, PriceCount %s"%curPackData.PriceCount) return def __CheckBuyBourseItemResult(curPackData): curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(curPackData.PlayerID) if not curPlayer: GameWorld.DebugLog("Bourse### GMCheckBuyBourseItemResult , PlayerID %s no found "%curPackData.PlayerID) return '' if curPackData.PriceCount != 0: if not PlayerControl.HaveMoney(curPlayer, curPackData.PriceType, curPackData.PriceCount): GameWorld.DebugLog("Bourse### GMCheckBuyBourseItemResult , ItemGUID %s no enough money %s"%(curPackData.ItemGUID, curPackData.PriceCount)) return '' if curPackData.PriceType == IPY_GameWorld.TYPE_Price_Gold_Money: if not PlayerControl.HaveMoney(curPlayer, ShareDefine.TYPE_Price_BourseMoney, curPackData.PriceCount): curBourseMoney = PlayerControl.GetMoney(curPlayer, ShareDefine.TYPE_Price_BourseMoney) GameWorld.Log("Bourse### GMCheckBuyBourseItemResult , ItemGUID %s no enough bourse money! priceCount=%s,curBourseMoney=%s" % (curPackData.ItemGUID, curPackData.PriceCount, curBourseMoney), curPlayer.GetPlayerID()) return '' #Ïȸ¶Ç®ÔÙ¸øÂô¼ÒÊÕÒæ infoDict = {"ItemGUID":curPackData.ItemGUID} PlayerControl.PayMoney(curPlayer, curPackData.PriceType, curPackData.PriceCount, ChConfig.Def_Cost_BourseBuy, infoDict) return curPlayer.GetPlayerName() return ''