#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package DB.StructData.DBEventTrig
|
#
|
# @todo:ʼþ´¥·¢Öµ¹ÜÀíÆ÷
|
# @author hxp
|
# @date 2025-05-15
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ʼþ´¥·¢Öµ¹ÜÀíÆ÷
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2025-05-15 10:35"""
|
#-------------------------------------------------------------------------------
|
|
import DBStruct
|
import GameWorld
|
import CommFunc
|
|
class EventTrigMgr():
|
|
def __init__(self):
|
self.__eventDict = {} # ʼþ×Öµä {key:value, ...}
|
return
|
|
def GetDict(self): return self.__eventDict
|
|
def GetValue(self, key, defaultValue=0):
|
if key in self.__eventDict:
|
return self.__eventDict[key]
|
return defaultValue
|
|
def SetValue(self, key, value):
|
self.__eventDict[key] = value
|
return value
|
|
def DelAllKey(self, excludeList=[]):
|
## ɾ³ýËùÓмǼ
|
# @param excludeList: ²»°üº¬µÄkeyÁбí
|
self.__eventDict = {k:self.GetValue(k) for k in excludeList}
|
return
|
|
def DelKey(self, key):
|
return self.__eventDict.pop(key, None)
|
|
def SetValueIncrement(self, key):
|
## É趨·þÎñÆ÷ʼþ(¸Ãʼþ¼Ç¼ΪÊýÖµ´Ó1Ò»Ö±×ÔÔöÀÛ¼Ó)
|
# @return: ×ÔÔöºóµÄÖµ
|
value = self.GetValue(key, 0)
|
return self.SetValue(key, value + 1)
|
|
# ±£´æÊý¾Ý ´æÊý¾Ý¿âºÍrealtimebackup
|
def GetSaveData(self):
|
savaData = ""
|
cntData = ""
|
cnt = 0
|
|
dbData = DBStruct.tagDBEventTrig()
|
for key, value in self.__eventDict.items():
|
if not value:
|
continue
|
dbData.clear()
|
dbData.EventID = key
|
dbData.EventLen = len(dbData.EventID)
|
dbData.EventValue = value
|
cnt += 1
|
savaData += dbData.getBuffer()
|
|
GameWorld.Log("Save DBEventTrig count :%s len=%s" % (cnt, len(savaData)))
|
return CommFunc.WriteDWORD(cntData, cnt) + savaData
|
|
# ´ÓÊý¾Ý¿âÔØÈëÊý¾Ý
|
def LoadPyGameData(self, datas, pos, dataslen):
|
|
cnt, pos = CommFunc.ReadDWORD(datas, pos)
|
GameWorld.Log("Load DBEventTrig count :%s" % cnt)
|
|
dbData = DBStruct.tagDBEventTrig()
|
for _ in xrange(cnt):
|
pos += dbData.readData(datas, pos, dataslen)
|
self.__eventDict[dbData.EventID] = dbData.EventValue
|
|
return pos
|