| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package PlayerLVAward  | 
| #  | 
| # @todo: ¼ÇÂ¼Íæ¼ÒµÄµÈ¼¶½±ÀøÐÅÏ¢£¬¶þ½øÖÆÎ»±êʾ£¬Ä¿Ç°ÓÃÁËÒ»¸ö×Öµä  | 
| # @author xdh  | 
| # @date 2018-03-07 13:50  | 
| # ¼òҪ˵Ã÷:  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö:   | 
| #  | 
| """Version = 2018-03-07 13:50"""  | 
| #------------------------------------------------------------------------------   | 
| import GameWorld  | 
| import IPY_GameWorld  | 
| import ItemControler  | 
| import ChConfig  | 
| import ChPyNetSendPack  | 
| import NetPackCommon  | 
| import ItemCommon  | 
| import PlayerControl  | 
| import IpyGameDataPY  | 
| import DataRecordPack  | 
|   | 
|   | 
|   | 
|   | 
| ## ÁìÈ¡Íæ¼ÒµÈ¼¶½±Àø  | 
| #  @param getLV£ºÁìÈ¡µÄµÈ¼¶  | 
| #  @return None  | 
| def GetPlayerLVAward(curPlayer, awardID):  | 
|     ipyData = IpyGameDataPY.GetIpyGameData('LVAward', awardID)  | 
|     if not ipyData:  | 
|         return  | 
|       | 
|     getLV = ipyData.GetLV()  | 
|     # ¼ì²é¿É·ñÁìÈ¡  | 
|       | 
|     # Íæ¼ÒµÈ¼¶Ð¡ÓÚÁìÈ¡µÈ¼¶  | 
|     if curPlayer.GetLV() < getLV:  | 
|         GameWorld.ErrLog("GetLVAward error£ºgetLV=%s greater than heroLV=%s" % (getLV, curPlayer.GetLV()))  | 
|         return  | 
|     awardInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LVAwardGetRecord, 0,  | 
|                                               ChConfig.Def_PDictType_LVAward)  | 
|     vipAwardInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LVAwardVIPGetRecord, 0,  | 
|                                               ChConfig.Def_PDictType_LVAward)  | 
|     awardMark = pow(2, awardID - 1)  | 
|     if awardInfo & awardMark and vipAwardInfo & awardMark:  | 
|         #ÒÑÁìÈ¡  | 
|         GameWorld.DebugLog("ÁìÈ¡Íæ¼ÒµÈ¼¶½±ÀøÒÑÁìÈ¡½±Àø£¡awardID=%s,getLV=%s" % (awardID, getLV))  | 
|         return  | 
|     itemList = []  | 
|     if not awardInfo & awardMark:  | 
|         #·Çvip½±Àø  | 
|         job = curPlayer.GetJob()  | 
|         awardDict = ipyData.GetReward()  | 
|         if str(job) not in awardDict:  | 
|             return  | 
|         itemList += awardDict[str(job)]  | 
|     hasVIPAward = False #ÊÇ·ñÓÐVIP½±Àø  | 
|     if not vipAwardInfo & awardMark:  | 
|         if curPlayer.GetVIPLv() >= ipyData.GetVIPLimit():  | 
|             itemList += ipyData.GetVIPAward()  | 
|             hasVIPAward = True  | 
|     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  | 
|       | 
|     serverLimitCnt = ipyData.GetLimitCnt()  | 
|     if serverLimitCnt > 0:  | 
|         if curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_LvAwardQueryState) == 1:  | 
|             #ÒѾÔÚ²éѯÖÐ, ²»Öظ´²éѯ  | 
|             GameWorld.DebugLog("ÒѾÔÚ²éѯÖÐ, ²»Öظ´²éѯ awardID=%s" % awardID)  | 
|             return  | 
|         cmdStr = '%s' % ([awardID, serverLimitCnt, getLV])  | 
|         GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0,  | 
|                                         "GetPlayerLVAward", cmdStr, len(cmdStr))  | 
|         #ÉèÖÃ״̬²éѯÖÐ  | 
|         curPlayer.SetDict(ChConfig.Def_PlayerKey_LvAwardQueryState, 1)  | 
|         return  | 
|       | 
|     # ¸øÎïÆ·  | 
|     GiveLVAward(curPlayer, awardID, itemList, hasVIPAward)  | 
|     return  | 
|   | 
| def GiveLVAward(curPlayer, awardID, itemList=[], hasVIPAward=False):  | 
|     if not itemList:  | 
|         ipyData = IpyGameDataPY.GetIpyGameData('LVAward', awardID)  | 
|         job = curPlayer.GetJob()  | 
|         awardDict = ipyData.GetReward()  | 
|         itemList = awardDict[str(job)]  | 
|       | 
|     # ¸øÎïÆ·  | 
|     for itemID, itemCount in itemList:  | 
|         ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem])  | 
|           | 
|     # ¸üÐÂÒÑÁìÈ¡³É¹¦±ê¼Ç  | 
|     awardMark = pow(2, awardID - 1)  | 
|     awardInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LVAwardGetRecord, 0,  | 
|                                               ChConfig.Def_PDictType_LVAward)  | 
|     vipAwardInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LVAwardVIPGetRecord, 0,  | 
|                                               ChConfig.Def_PDictType_LVAward)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LVAwardGetRecord, awardInfo | awardMark, ChConfig.Def_PDictType_LVAward)  | 
|     if hasVIPAward:  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LVAwardVIPGetRecord, vipAwardInfo | awardMark, ChConfig.Def_PDictType_LVAward)  | 
|     # Í¨Öª¿Í»§¶Ë  | 
|     Sync_LVAwardGetRecordInfo(curPlayer)  | 
|       | 
|     # ¼Ç¼Áìȡʼþ  | 
|     DataRecordPack.DR_LVAward(curPlayer, awardID)  | 
|     return  | 
|   | 
| ## Í¨ÖªµÈ¼¶½±ÀøÁìÈ¡¼Ç¼ÐÅÏ¢  | 
| #  @param None  | 
| #  @return None  | 
| def Sync_LVAwardGetRecordInfo(curPlayer):  | 
|     sendPack = ChPyNetSendPack.tagMCPlayerLVAwardGetRecord()  | 
|     sendPack.Clear()  | 
|     sendPack.LVAwardGetRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LVAwardGetRecord, 0,  | 
|                                               ChConfig.Def_PDictType_LVAward)  | 
|     sendPack.VIPAwardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LVAwardVIPGetRecord, 0,  | 
|                                               ChConfig.Def_PDictType_LVAward)  | 
|     NetPackCommon.SendFakePack(curPlayer, sendPack)  | 
|     return  | 
|   |