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
#!/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 GameWorld
import IpyGameDataPY
import PlayerDBGSEvent
import PlayerFamilyRedPacket
import ChPyNetSendPack
import NetPackCommon
 
 
## GMÃüÁîÖ´ÐÐÈë¿Ú
#  @param curPlayer µ±Ç°Íæ¼Ò
#  @param paramList ²ÎÊýÁбí
#  @return None or True
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def OnExec(curPlayer, paramList):
    GameWorld.DebugLog("Ö´ÐÐGameServer->SetRedPacket: %s" % paramList)
    if not paramList:
#        GameWorld.DebugAnswer(curPlayer, "Çå³ýËùÓÐÀàÐͺì°ü:SetRedPacket 0")
#        GameWorld.DebugAnswer(curPlayer, "Çå³ýÖ¸¶¨ÀàÐͺì°ü:SetRedPacket 0 ÀàÐÍA ÀàÐÍB ...")
#        GameWorld.DebugAnswer(curPlayer, "·¢ËÍÈ«·þϵͳºì°ü:SetRedPacket 36 ºì°ü±àºÅ ¸öÊý")
#        GameWorld.DebugAnswer(curPlayer, "È«·þϵͳºì°ü±àºÅ:126~130")
#        GameWorld.DebugAnswer(curPlayer, "ºì°üÀàÐÍ:36-È«·þºì°ü;33-½ÚÈճɾÍ")
        return
    
    paramA = paramList[0]
    if paramA == 0:
        delRedIDList = []
        delTypeList = paramList[1:]
        redpacketMgr = PlayerFamilyRedPacket.GetRedpacketMgr()
        for redPacketID, redPacketObj in redpacketMgr.allRedPacketDict.items():
            getWay = redPacketObj.getWay
            if delTypeList and getWay not in delTypeList:
                continue
            delRedIDList.append(redPacketID)
            redpacketMgr.allRedPacketDict.pop(redPacketID)
            familyID = redPacketObj.familyID
            if familyID in redpacketMgr.familyRedPacketDict:
                redpacketMgr.DelFamilyRedPacketID(familyID, redPacketID)
            redpacketMgr.DelActiveRedPacketID(getWay, redPacketID)
            for playerID in redpacketMgr.playerNosendRedPacketIDInfo.keys():
                redpacketMgr.DelPlayerNosendRedPacketID(playerID, getWay, redPacketID)
            for playerID in redpacketMgr.playerCanGetRedPacketIDInfo.keys():
                redpacketMgr.DelPlayerCanGetRedPacketID(playerID, getWay, redPacketID)
            if redPacketID in redpacketMgr.notifyAllServerRedPacketIDList:
                redpacketMgr.notifyAllServerRedPacketIDList.remove(redPacketID)
                
        __ResetSendState(delTypeList)
        GameWorld.DebugAnswer(curPlayer, "Çå³ýÀàÐͺì°üOK!%s,ÌõÊý:%s" % (delTypeList, len(delRedIDList)))
        
        if delRedIDList:
            sendPack = ChPyNetSendPack.tagGCRedPacketDel()
            sendPack.DelRedPacketID = delRedIDList
            sendPack.Cnt = len(delRedIDList)
            
            playerManager = GameWorld.GetPlayerManager()
            for index in xrange(playerManager.GetPlayerCount()):
                curPlayer = playerManager.GetPlayerByIndex(index)
                if not curPlayer.GetID():
                    continue
                NetPackCommon.SendFakePack(curPlayer, sendPack)
                
    elif paramA == 36:
        redPackID = paramList[1] if len(paramList) > 1 else 0
        sendCount = paramList[2] if len(paramList) > 2 else 0
        sendCount = min(100, sendCount)
        canSendRedPacketIDList = range(126, 130 + 1) + []
        if redPackID not in canSendRedPacketIDList or not sendCount:
            GameWorld.DebugAnswer(curPlayer, "·¢ËÍÈ«·þϵͳºì°ü²ÎÊý´íÎó!")
            return
        for _ in xrange(sendCount):
            PlayerFamilyRedPacket.CreateSystemRedPacket(redPackID)
        GameWorld.DebugAnswer(curPlayer, "³É¹¦·¢Ëͺì°ü±àºÅ:%s ¹²:%s¸ö" % (redPackID, sendCount))
        
    else:
        GameWorld.DebugAnswer(curPlayer, "ºì°üÃüÁî²ÎÊý´íÎó!")
    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