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
136
137
138
139
140
141
142
143
144
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package GM.Commands.ChatBox
#
# @todo:ÁÄÌì¿ò
# @author hxp
# @date 2024-09-13
# @version 1.0
#
# ÏêϸÃèÊö: ÁÄÌì¿ò
#
#-------------------------------------------------------------------------------
#"""Version = 2024-09-13 16:30"""
#-------------------------------------------------------------------------------
 
import GameWorld
import IpyGameDataPY
import PlayerControl
import PlayerChatBox
import ChConfig
 
#Âß¼­ÊµÏÖ
## GMÃüÁîÖ´ÐÐÈë¿Ú
#  @param curPlayer µ±Ç°Íæ¼Ò
#  @param msgList ²ÎÊýÁбí
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def OnExec(curPlayer, msgList):
    
    if not msgList:
        GameWorld.DebugAnswer(curPlayer, "---------- %s" % GameWorld.GetCurrentDataTimeStr())
        GameWorld.DebugAnswer(curPlayer, "Ìí¼ÓÆøÅÝ¿ò: ChatBox b1 ÆøÅÝ¿òID [ÓÐЧÃë]")
        GameWorld.DebugAnswer(curPlayer, "ɾ³ýÆøÅÝ¿ò: ChatBox b0 [ÆøÅÝ¿òID]")
        GameWorld.DebugAnswer(curPlayer, "ÆøÅÝ¿òÐǼ¶: ChatBox bs ÆøÅÝ¿òID ÐǼ¶")
        GameWorld.DebugAnswer(curPlayer, "Ìí¼Ó±íÇé°ü: ChatBox e1 ±íÇé°üID [ÓÐЧÃë]")
        GameWorld.DebugAnswer(curPlayer, "ɾ³ý±íÇé°ü: ChatBox e0 [±íÇé°üID]")
        GameWorld.DebugAnswer(curPlayer, "ÓÐЧÃë:²»Ìî¶Á±í,0-ÓÀ¾Ã,>0Ö¸¶¨ÓÐЧÃë")
        return
    
    syncBoxIDList = []
    packIDList = []
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    value1 = msgList[0]
    
    # É¾³ýÆøÅÝ¿ò
    if value1 == "b0":
        boxID = msgList[1] if len(msgList) > 1 else 0
        if not boxID:
            for index in range(ipyDataMgr.GetChatBubbleBoxCount()):
                ipyData = ipyDataMgr.GetChatBubbleBoxByIndex(index)
                boxID = ipyData.GetBoxID()
                if ipyData.GetUnlockDefault():
                    continue
                if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_ChatBubbleBoxState, boxID):
                    continue
                GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_ChatBubbleBoxState, boxID, 0)
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ChatBoxEndTime % boxID, 0)
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ChatBoxStar % boxID, 0)
                syncBoxIDList.append(boxID)
        else:
            ipyData = IpyGameDataPY.GetIpyGameData("ChatBubbleBox", boxID)
            if not ipyData:
                GameWorld.DebugAnswer(curPlayer, "¸ÃÆøÅÝ¿ò²»´æÔÚ:%s" % boxID)
                return
            if ipyData.GetUnlockDefault():
                GameWorld.DebugAnswer(curPlayer, "¸ÃÆøÅÝ¿òĬÈϼ¤»î:%s" % boxID)
                return
            GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_ChatBubbleBoxState, boxID, 0)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ChatBoxEndTime % boxID, 0)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ChatBoxStar % boxID, 0)
            syncBoxIDList.append(boxID)
        GameWorld.DebugAnswer(curPlayer, "ɾ³ýÆøÅÝ¿ò:%s" % syncBoxIDList)
        
    # Ìí¼ÓÆøÅÝ¿ò
    elif value1 == "b1":
        boxID = msgList[1] if len(msgList) > 1 else 0
        expireTimes = msgList[2] if len(msgList) > 2 else None
        if PlayerChatBox.AddChatBox(curPlayer, boxID, expireTimes):
            endTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ChatBoxEndTime % boxID)
            endTimeStr = "ÓÀ¾Ã" if not endTime else GameWorld.ChangeTimeNumToStr(endTime)
            GameWorld.DebugAnswer(curPlayer, "Ìí¼ÓÆøÅÝ¿ò³É¹¦:%s,µ½ÆÚ:%s" % (boxID, endTimeStr))
        else:
            GameWorld.DebugAnswer(curPlayer, "Ìí¼ÓÆøÅÝ¿òʧ°Ü:%s" % (boxID))
            
    # ÆøÅÝ¿òÐǼ¶
    elif value1 == "bs":
        boxID = msgList[1] if len(msgList) > 1 else 0
        boxStar = msgList[2] if len(msgList) > 2 else 0
        if boxStar:
            starIpyData = IpyGameDataPY.GetIpyGameData("ChatBubbleBoxStar", boxID, boxStar)
            if not starIpyData:
                GameWorld.DebugAnswer(curPlayer, "ÆøÅÝ¿òÐǼ¶²»´æÔÚ:%s,star:%s" % (boxID, boxStar))
                return
        GameWorld.DebugAnswer(curPlayer, "ÉèÖÃÆøÅÝ¿òÐǼ¶:%s,ÐÇ:%s" % (boxID, boxStar))
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ChatBoxStar % boxID, boxStar)
        syncBoxIDList.append(boxID)
        
    # É¾³ý±íÇé°ü
    elif value1 == "e0":
        packID = msgList[1] if len(msgList) > 1 else 0
        if not packID:
            for index in range(ipyDataMgr.GetEmojiPackCount()):
                ipyData = ipyDataMgr.GetEmojiPackByIndex(index)
                packID = ipyData.GetEmojiPackID()
                if ipyData.GetUnlockDefault():
                    continue
                if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_EmojiPackState, packID):
                    continue
                GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_EmojiPackState, packID, 0)
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EmojiPackEndTime % packID, 0)
                packIDList.append(packID)
        else:
            ipyData = IpyGameDataPY.GetIpyGameData("EmojiPack", packID)
            if not ipyData:
                GameWorld.DebugAnswer(curPlayer, "¸Ã±íÇé°ü²»´æÔÚ:%s" % packID)
                return
            if ipyData.GetUnlockDefault():
                GameWorld.DebugAnswer(curPlayer, "¸Ã±íÇé°üĬÈϼ¤»î:%s" % packID)
                return
            GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_EmojiPackState, packID, 0)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EmojiPackEndTime % packID, 0)
            packIDList.append(packID)
        GameWorld.DebugAnswer(curPlayer, "ɾ³ý±íÇé°ü:%s" % packIDList)
        
    # Ìí¼Ó±íÇé°ü
    elif value1 == "e1":
        packID = msgList[1] if len(msgList) > 1 else 0
        expireTimes = msgList[2] if len(msgList) > 2 else None
        if PlayerChatBox.AddEmojiPack(curPlayer, packID, expireTimes):
            endTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EmojiPackEndTime % packID)
            endTimeStr = "ÓÀ¾Ã" if not endTime else GameWorld.ChangeTimeNumToStr(endTime)
            GameWorld.DebugAnswer(curPlayer, "Ìí¼Ó±íÇé°ü³É¹¦:%s,µ½ÆÚ:%s" % (packID, endTimeStr))
        else:
            GameWorld.DebugAnswer(curPlayer, "Ìí¼Ó±íÇé°üʧ°Ü:%s" % (packID))
            
    if syncBoxIDList:
        PlayerChatBox.RefreshBoxAttr(curPlayer)
        PlayerChatBox.SyncChatBoxInfo(curPlayer, syncBoxIDList)
        
    if packIDList:
        PlayerChatBox.SyncEmojiPackInfo(curPlayer, packIDList)
    return