hxp
2019-08-08 23a95e1146a41c751c80dc54f6821535cdbe74bb
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package GM.Commands.JobPlayerCount
#
# @todo:Ö°ÒµÈËÊýÐÅÏ¢
# @author hxp
# @date 2019-07-23
# @version 1.0
#
# ÏêϸÃèÊö: Ö°ÒµÈËÊýÐÅÏ¢
#
#-------------------------------------------------------------------------------
#"""Version = 2019-07-23 21:00"""
#-------------------------------------------------------------------------------
 
import GameWorld
import PyGameData
import IpyGameDataPY
import time
 
 
## Ö´ÐÐÂß¼­
#  @param curPlayer µ±Ç°Íæ¼Ò
#  @param gmList []
#  @return None
def OnExec(curPlayer, gmList):
    
    if not gmList:
        GameWorld.DebugAnswer(curPlayer, "ÖØÖÃÈËÊý: JobPlayerCount 0")
        GameWorld.DebugAnswer(curPlayer, "ÉèÖÃ24Сʱְҵ¶ÔÓ¦ÈËÊý: ")
        GameWorld.DebugAnswer(curPlayer, "JobPlayerCount Ö°Òµ1 ÈËÊý Ö°Òµ2 ÈËÊý")
        __PrintJobPlayerCount(curPlayer)
        return
    
    if len(gmList) == 1 and gmList[0] == 0:
        PyGameData.g_onedayJobPlayerLoginoffTimeDict = {}
        GameWorld.DebugAnswer(curPlayer, "ÖØÖÃÖ°ÒµÈËÊý³É¹¦! ")
        __PrintJobPlayerCount(curPlayer)
        return
    
    if len(gmList) % 2 == 0:
        while gmList:
            job = gmList[0]
            count = gmList[1]
            gmList = gmList[2:]
            if job not in PyGameData.g_onedayJobPlayerLoginoffTimeDict:
                PyGameData.g_onedayJobPlayerLoginoffTimeDict[job] = {}
            jobPlayerDict = PyGameData.g_onedayJobPlayerLoginoffTimeDict[job]
            curCount = len(jobPlayerDict)
            if curCount > count:
                playerIDList = jobPlayerDict.keys()
                for popPlayerID in playerIDList[:curCount - count]:
                    jobPlayerDict.pop(popPlayerID)
            elif curCount < count:
                for i in range(count - curCount):
                    jobPlayerDict[100 + curCount + 1 + i] = int(time.time())
            else:
                pass
        GameWorld.DebugAnswer(curPlayer, "ÉèÖÃÖ°ÒµÈËÊý³É¹¦! ")
        __PrintJobPlayerCount(curPlayer)
                    
    return
 
def __PrintJobPlayerCount(curPlayer):
    openJobList = IpyGameDataPY.GetFuncEvalCfg("OpenJob", 1)
    GameWorld.DebugAnswer(curPlayer, "µ±Ç°: ")
    for job in openJobList:
        GameWorld.DebugAnswer(curPlayer, "Ö°Òµ%s  ÈËÊý: %s" % (job, len(PyGameData.g_onedayJobPlayerLoginoffTimeDict.get(job, {}))))
    return