#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package Player.GameFuncComm # # @todo:ÓÎÏ·¹¦ÄÜ¿ØÖÆͨÓà # @author hxp # @date 2016-06-02 # @version 1.5 # # @change: "2016-08-19 16:30" hxp Éý¼¶¿ªÆô¹¦ÄÜÂß¼­´¦Àí # @change: "2016-08-30 15:00" hxp Ôö¼Ó¹¦ÄÜ¿ªÆôºóÉý¼¶ÐèÒª´¦ÀíµÄÂß¼­ # @change: "2016-12-08 12:00" hxp ¿ªÆôµÈ¼¶Ï¸»¯ # @change: "2016-12-09 12:00" hxp Éý¼¶´¥·¢¹ó×åÂß¼­ # @change: "2017-12-21 12:00" hxp ÊÖÓΰæÐÞ¸Ä(¼¤»î״̬¸ÄΪ·þÎñ¶Ë¼Ç¼ÊÇ·ñ¼¤»î£¬¼ò»¯Âß¼­£¬Ö§³Ö¶àÖÖ¼¤»î·½Ê½) # # ÏêϸÃèÊö: ÓÎÏ·¹¦ÄÜ¿ØÖÆͨÓà # #------------------------------------------------------------------------------- #"""Version = 2017-12-21 12:00""" #------------------------------------------------------------------------------- import ChConfig import ChPyNetSendPack import GameWorld import NetPackCommon import PlayerGodWeapon import PlayerHorse import PlayerPet import ShareDefine import IpyGameDataPY import PlayerMagicWeapon import PlayerRefineStove import PlayerControl import PlayerPrestigeSys import PlayerBillboard import PlayerTreasure import PlayerSignDay import PlayerGoldGift import PlayerEquipDecompose import PlayerCrossChampionship import PlayerFreeGoods import FunctionNPCCommon import PlayerGreatMaster import IPY_GameWorld import ItemCommon import ItemControler import PlayerLianTi import PlayerArena import PlayerFaQi import PlayerGuaji import PlayerTJG # ¹¦ÄÜ¿ªÆôÐèÖ´Ðеĺ¯Êý{¹¦ÄÜID:Ö´Ðк¯Êý, ...} º¯ÊýÐè·µ»ØÊÇ·ñ¼¤»î³É¹¦, ¹¦ÄÜ¿ªÆôÓÐÐèÒª´¦Àí¹¦ÄÜÂß¼­µÄÕâÀïÔö¼Óº¯Êýµ÷ÓÃÅäÖü´¿É FuncOpenLogicDict = { ShareDefine.GameFuncID_Horse:lambda curObj:PlayerHorse.DoHorseOpen(curObj), ShareDefine.GameFuncID_GodWeapon:lambda curObj:PlayerGodWeapon.DoGodWeaponOpen(curObj), ShareDefine.GameFuncID_Pet:lambda curObj:PlayerPet.DoPetOpen(curObj), ShareDefine.GameFuncID_MagicWeapon:lambda curObj:PlayerMagicWeapon.DoMagicWeaponOpen(curObj), ShareDefine.GameFuncID_RefineStove:lambda curObj:PlayerRefineStove.DoRefineStoveOpen(curObj), ShareDefine.GameFuncID_Official:lambda curObj:PlayerPrestigeSys.DoOfficialOpen(curObj), ShareDefine.GameFuncID_Billboard:lambda curObj:PlayerBillboard.DoBillboardOpen(curObj), ShareDefine.GameFuncID_SignDay:lambda curObj:PlayerSignDay.DoSignDayOpen(curObj), ShareDefine.GameFuncID_Treasure:lambda curObj:PlayerTreasure.DoTreasureOpen(curObj), ShareDefine.GameFuncID_FirstGoldTip:lambda curObj:PlayerGoldGift.DoFirstGoldOpen(curObj), ShareDefine.GameFuncID_EquipDecompose:lambda curObj:PlayerEquipDecompose.DoEquipDecomposeOpen(curObj), ShareDefine.GameFuncID_FreeGoods:lambda curObj:PlayerFreeGoods.DoFreeGoodsOpen(curObj), ShareDefine.GameFuncID_OSSail:lambda curObj:FunctionNPCCommon.OSSaleOpenMail(curObj), ShareDefine.GameFuncID_AddPoint:lambda curObj:PlayerControl.DoAddPointOpen(curObj), ShareDefine.GameFuncID_Talent:lambda curObj:PlayerGreatMaster.DoTalentOpen(curObj), #ShareDefine.GameFuncID_TJG:lambda curObj:PlayerTJG.DoTJGOpen(curObj), ShareDefine.GameFuncID_Arena:lambda curObj:PlayerArena.DoArenaOpen(curObj), ShareDefine.GameFuncID_FaQi:lambda curObj:PlayerFaQi.DoFaQiOpen(curObj), ShareDefine.GameFuncID_LianTi:lambda curObj:PlayerLianTi.DoLianTiOpen(curObj), ShareDefine.GameFuncID_Championship:lambda curObj:PlayerCrossChampionship.DoChampionshipOpen(curObj), ShareDefine.GameFuncID_Guaji:lambda curObj:PlayerGuaji.DoGuajiOpen(curObj), #ShareDefine.GameFuncID_RunDaily:lambda curObj:FBCommon.DoFuncOpen_RunDaily(curObj), #ShareDefine.GameFuncID_RunFamily:lambda curObj:FBCommon.DoFuncOpen_RunFamily(curObj), #ShareDefine.GameFuncID_RefineExp:lambda curObj:Operate_PlayerBuyZhenQi.DoFuncOpen_RefineExp(curObj), #ShareDefine.GameFuncID_RefineMoney:lambda curObj:Operate_PlayerBuyZhenQi.DoFuncOpen_RefineMoney(curObj), #ShareDefine.GameFuncID_ArrestTask:lambda curObj:PlayerArrestTask.DoArrestTaslOpen(curObj), } ## ×¢Ò⣺¹¦ÄÜ¿ªÆôÐèÖ´Ðеĺ¯Êý ¼° ¹¦ÄÜ¿ªÆôºóÉý¼¶Âß¼­ Ö»»áÖ´ÐÐÆäÖÐÒ»¸ö ## ×¢Ò⣺¹¦ÄÜ¿ªÆôÐèÖ´Ðеĺ¯Êý ¼° ¹¦ÄÜ¿ªÆôºóÉý¼¶Âß¼­ Ö»»áÖ´ÐÐÆäÖÐÒ»¸ö ## ×¢Ò⣺¹¦ÄÜ¿ªÆôÐèÖ´Ðеĺ¯Êý ¼° ¹¦ÄÜ¿ªÆôºóÉý¼¶Âß¼­ Ö»»áÖ´ÐÐÆäÖÐÒ»¸ö # ¹¦ÄÜ¿ªÆôºóÉý¼¶Âß¼­ ÐèÒª´¦ÀíµÄº¯Êý {¹¦ÄÜID:Ö´Ðк¯Êý, ...} #FuncLVUpLogicDict = { # ShareDefine.GameFuncID_Pet:lambda curObj:PlayerPet.DoLVUPLogic_Pet(curObj), # } # ¹¦ÄÜ¿ªÆôÐèҪͬ²½µ½GameServerµÄ FuncOpenNotifyGameServer = [ShareDefine.GameFuncID_Championship, ShareDefine.GameFuncID_MineArea] def GetFuncOpenLVIpyData(funcID): return IpyGameDataPY.GetIpyGameData("FuncOpenLV", funcID) def DoFuncOpenLogic(curPlayer, finishMissionIDList=[]): '''Ö´Ðд¥·¢¹¦ÄÜ¿ªÆôÂß¼­ @param finishMissionIDList: Íê³ÉµÄÈÎÎñIDÁбí ''' #GameWorld.DebugLog("Ö´Ðд¥·¢¹¦ÄÜ¿ªÆôÂß¼­: finishMissionIDList=%s" % finishMissionIDList, curPlayer.GetPlayerID()) openFuncIDList = [] curLV = curPlayer.GetLV() ipyGameData = IpyGameDataPY.IPY_Data() funcOpenLVCount = ipyGameData.GetFuncOpenLVCount() for i in xrange(funcOpenLVCount): ipyData = ipyGameData.GetFuncOpenLVByIndex(i) funcID = ipyData.GetFuncId() limitMissionID = ipyData.GetLimitMissionID() if limitMissionID and limitMissionID in finishMissionIDList: if not curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_MissionFinish % limitMissionID): PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_MissionFinish % limitMissionID, 1) GameWorld.DebugLog(" ÉèÖù¦ÄÜ¿ªÆôËùÐèÈÎÎñÍê³É: funcID=%s,limitMissionID=%s" % (funcID, limitMissionID), curPlayer.GetPlayerID()) isOpen = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_GameFuncFirstTouch, funcID, True) if isOpen: #GameWorld.DebugLog(" ¹¦ÄÜÒѾ­¿ªÆô¹ý, ²»ÐèÒªÖظ´´¥·¢¿ªÆô! funcID=%s" % (funcID), curPlayer.GetPlayerID()) continue limitLV = ipyData.GetLimitLV() if limitLV and curLV < limitLV: continue limitMagicWeapon = ipyData.GetLimitMagicWeapon() limitMagicWeaponID, limitMagicWeaponlv = limitMagicWeapon/100, limitMagicWeapon%100 if limitMagicWeaponID and not PlayerMagicWeapon.GetIsActiveMagicWeapon(curPlayer, limitMagicWeaponID, limitMagicWeaponlv): continue limitRealmLV = ipyData.GetLimiRealmLV() if limitRealmLV and curPlayer.GetOfficialRank() < limitRealmLV: continue limitMissionID = ipyData.GetLimitMissionID() if limitMissionID and not curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_MissionFinish % limitMissionID): continue limitVIPLV = ipyData.GetLimitVIPLV() if limitVIPLV and curPlayer.GetVIPLv() < limitVIPLV: continue # ÏȸüÐÂÖµÔÙ´¦Àí¿ªÆôÂß¼­£¬²»ÄÜ¿ÉÄܵ¼ÖÂÔÚ¹¦ÄÜ¿ªÆôÂß¼­ÖÐÔÙ¿ªÆô¹¦ÄÜÒý·¢µÄµÝ¹éËÀÑ­»· befValue, updValue = GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_GameFuncFirstTouch, funcID, 1) if befValue == updValue: continue GameWorld.DebugLog(" ¹¦ÄÜ¿ªÆô£ºfuncID=%s,befValue=%s(%s),updValue=%s(%s)" % (funcID, befValue, str(bin(befValue)[2:]), updValue, str(bin(updValue)[2:])), curPlayer.GetPlayerID()) if funcID in FuncOpenLogicDict: FuncOpenLogicDict[funcID](curPlayer) mailKey = ipyData.GetMailKey() if mailKey: PlayerControl.SendMailByKey(mailKey, [curPlayer.GetPlayerID()], []) openFuncIDList.append(funcID) if openFuncIDList: Sync_FuncOpenState(curPlayer, openFuncIDList) notifyGameServerFuncIDList = [] for funcID in openFuncIDList: if funcID not in FuncOpenNotifyGameServer: continue notifyGameServerFuncIDList.append(funcID) if notifyGameServerFuncIDList: GameWorld.DebugLog("notifyGameServerFuncIDList=%s" % notifyGameServerFuncIDList) msgInfo = str(notifyGameServerFuncIDList) GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0, "FuncOpen", msgInfo, len(msgInfo)) return ## ¹¦ÄÜÊÇ·ñ¿ÉÓà def GetFuncCanUse(curPlayer, funcID): return GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_GameFuncFirstTouch, funcID, True) ## »ñÈ¡¹¦ÄÜÏÞÖƵȼ¶(µÈ¼¶Ìõ¼þΪȫ¾Ö) def GetFuncLimitLV(funcID): ipyData = IpyGameDataPY.GetIpyGameData("FuncOpenLV", funcID) if not ipyData: return 0 return ipyData.GetLimitLV() def GetFuncOpenAward(curPlayer, funcID): ## ÁìÈ¡¹¦ÄÜ¿ªÆô½±Àø ipyData = IpyGameDataPY.GetIpyGameData('FunctionForecast', funcID) if not ipyData: return getState = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_GameFuncAwardState, funcID) if getState: return awardDict = ipyData.GetAward() job = curPlayer.GetJob() itemList = awardDict.get(str(job)) if not itemList: return # ¼ì²é±³°ü needSpace = len(itemList) packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace) if needSpace > packSpace: PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371") return GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_GameFuncAwardState, funcID, 1) # ¸øÎïÆ· for itemID, itemCount in itemList: ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem]) Sync_FuncOpenState(curPlayer, [funcID]) return def Sync_FuncOpenState(curPlayer, syncFuncIDList=None, isSyncUnOpen=False): ## ֪ͨ¹¦ÄÜÊ״δ¥·¢Çé¿ö if syncFuncIDList == None: syncFuncIDList = [] ipyGameData = IpyGameDataPY.IPY_Data() for i in xrange(ipyGameData.GetFuncOpenLVCount()): ipyData = ipyGameData.GetFuncOpenLVByIndex(i) funcID = ipyData.GetFuncId() syncFuncIDList.append(funcID) funcStatePack = ChPyNetSendPack.tagMCFuncOpenStateList() funcStatePack.Clear() funcStatePack.FuncStateList = [] for funcID in syncFuncIDList: openState = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_GameFuncFirstTouch, funcID) if not openState and not isSyncUnOpen: continue funcOpenState = ChPyNetSendPack.tagMCFuncOpenState() funcOpenState.Clear() funcOpenState.FuncID = funcID funcOpenState.State = openState funcOpenState.AwardState = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_GameFuncAwardState, funcID) funcStatePack.FuncStateList.append(funcOpenState) funcCount = len(funcStatePack.FuncStateList) funcStatePack.FuncCount = funcCount if funcCount: NetPackCommon.SendFakePack(curPlayer, funcStatePack) #GameWorld.DebugLog("Sync_FuncFirstTouch funcCount=%s" % funcCount) return