mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-23 19:52:37 -06:00
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
from direct.distributed.DistributedObject import DistributedObject
|
|
from direct.directnotify.DirectNotifyGlobal import directNotify
|
|
|
|
class TTCodeRedemptionMgr(DistributedObject):
|
|
neverDisable = 1
|
|
notify = directNotify.newCategory('TTCodeRedemptionMgr')
|
|
|
|
def __init__(self, cr):
|
|
DistributedObject.__init__(self, cr)
|
|
|
|
def announceGenerate(self):
|
|
DistributedObject.announceGenerate(self)
|
|
base.cr.codeRedemptionMgr = self
|
|
self._contextGen = SerialMaskedGen(4294967295L)
|
|
self._context2callback = {}
|
|
|
|
def delete(self):
|
|
if hasattr(base.cr, 'codeRedemptionMgr'):
|
|
if base.cr.codeRedemptionMgr is self:
|
|
del base.cr.codeRedemptionMgr
|
|
self._context2callback = None
|
|
self._contextGen = None
|
|
DistributedObject.delete(self)
|
|
return
|
|
|
|
def redeemCode(self, code, callback):
|
|
context = self._contextGen.next()
|
|
self._context2callback[context] = callback
|
|
self.notify.debug('redeemCode(%s, %s)' % (context, code))
|
|
self.sendUpdate('redeemCode', [context, code])
|
|
|
|
def redeemCodeResult(self, context, result, awardMgrResult):
|
|
self.notify.debug('redeemCodeResult(%s, %s, %s)' % (context, result, awardMgrResult))
|
|
callback = self._context2callback.pop(context)
|
|
callback(result, awardMgrResult)
|