xdh
2019-01-28 8305e47be942c376430044332780e6e69a3c7a7f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/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, 1, [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