| | |
| | | ('CmpValue', ctypes.c_ulong),
|
| | | ('CmpValue2', ctypes.c_ulong),
|
| | | ('CmpValue3', ctypes.c_ulong),
|
| | | ('Time', ctypes.c_ulong),
|
| | | ('DataLen', ctypes.c_ushort),
|
| | | ('UserData', ctypes.c_char_p),
|
| | | ('ADOResult', ctypes.c_ulong),
|
| | |
| | | self.CmpValue = 0
|
| | | self.CmpValue2 = 0
|
| | | self.CmpValue3 = 0
|
| | | self.Time = 0
|
| | | self.DataLen = 0
|
| | | self.UserData = ''
|
| | |
|
| | |
| | | self.CmpValue, pos = CommFunc.ReadDWORD(buf, pos)
|
| | | self.CmpValue2, pos = CommFunc.ReadDWORD(buf, pos)
|
| | | self.CmpValue3, pos = CommFunc.ReadDWORD(buf, pos)
|
| | | self.Time, pos = CommFunc.ReadDWORD(buf, pos)
|
| | | self.DataLen, pos = CommFunc.ReadWORD(buf, pos)
|
| | | tmp, pos = CommFunc.ReadString(buf, pos, self.DataLen)
|
| | | self.UserData = ctypes.c_char_p(tmp)
|
| | |
| | | buf = CommFunc.WriteDWORD(buf, self.CmpValue)
|
| | | buf = CommFunc.WriteDWORD(buf, self.CmpValue2)
|
| | | buf = CommFunc.WriteDWORD(buf, self.CmpValue3)
|
| | | buf = CommFunc.WriteDWORD(buf, self.Time)
|
| | | buf = CommFunc.WriteWORD(buf, self.DataLen)
|
| | | buf = CommFunc.WriteString(buf, self.DataLen, self.UserData)
|
| | | return buf
|
| | |
| | | length += sizeof(ctypes.c_char) * 33
|
| | | length += sizeof(ctypes.c_char) * 65
|
| | | length += sizeof(ctypes.c_ubyte)
|
| | | length += sizeof(ctypes.c_ulong)
|
| | | length += sizeof(ctypes.c_ulong)
|
| | | length += sizeof(ctypes.c_ulong)
|
| | | length += sizeof(ctypes.c_ulong)
|
| | |
| | | CmpValue = %s,
|
| | | CmpValue2 = %s,
|
| | | CmpValue3 = %s,
|
| | | Time = %s,
|
| | | DataLen = %s,
|
| | | UserData = %s,
|
| | | ADOResult = %s,
|
| | |
| | | self.CmpValue,
|
| | | self.CmpValue2,
|
| | | self.CmpValue3,
|
| | | self.Time,
|
| | | self.DataLen,
|
| | | self.UserData,
|
| | | self.ADOResult,
|
| | |
| | | def SetCmpValue2(self, cmpValue2): self.__dbData.CmpValue2 = cmpValue2
|
| | | def GetCmpValue3(self): return self.__dbData.CmpValue3
|
| | | def SetCmpValue3(self, cmpValue3): self.__dbData.CmpValue3 = cmpValue3
|
| | | def GetTime(self): return self.__dbData.Time
|
| | | def SetTime(self, updTime): self.__dbData.Time = updTime
|
| | | def GetUserData(self): return self.__dbData.UserData
|
| | | def SetUserData(self, userData):
|
| | | if not isinstance(userData, str):
|
| | |
| | | copyData.SetCmpValue(self.GetCmpValue())
|
| | | copyData.SetCmpValue2(self.GetCmpValue2())
|
| | | copyData.SetCmpValue3(self.GetCmpValue3())
|
| | | copyData.SetTime(self.GetTime())
|
| | | return copyData
|
| | |
|
| | | class Billboard():
|
| | |
| | | def SortData(self):
|
| | | GameWorld.DebugLog("榜单排序: billboardType=%s,groupValue1=%s,groupValue2=%s,dataCount=%s"
|
| | | % (self.__billboardType, self.__groupValue1, self.__groupValue2, len(self.__billboardList)))
|
| | | self.__billboardList.sort(key=lambda b: (b.GetCmpValue(), b.GetCmpValue2(), b.GetCmpValue3()), reverse=True)
|
| | | self.__billboardList.sort(key=lambda b: (b.GetCmpValue(), b.GetCmpValue2(), b.GetCmpValue3(), -b.GetTime()), reverse=True)
|
| | | self.__idOrderDict = {} # 排序后重置,下次查询时更新并缓存
|
| | | self.__idIndexDict = {}
|
| | | self.__sortDelay = False
|
| | |
| | | "Value5":bData.GetValue5(), "Value6":bData.GetValue6(),
|
| | | "Value7":bData.GetValue7(), "Value8":bData.GetValue8(),
|
| | | "CmpValue":bData.GetCmpValue(), "CmpValue2":bData.GetCmpValue2(),
|
| | | "CmpValue3":bData.GetCmpValue3(), "UserData":bData.GetUserData()}
|
| | | "CmpValue3":bData.GetCmpValue3(), "Time":bData.GetTime(), "UserData":bData.GetUserData()}
|
| | | DataRecordPack.SendEventPack(eventTypeStr, dataDict)
|
| | |
|
| | | return
|
| | |
| | | cmpValueChange = isNewData or billboardData.GetCmpValue() != cmpValue or billboardData.GetCmpValue2() != cmpValue2 \
|
| | | or (cmpValue3 and billboardData.GetCmpValue3() != cmpValue3)
|
| | |
|
| | | # 没设置值默认为时间time,先上榜的排前面
|
| | | if cmpValue3 == 0:
|
| | | # 时间权值仅在比较值变更的情况下才更新, 防止其他附属值更新时导致比较值相同的玩家名次间会变动的问题
|
| | | if cmpValueChange:
|
| | | calcTime = GameWorld.ChangeTimeStrToNum("2090-01-01 00:00:00")
|
| | | cmpValue3 = max(0, calcTime - int(time.time())) # 比较值3如果没指定值则默认存当前更新的time
|
| | | else:
|
| | | cmpValue3 = billboardData.GetCmpValue3()
|
| | | |
| | | billboardData.SetCmpValue(cmpValue)
|
| | | billboardData.SetCmpValue2(cmpValue2)
|
| | | billboardData.SetCmpValue3(cmpValue3)
|
| | | if cmpValueChange or not billboardData.GetTime():
|
| | | billboardData.SetTime(int(time.time()))
|
| | |
|
| | | GameWorld.DebugLog("更新排行榜值: billboardType=%s,groupValue1=%s,groupValue2=%s,dataID=%s,cmpValueChange=%s,cmpValue=%s,cmpValue2=%s,cmpValue3=%s"
|
| | | % (billboardType, groupValue1, groupValue2, dataID, cmpValueChange,
|
| | |
| | | cmpValueChange = isNewData or billboardData.GetCmpValue() != cmpValue or billboardData.GetCmpValue2() != cmpValue2 \
|
| | | or (cmpValue3 and billboardData.GetCmpValue3() != cmpValue3)
|
| | |
|
| | | # 没设置值默认为时间time,先上榜的排前面
|
| | | if cmpValue3 == 0:
|
| | | # 时间权值仅在比较值变更的情况下才更新, 防止其他附属值更新时导致比较值相同的玩家名次间会变动的问题
|
| | | if cmpValueChange:
|
| | | calcTime = GameWorld.ChangeTimeStrToNum("2090-01-01 00:00:00")
|
| | | cmpValue3 = max(0, calcTime - int(time.time())) # 比较值3如果没指定值则默认存当前更新的time
|
| | | else:
|
| | | cmpValue3 = billboardData.GetCmpValue3()
|
| | | |
| | | # 更新所有值
|
| | | billboardData.SetType(billboardType)
|
| | | billboardData.SetGroupValue1(groupValue1)
|
| | |
| | | billboardData.SetCmpValue(cmpValue)
|
| | | billboardData.SetCmpValue2(cmpValue2)
|
| | | billboardData.SetCmpValue3(cmpValue3)
|
| | | if cmpValueChange or not billboardData.GetTime():
|
| | | billboardData.SetTime(int(time.time()))
|
| | |
|
| | | GameWorld.DebugLog("更新排行榜值: billboardType=%s,groupValue1=%s,groupValue2=%s,dataID=%s,isNewData=%s,cmpValueChange=%s,type2=%s,value1=%s,value2=%s,cmpValue=%s,cmpValue2=%s,cmpValue3=%s,%s"
|
| | | % (billboardType, groupValue1, groupValue2, dataID, isNewData, cmpValueChange,
|
| | |
| | | ('CmpValue', ctypes.c_ulong),
|
| | | ('CmpValue2', ctypes.c_ulong),
|
| | | ('CmpValue3', ctypes.c_ulong),
|
| | | ('Time', ctypes.c_ulong),
|
| | | ('DataLen', ctypes.c_ushort),
|
| | | ('UserData', ctypes.c_char_p),
|
| | | ('ADOResult', ctypes.c_ulong),
|
| | |
| | | self.CmpValue = 0
|
| | | self.CmpValue2 = 0
|
| | | self.CmpValue3 = 0
|
| | | self.Time = 0
|
| | | self.DataLen = 0
|
| | | self.UserData = ''
|
| | |
|
| | |
| | | self.CmpValue, pos = CommFunc.ReadDWORD(buf, pos)
|
| | | self.CmpValue2, pos = CommFunc.ReadDWORD(buf, pos)
|
| | | self.CmpValue3, pos = CommFunc.ReadDWORD(buf, pos)
|
| | | self.Time, pos = CommFunc.ReadDWORD(buf, pos)
|
| | | self.DataLen, pos = CommFunc.ReadWORD(buf, pos)
|
| | | tmp, pos = CommFunc.ReadString(buf, pos, self.DataLen)
|
| | | self.UserData = ctypes.c_char_p(tmp)
|
| | |
| | | buf = CommFunc.WriteDWORD(buf, self.CmpValue)
|
| | | buf = CommFunc.WriteDWORD(buf, self.CmpValue2)
|
| | | buf = CommFunc.WriteDWORD(buf, self.CmpValue3)
|
| | | buf = CommFunc.WriteDWORD(buf, self.Time)
|
| | | buf = CommFunc.WriteWORD(buf, self.DataLen)
|
| | | buf = CommFunc.WriteString(buf, self.DataLen, self.UserData)
|
| | | return buf
|
| | |
| | | length += sizeof(ctypes.c_char) * 33
|
| | | length += sizeof(ctypes.c_char) * 65
|
| | | length += sizeof(ctypes.c_ubyte)
|
| | | length += sizeof(ctypes.c_ulong)
|
| | | length += sizeof(ctypes.c_ulong)
|
| | | length += sizeof(ctypes.c_ulong)
|
| | | length += sizeof(ctypes.c_ulong)
|
| | |
| | | rec[u'CmpValue'] = self.CmpValue
|
| | | rec[u'CmpValue2'] = self.CmpValue2
|
| | | rec[u'CmpValue3'] = self.CmpValue3
|
| | | rec[u'Time'] = self.Time
|
| | | rec[u'DataLen'] = self.DataLen
|
| | | rec[u'UserData'] = fix_incomingText(self.UserData)
|
| | | return rec
|
| | |
| | | self.CmpValue = rec.get(u'CmpValue', 0)
|
| | | self.CmpValue2 = rec.get(u'CmpValue2', 0)
|
| | | self.CmpValue3 = rec.get(u'CmpValue3', 0)
|
| | | self.Time = rec.get(u'Time', 0)
|
| | | self.DataLen = rec.get(u'DataLen', 0)
|
| | | self.UserData = fix_outgoingText(rec.get(u'UserData', u''))
|
| | |
|
| | |
| | | CmpValue = %s,
|
| | | CmpValue2 = %s,
|
| | | CmpValue3 = %s,
|
| | | Time = %s,
|
| | | DataLen = %s,
|
| | | UserData = %s,
|
| | | ADOResult = %s,
|
| | |
| | | self.CmpValue,
|
| | | self.CmpValue2,
|
| | | self.CmpValue3,
|
| | | self.Time,
|
| | | self.DataLen,
|
| | | self.UserData,
|
| | | self.ADOResult,
|
| | |
| | | return output
|
| | |
|
| | | def dumpString(self):
|
| | | output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
|
| | | output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
|
| | | self.GroupValue1,
|
| | | self.GroupValue2,
|
| | | self.BillboardType,
|
| | |
| | | self.CmpValue,
|
| | | self.CmpValue2,
|
| | | self.CmpValue3,
|
| | | self.Time,
|
| | | self.DataLen,
|
| | | self.UserData,
|
| | | )
|