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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package GM.Commands.SetRedPacket
#
# @todo:ÉèÖúì°ü
# @author hxp
# @date 2019-01-29
# @version 1.0
#
# ÏêϸÃèÊö: ÉèÖúì°ü
#
#-------------------------------------------------------------------------------
#"""Version = 2019-01-29 16:00"""
#-------------------------------------------------------------------------------
 
import PlayerFamilyRedPacket
import ShareDefine
import GameWorld
import IpyGameDataPY
import PlayerDBGSEvent
 
 
## GMÃüÁîÖ´ÐÐÈë¿Ú
#  @param curPlayer µ±Ç°Íæ¼Ò
#  @param paramList ²ÎÊýÁбí
#  @return None or True
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def OnExec(curPlayer, paramList):
    if not paramList:
        return
    
#    GameWorld.DebugAnswer(curPlayer, "ÖØÖÃËùÓкì°üÁìÈ¡:SetRedPacket 0")
#    GameWorld.DebugAnswer(curPlayer, "Çå³ýËùÓÐÀàÐͺì°ü:SetRedPacket 0 0")
#    GameWorld.DebugAnswer(curPlayer, "Çå³ýÖ¸¶¨ÀàÐͺì°ü:SetRedPacket 0 ÀàÐÍA ÀàÐÍB ...")
    
    paramA = paramList[0]
    paramB = paramList[1] if len(paramList) > 1 else None
    # ÖØÖÃËùÓкì°üÊý¾Ý
    if paramA == 0:
        PlayerFamilyRedPacket.g_allRecordDict = {}
        PlayerFamilyRedPacket.g_grabDataDict = {}
        PlayerFamilyRedPacket.g_redPackCountDict = {}
        
        universalRecMgr = GameWorld.GetUniversalRecMgr()
        # Çå³ýËùÓÐÀàÐͺì°ü
        if paramB == 0:
            universalRecMgr.Delete(ShareDefine.Def_UniversalGameRecType_FamilyRedPacketAllRecord)
            __ResetSendState([])
            GameWorld.DebugAnswer(curPlayer, "Çå³ýËùÓÐÀàÐͺì°üOK!")
            
        # Çå³ýÖ¸¶¨ÀàÐͺì°ü
        elif paramB:
            delTypeList = paramList[1:]
            allRecordList = universalRecMgr.GetTypeList(ShareDefine.Def_UniversalGameRecType_FamilyRedPacketAllRecord)
            delCount = 0
            for index in xrange(allRecordList.Count()):
                universalRecData = allRecordList.At(index - delCount)
                strValue1 = universalRecData.GetStrValue1()
                strValue1List = strValue1.split('|')
                getWay = int(strValue1List[3])
                if getWay not in delTypeList:
                    continue
                allRecordList.Delete(index)
                delCount += 1
            __ResetSendState(delTypeList)
            GameWorld.DebugAnswer(curPlayer, "Çå³ýÖ¸¶¨ÀàÐͺì°üOK!%s,ÌõÊý:%s" % (delTypeList, delCount))
            
        # Çå³ýÇÀµÄ¼Ç¼
        universalRecMgr.Delete(ShareDefine.Def_UniversalGameRecType_FamilyRedPacketGrabRecord)
        PlayerFamilyRedPacket.NotifyRedPacketInfo(curPlayer)
        GameWorld.DebugAnswer(curPlayer, "Çå³ýËùÓкì°üÁìÈ¡¼Ç¼OK!")
        return
    
    
    return
 
def __ResetSendState(delTypeList):
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    for index in xrange(ipyDataMgr.GetFamilyRedPackCount()):
        ipyData = ipyDataMgr.GetFamilyRedPackByIndex(index)
        if delTypeList and ipyData.GetGetType() not in delTypeList:
            continue
        redPackID = ipyData.GetID()
        if PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerFamilyRedPacket.DBKey_RedPacketSend % redPackID):
            PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerFamilyRedPacket.DBKey_RedPacketSend % redPackID, 0)
    return