#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package GM.Commands.OpenFunc # # @todo:¹¦ÄÜ¿ªÆô # @author hxp # @date 2017-12-21 # @version 1.0 # # ÏêϸÃèÊö: ¹¦ÄÜ¿ªÆô # #------------------------------------------------------------------------------- #"""Version = 2017-12-21 12:00""" #------------------------------------------------------------------------------- import GameWorld import PlayerControl import PlayerPrestigeSys import PlayerMagicWeapon import IpyGameDataPY import GameFuncComm import ChConfig import ShareDefine ## GMÃüÁîÖ´ÐÐÈë¿Ú # @param curPlayer µ±Ç°Íæ¼Ò # @param list ²ÎÊýÁбí # @return None # @remarks º¯ÊýÏêϸ˵Ã÷. def OnExec(curPlayer, cmdList): GameWorld.DebugAnswer(curPlayer, "--------------") if not cmdList: GameWorld.DebugAnswer(curPlayer, "¿ªÆôËùÓй¦ÄÜ: OpenFunc 1") GameWorld.DebugAnswer(curPlayer, "¿ªÆôÖ¸¶¨¹¦ÄÜ: OpenFunc 1 ¹¦ÄÜID") GameWorld.DebugAnswer(curPlayer, "¹Ø±ÕËùÓй¦ÄÜ: OpenFunc 0") GameWorld.DebugAnswer(curPlayer, "¹Ø±ÕÖ¸¶¨¹¦ÄÜ: OpenFunc 0 ¹¦ÄÜID") else: state = cmdList[0] if not state: closeFuncID = cmdList[1] if len(cmdList) > 1 else 0 DoGMCloseFunc(curPlayer, closeFuncID) else: openFuncID = cmdList[1] if len(cmdList) > 1 else 0 DoGMOpenFunc(curPlayer, openFuncID) PrintFuncOpenState(curPlayer) return def PrintFuncOpenState(curPlayer): openFuncIDList = [] unOpenFuncIDList = [] ipyDataMgr = IpyGameDataPY.IPY_Data() funcOpenLVCount = ipyDataMgr.GetFuncOpenLVCount() for i in xrange(funcOpenLVCount): ipyData = ipyDataMgr.GetFuncOpenLVByIndex(i) funcID = ipyData.GetFuncId() isOpen = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_GameFuncFirstTouch, funcID, True) if isOpen: openFuncIDList.append(funcID) else: unOpenFuncIDList.append(funcID) GameWorld.DebugAnswer(curPlayer, "ÒÑ¿ªÆôµÄ¹¦ÄÜÊý: %s/%s" % (len(openFuncIDList), funcOpenLVCount)) if len(openFuncIDList) < len(unOpenFuncIDList): for i in range((funcOpenLVCount/10) + 1): openList = openFuncIDList[i*10:(i+1)*10] if not openList: break GameWorld.DebugAnswer(curPlayer, "%s" % openList) GameWorld.DebugAnswer(curPlayer, "먦ÆôµÄ¹¦ÄÜ: %s/%s" % (len(unOpenFuncIDList), funcOpenLVCount)) if len(unOpenFuncIDList) < len(openFuncIDList): for i in range((funcOpenLVCount/10) + 1): unOpenList = unOpenFuncIDList[i*10:(i+1)*10] if not unOpenList: break GameWorld.DebugAnswer(curPlayer, "%s" % unOpenList) return def DoGMOpenFunc(curPlayer, openFuncID=0): openFuncIDList = [] if openFuncID: if GameFuncComm.GetFuncCanUse(curPlayer, openFuncID): GameWorld.DebugLog("¹¦ÄÜÒÑ¿ªÆô£¬²»ÐèÒªÖØ¸´¼¤»î!openFuncID=%s" % openFuncID, curPlayer.GetPlayerID()) return openFuncIDList = [openFuncID] if openFuncIDList: needLV, needMagicWeaponIDList, needRealmLV, needMissionIDList = __GetOpenFuncLimit(openFuncIDList) if needMagicWeaponIDList: openFuncIDList.append(ShareDefine.GameFuncID_MagicWeapon) if needRealmLV: openFuncIDList.append(ShareDefine.GameFuncID_Official) needLV, needMagicWeaponIDList, needRealmLV, needMissionIDList = __GetOpenFuncLimit(openFuncIDList) GameWorld.DebugLog("GM´¦ÀíµÈ¼¶¿ªÆô¹¦ÄÜ: openFuncID=%s,openFuncIDList=%s,needLV=%s" % (openFuncID, openFuncIDList, needLV), curPlayer.GetPlayerID()) # ÓÅÏÈ´¦ÀíÉý¼¶ if needLV: preLV = needLV - 1 curPlayer.SetLV(preLV) PlayerControl.SetPlayerTotalExp(curPlayer, PlayerControl.GetTotalExpByPlayerLv(preLV)) PlayerControl.PlayerControl(curPlayer).PlayerLvUp() GameWorld.DebugLog("GM´¦Àí·¨±¦¿ªÆô¹¦ÄÜ: needMagicWeaponIDList=%s" % needMagicWeaponIDList, curPlayer.GetPlayerID()) for mwIDKey in needMagicWeaponIDList: mwID, mwLV = mwIDKey/100, mwIDKey%100 for lv in xrange(mwLV+1): PlayerMagicWeapon.DoActiveMW(curPlayer, mwID, lv) GameWorld.DebugLog("GM´¦Àí¾³½ç¿ªÆô¹¦ÄÜ: needRealmLV=%s" % needRealmLV, curPlayer.GetPlayerID()) if needRealmLV: curPlayer.SetOfficialRank(needRealmLV - 1) PlayerPrestigeSys.DoRealmLVUpLogic(curPlayer) GameWorld.DebugLog("GM´¦ÀíÈÎÎñ¿ªÆô¹¦ÄÜ: needMissionIDList=%s" % needMissionIDList, curPlayer.GetPlayerID()) #×îºóÇ¿ÖÆ´¥·¢Ò»´Î #if needMissionIDList: GameFuncComm.DoFuncOpenLogic(curPlayer, needMissionIDList) return def __GetOpenFuncLimit(openFuncIDList): maxLV = IpyGameDataPY.GetFuncCfg("PlayerMaxLV") needLV = 0 needRealmLV = 0 needMissionIDList = [] needMagicWeaponIDList = [] ipyDataMgr = IpyGameDataPY.IPY_Data() funcOpenLVCount = ipyDataMgr.GetFuncOpenLVCount() for i in xrange(funcOpenLVCount): ipyData = ipyDataMgr.GetFuncOpenLVByIndex(i) funcID = ipyData.GetFuncId() if openFuncIDList and funcID not in openFuncIDList: continue limitLV = ipyData.GetLimitLV() if limitLV and limitLV <= maxLV and needLV < limitLV: needLV = limitLV limitMagicWeaponID = ipyData.GetLimitMagicWeapon() if limitMagicWeaponID and limitMagicWeaponID not in needMagicWeaponIDList: needMagicWeaponIDList.append(limitMagicWeaponID) limitRealmLV = ipyData.GetLimiRealmLV() if limitRealmLV and needRealmLV < limitRealmLV: needRealmLV = limitRealmLV limitMissionID = ipyData.GetLimitMissionID() if limitMissionID and limitMissionID not in needMissionIDList: needMissionIDList.append(limitMissionID) return needLV, needMagicWeaponIDList, needRealmLV, needMissionIDList def DoGMCloseFunc(curPlayer, closeFuncID): ## GM¹Ø±Õ¹¦ÄÜ if not closeFuncID: curPlayer.SetLV(1) curPlayer.SetOfficialRank(0) ipyDataMgr = IpyGameDataPY.IPY_Data() for i in xrange(ipyDataMgr.GetTreasureCount()): ipyData = ipyDataMgr.GetTreasureByIndex(i) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MagicWeaponLV % ipyData.GetID(), 0) for keyNum in xrange(8): PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_GameFuncFirstTouch % keyNum, 0) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_GameFuncAwardState % keyNum, 0) needLV, needMagicWeaponIDList, needRealmLV, needMissionIDList = __GetOpenFuncLimit([]) for missionID in needMissionIDList: PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_MissionFinish % missionID, 0) GameFuncComm.Sync_FuncOpenState(curPlayer, isSyncUnOpen=True) GameWorld.DebugAnswer(curPlayer, "¹Ø±ÕËùÓй¦ÄÜ!") return if not GameFuncComm.GetFuncCanUse(curPlayer, closeFuncID): GameWorld.DebugLog("¹¦ÄÜÒѹرգ¬²»ÐèÒªÖØ¸´¹Ø±Õ! closeFuncID=%s" % closeFuncID, curPlayer.GetPlayerID()) return ipyData = IpyGameDataPY.GetIpyGameData("FuncOpenLV", closeFuncID) if not ipyData: return limitLV = ipyData.GetLimitLV() if limitLV and curPlayer.GetLV() >= limitLV: curPlayer.SetLV(max(1, limitLV - 1)) PlayerControl.SetPlayerTotalExp(curPlayer, 0) limitRealmLV = ipyData.GetLimiRealmLV() if limitRealmLV and curPlayer.GetOfficialRank() >= limitRealmLV: curPlayer.SetOfficialRank(max(0, limitRealmLV - 1)) limitMagicWeaponID = ipyData.GetLimitMagicWeapon() if limitMagicWeaponID: mwID = limitMagicWeaponID / 100 PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MagicWeaponLV % mwID, 0) limitMissionID = ipyData.GetLimitMissionID() if limitMissionID: PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_MissionFinish % limitMissionID, 0) GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_GameFuncFirstTouch, closeFuncID, 0) GameFuncComm.Sync_FuncOpenState(curPlayer, isSyncUnOpen=True) GameWorld.DebugAnswer(curPlayer, "¹Ø±Õ¹¦ÄÜ: %s" % closeFuncID) return