hxp
2 天以前 388823edfe6308cba6f76ca6dc4f20022c5cb2be
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
##@package PlayerLoginDayAward
#
# @todo: ÀۼƵǽÀñ
# @author xdh
# @date 2018-03-05 20:30
# @version 1.0
#
# ÏêϸÃèÊö:
#"""Version = 2018-03-05 20:30"""
#------------------------------------------------------------------------------ 
 
import ChConfig
import GameWorld
import NetPackCommon
import ChPyNetSendPack
import ItemCommon
import IPY_GameWorld
import PlayerControl
import ItemControler
import DataRecordPack
import IpyGameDataPY
 
 
## ondayÌí¼ÓÀۼƵǽÌìÊý
#  @param curPlayer
#  @return None
def NotePlayerLoginDayCnt(curPlayer):
    cnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoginDayCnt) + 1
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoginDayCnt, cnt)
    
    NotifyPlayerLoginDayAward(curPlayer)
    return
 
 
 
## µÇ½֪ͨÀۼƽ±ÀøÐÅÏ¢
#  @param curPlayer
#  @return None
def OnLoginNotifyLoginDayAward(curPlayer):
    NotifyPlayerLoginDayAward(curPlayer)
    return
    
    
## Í¨ÖªÀۼƵǽÐÅÏ¢
#  @param curPlayer
#  @return None
def NotifyPlayerLoginDayAward(curPlayer):
    sendPack = ChPyNetSendPack.tagMCTotalLoginDayCntInfo()
    sendPack.Clear()
    sendPack.DayCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoginDayCnt)    
    sendPack.AwardInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoginDayAward)
    
    #֪ͨ¿Í»§¶Ëʱ¼ä
    NetPackCommon.SendFakePack(curPlayer, sendPack)
    return
 
 
## ÁìÈ¡ÀۼƵǽ½±Àø
#  @param curPlayer
#  @return None
def GetTotalLoginDayAward(index, clientPack, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    # µÚÒ»ÌìΪ1
    cnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoginDayCnt)
    
    index = clientPack.Index
    if index > cnt:
        #µÇ½´ÎÊý²»¹»
        return
    
    awardInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoginDayAward)
    awardMark = pow(2, index-1)
    if awardInfo & awardMark:
        #ÒÑÁìÈ¡
        return
    
    ipyData = IpyGameDataPY.GetIpyGameData('LoginDayAward', index)
    if not ipyData:
        return
    job = curPlayer.GetJob()
    awardDict = ipyData.GetReward()
    if str(job) not in awardDict:
        return
    itemList = awardDict[str(job)]
    
    # ¼ì²é±³°ü
    needSpace = len(itemList)
    packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
    if needSpace > packSpace:
        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")
        return
    
    # ¸øÎïÆ·
    for itemID, itemCount in itemList:
        ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem])
    ItemControler.NotifyGiveAwardInfo(curPlayer, itemList, "LoginDayAward")
    
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoginDayAward, awardInfo | awardMark)
    
 
    # ¼Ç¼Áìȡʼþ
    DataRecordPack.DR_LoginDayAward(curPlayer, index)
    
    NotifyPlayerLoginDayAward(curPlayer)
    return