hxp
2025-10-17 f495a32d55731268db3e8fbd272769e1c6ab1fb3
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package PyMongoDB.GMToolLogicProcess.Commands.GMT_Face
#
# @todo:GM¹¤¾ßÃüÁî - »Ã¾³¸ó
# @author hxp
# @date 2025-10-15
# @version 1.0
#
# ÏêϸÃèÊö: GM¹¤¾ßÃüÁî - »Ã¾³¸ó
#
#-------------------------------------------------------------------------------
#"""Version = 2025-10-15 09:30"""
#-------------------------------------------------------------------------------
 
import GMCommon
import GameWorld
import PlayerFace
import PlayerHJG
import ChConfig
 
## ÊÕµ½gmÃüÁîÖ´ÐÐ
# @param gmCmdDict:gmÃüÁî×Öµä
# @return None 
def OnExec(gmCmdDict):
    #ÃüÁî²âÊÔûͨ¹ý£¬ºóÐøÔÙµ÷ÊÔ
    GameWorld.Log("GMT_Face: %s" % gmCmdDict)
    errorMsg = ""
    from GMToolLogicProcess import  ProjSpecialProcess
    Result, curPlayer = ProjSpecialProcess.GMCmdPlayerValidation(gmCmdDict, False)
    if Result != GMCommon.Def_Success:
        return Result, errorMsg
    
    faceType = gmCmdDict.get('faceType', '')
    opType = gmCmdDict.get('opType', '')
    opID = GameWorld.ToIntDef(gmCmdDict.get('opID', '0'))
    expireTime = GameWorld.ToIntDef(gmCmdDict.get('expireTime', '0'))
    setValue = GameWorld.ToIntDef(gmCmdDict.get('setValue', '0'))
    
    state, endTime, star = 0, 0, 0
    isOK = False
    errorMsg = ""
    if faceType == "face":
        if opType == "add":
            isOK = PlayerFace.AddFace(curPlayer, opID, expireTime, isFree=True)
        elif opType == "del":
            isOK = PlayerFace.DelFace(curPlayer, opID)
        elif opType == "starUp":
            setValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceStar % opID) + 1
            isOK = PlayerFace.SetFaceStar(curPlayer, opID, setValue)
        elif opType == "setStar":
            isOK = PlayerFace.SetFaceStar(curPlayer, opID, setValue)
        elif opType == "query":
            isOK = True
        state = PlayerFace.IsFaceCanUse(curPlayer, opID)
        endTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceEndTime % opID)
        star = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceStar % opID)
    elif faceType == "facePic":
        if opType == "add":
            isOK = PlayerFace.AddFacePic(curPlayer, opID, expireTime, isFree=True)
        elif opType == "del":
            isOK = PlayerFace.DelFacePic(curPlayer, opID)
        elif opType == "starUp":
            setValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicStar % opID) + 1
            isOK = PlayerFace.SetFacePicStar(curPlayer, opID, setValue)
        elif opType == "setStar":
            isOK = PlayerFace.SetFacePicStar(curPlayer, opID, setValue)
        elif opType == "query":
            isOK = True
        state = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FacePicState, opID)
        endTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicEndTime % opID)
        star = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicStar % opID)
    elif faceType == "title":
        if opType == "add":
            isOK = PlayerHJG.AddTitle(curPlayer, opID, expireTime, isFree=True)
        elif opType == "del":
            isOK = PlayerHJG.DelTitle(curPlayer, opID)
        elif opType == "starUp":
            setValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TitleStar % opID) + 1
            isOK = PlayerHJG.SetTitleStar(curPlayer, opID, setValue)
        elif opType == "setStar":
            isOK = PlayerHJG.SetTitleStar(curPlayer, opID, setValue)
        elif opType == "query":
            isOK = True
        state = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_TitleState, opID)
        endTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TitleEndTime % opID)
        star = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TitleStar % opID)
        
    if not isOK:
        if errorMsg:
            errorMsg = "%s %s fail! %s" % (opType, faceType, errorMsg)
        else:
            errorMsg = "%s %s fail! Please check that the ID(%s) is correct." % (opType, faceType, opID)
        return GMCommon.Def_ParamErr, errorMsg
    
    endTimeStr = "δ¼¤»î"
    if state:
        endTimeStr = "ÓÀ¾Ã" if not endTime else GameWorld.ChangeTimeNumToStr(endTime)
    resultDict = {"opID":opID, "expireTime":expireTime, "opType":opType, 
                  "faceType":faceType, "state":state, "endTimeStr":endTimeStr, "star":star}
    GameWorld.Log("GMT_Face: resultDict=%s" % resultDict, curPlayer.GetPlayerID())
    return Result, resultDict