hxp
2023-01-08 9e65b1227144d715b48bdac99290a292108bec53
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package GM.Commands.SetChestsUseCount
#
# @todo:ÉèÖñ¦Ï俪Æô´ÎÊý
# @author hxp
# @date 2018-09-27
# @version 1.0
#
# ÏêϸÃèÊö: ÉèÖñ¦Ï俪Æô´ÎÊý
#
#-------------------------------------------------------------------------------
#"""Version = 2018-09-27 19:00"""
#-------------------------------------------------------------------------------
 
import PlayerControl
import IpyGameDataPY
import GameWorld
import ChConfig
 
#---------------------------------------------------------------------
#Âß¼­ÊµÏÖ
 
## GMÃüÁîÖ´ÐÐÈë¿Ú
#  @param curPlayer µ±Ç°Íæ¼Ò
#  @param msgList ²ÎÊýÁбí
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def OnExec(curPlayer, msgList):
    if not msgList:
        GameWorld.DebugAnswer(curPlayer, "SetChestsUseCount ±¦ÏäID ´ÎÊý")
        GameWorld.DebugAnswer(curPlayer, "ÖØÖÃËùÓÐ: SetChestsUseCount 0")
        return
    
    if len(msgList) == 1 and not msgList[0]:
        resetIDList = []
        ipyDataMgr = IpyGameDataPY.IPY_Data()
        for i in xrange(ipyDataMgr.GetChestsAwardCount()):
            ipyData = ipyDataMgr.GetChestsAwardByIndex(i)
            chestsItemID = ipyData.GetChestsItemID()
            if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ChestsOpenCount % chestsItemID):
                continue
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ChestsOpenCount % chestsItemID, 0)
            resetIDList.append(chestsItemID)
            
        GameWorld.DebugAnswer(curPlayer, "ÖØÖÃOK: %s" % resetIDList)
        return
    
    isNeedRecord = False
    chestsItemID = msgList[0]
    awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ChestsAward", chestsItemID)
    if not awardIpyDataList:
        GameWorld.DebugAnswer(curPlayer, "ûÓиñ¦Ïä²ú³öÅäÖÃ:%s" % chestsItemID)
        return
    
    for ipyData in awardIpyDataList:
        if ipyData.GetRandItemByUseCount():
            isNeedRecord = True
            break
        
    if not isNeedRecord:
        GameWorld.DebugAnswer(curPlayer, "ûÓÐÅäÖÿªÆô´ÎÊýÌØÊâ²ú³ö:%s" % chestsItemID)
        return
    
    useCount = msgList[1] if len(msgList) > 1 else 0
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ChestsOpenCount % chestsItemID, useCount)
    GameWorld.DebugAnswer(curPlayer, "ÉèÖñ¦Ï俪Æô´ÎÊý(%s)=%s" % (chestsItemID, useCount))
    return