hxp
2024-11-13 141959c90ea475111b1d021d219745c2e246f45e
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package GM.Commands.Face
#
# @todo:Í·ÏñÍ·Ïñ¿ò
# @author hxp
# @date 2024-09-12
# @version 1.0
#
# ÏêϸÃèÊö: Í·ÏñÍ·Ïñ¿ò
#
#-------------------------------------------------------------------------------
#"""Version = 2024-09-12 12:00"""
#-------------------------------------------------------------------------------
 
import GameWorld
import IpyGameDataPY
import PlayerControl
import PlayerFace
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, "Ìí¼ÓÍ·Ïñ: Face f1 Í·ÏñID [ÓÐЧÃë]")
        GameWorld.DebugAnswer(curPlayer, "ɾ³ýÍ·Ïñ: Face f0 [Í·ÏñID]")
        GameWorld.DebugAnswer(curPlayer, "Í·ÏñÐǼ¶: Face fs Í·ÏñID ÐǼ¶")
        GameWorld.DebugAnswer(curPlayer, "Ìí¼ÓÍ·¿ò: Face p1 Í·¿òID [ÓÐЧÃë]")
        GameWorld.DebugAnswer(curPlayer, "ɾ³ýÍ·¿ò: Face p0 [Í·¿òID]")
        GameWorld.DebugAnswer(curPlayer, "Í·¿òÐǼ¶: Face ps Í·¿òID ÐǼ¶")
        GameWorld.DebugAnswer(curPlayer, "ÓÐЧÃë:²»Ìî¶Á±í,0-ÓÀ¾Ã,>0Ö¸¶¨ÓÐЧÃë")
        return
    
    syncFaceIDList = []
    syncFacePicIDList = []
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    value1 = msgList[0]
    
    # É¾³ýÍ·Ïñ
    if value1 == "f0":
        faceID = msgList[1] if len(msgList) > 1 else 0
        if not faceID:
            for index in range(ipyDataMgr.GetPlayerFaceCount()):
                ipyData = ipyDataMgr.GetPlayerFaceByIndex(index)
                faceID = ipyData.GetFaceID()
                if ipyData.GetUnlockDefault():
                    continue
                if ipyData.GetCustomPlayerID():
                    continue
                if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FaceState, faceID):
                    continue
                GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_FaceState, faceID, 0)
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaceEndTime % faceID, 0)
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaceStar % faceID, 0)
                syncFaceIDList.append(faceID)
        else:
            ipyData = IpyGameDataPY.GetIpyGameData("PlayerFace", faceID)
            if not ipyData:
                GameWorld.DebugAnswer(curPlayer, "¸ÃÍ·Ïñ²»´æÔÚ:%s" % faceID)
                return
            if ipyData.GetUnlockDefault():
                GameWorld.DebugAnswer(curPlayer, "¸ÃÍ·ÏñĬÈϼ¤»î:%s" % faceID)
                return
            if ipyData.GetCustomPlayerID():
                GameWorld.DebugAnswer(curPlayer, "¶¨ÖÆÍ·Ïñ²»´¦Àí:%s" % faceID)
                return
            GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_FaceState, faceID, 0)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaceEndTime % faceID, 0)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaceStar % faceID, 0)
            syncFaceIDList.append(faceID)
        GameWorld.DebugAnswer(curPlayer, "ɾ³ýÍ·Ïñ:%s" % syncFaceIDList)
        
    # Ìí¼ÓÍ·Ïñ
    elif value1 == "f1":
        faceID = msgList[1] if len(msgList) > 1 else 0
        expireTimes = msgList[2] if len(msgList) > 2 else None
        if PlayerFace.AddFace(curPlayer, faceID, expireTimes):
            endTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceEndTime % faceID)
            endTimeStr = "ÓÀ¾Ã" if not endTime else GameWorld.ChangeTimeNumToStr(endTime)
            GameWorld.DebugAnswer(curPlayer, "Ìí¼ÓÍ·Ïñ³É¹¦:%s,µ½ÆÚ:%s" % (faceID, endTimeStr))
        else:
            GameWorld.DebugAnswer(curPlayer, "Ìí¼ÓÍ·Ïñʧ°Ü:%s" % (faceID))
                    
    # Í·ÏñÐǼ¶
    elif value1 == "fs":
        faceID = msgList[1] if len(msgList) > 1 else 0
        faceStar = msgList[2] if len(msgList) > 2 else 0
        starIpyData = IpyGameDataPY.GetIpyGameData("PlayerFaceStar", faceID, faceStar)
        if not starIpyData:
            GameWorld.DebugAnswer(curPlayer, "Í·ÏñÐǼ¶²»´æÔÚ:%s,star:%s" % (faceID, faceStar))
            return
        GameWorld.DebugAnswer(curPlayer, "ÉèÖÃÍ·ÏñÐǼ¶:%s,ÐÇ:%s" % (faceID, faceStar))
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaceStar % faceID, faceStar)
        syncFaceIDList.append(faceID)
        
    # É¾³ýÍ·Ïñ¿ò
    elif value1 == "p0":
        facePicID = msgList[1] if len(msgList) > 1 else 0
        if not facePicID:
            for index in range(ipyDataMgr.GetPlayerFacePicCount()):
                ipyData = ipyDataMgr.GetPlayerFacePicByIndex(index)
                facePicID = ipyData.GetFacePicID()
                if ipyData.GetUnlockDefault():
                    continue
                if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FacePicState, facePicID):
                    continue
                GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_FacePicState, facePicID, 0)
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FacePicEndTime % facePicID, 0)
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FacePicStar % facePicID, 0)
                syncFacePicIDList.append(facePicID)
        else:
            ipyData = IpyGameDataPY.GetIpyGameData("PlayerFacePic", facePicID)
            if not ipyData:
                GameWorld.DebugAnswer(curPlayer, "¸ÃÍ·Ïñ¿ò²»´æÔÚ:%s" % facePicID)
                return
            if ipyData.GetUnlockDefault():
                GameWorld.DebugAnswer(curPlayer, "¸ÃÍ·Ïñ¿òĬÈϼ¤»î:%s" % facePicID)
                return
            GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_FacePicState, facePicID, 0)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FacePicEndTime % facePicID, 0)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FacePicStar % facePicID, 0)
            syncFacePicIDList.append(facePicID)
        GameWorld.DebugAnswer(curPlayer, "ɾ³ýÍ·Ïñ¿ò:%s" % syncFacePicIDList)
        
    # Ìí¼ÓÍ·Ïñ¿ò
    elif value1 == "p1":
        facePicID = msgList[1] if len(msgList) > 1 else 0
        expireTimes = msgList[2] if len(msgList) > 2 else None
        if PlayerFace.AddFacePic(curPlayer, facePicID, expireTimes):
            endTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicEndTime % facePicID)
            endTimeStr = "ÓÀ¾Ã" if not endTime else GameWorld.ChangeTimeNumToStr(endTime)
            GameWorld.DebugAnswer(curPlayer, "Ìí¼ÓÍ·Ïñ¿ò³É¹¦:%s,µ½ÆÚ:%s" % (facePicID, endTimeStr))
        else:
            GameWorld.DebugAnswer(curPlayer, "Ìí¼ÓÍ·Ïñ¿òʧ°Ü:%s" % (facePicID))
                    
    # Í·Ïñ¿òÐǼ¶
    elif value1 == "ps":
        facePicID = msgList[1] if len(msgList) > 1 else 0
        facePicStar = msgList[2] if len(msgList) > 2 else 0
        starIpyData = IpyGameDataPY.GetIpyGameData("PlayerFacePicStar", facePicID, facePicStar)
        if not starIpyData:
            GameWorld.DebugAnswer(curPlayer, "Í·Ïñ¿òÐǼ¶²»´æÔÚ:%s,star:%s" % (facePicID, facePicStar))
            return
        GameWorld.DebugAnswer(curPlayer, "ÉèÖÃÍ·Ïñ¿òÐǼ¶:%s,ÐÇ:%s" % (facePicID, facePicStar))
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FacePicStar % facePicID, facePicStar)
        syncFacePicIDList.append(facePicID)
        
    if syncFaceIDList:
        PlayerFace.RefreshFaceAttr(curPlayer)
        PlayerFace.SyncFaceInfo(curPlayer, syncFaceIDList)
        
    if syncFacePicIDList:
        PlayerFace.RefreshFacePicAttr(curPlayer)
        PlayerFace.SyncFacePicInfo(curPlayer, syncFacePicIDList)
    return