Poodletooth-iLand/toontown/coderedemption/TTCodeRedemptionMgr.py

36 lines
1.3 KiB
Python
Raw Normal View History

2015-03-03 16:10:12 -06:00
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)
2015-04-20 09:29:11 -05:00
base.cr.codeRedemptionMgr = self
2015-03-03 16:10:12 -06:00
self._contextGen = SerialMaskedGen(4294967295L)
self._context2callback = {}
def delete(self):
2015-04-20 09:29:11 -05:00
if hasattr(base.cr, 'codeRedemptionMgr'):
if base.cr.codeRedemptionMgr is self:
del base.cr.codeRedemptionMgr
2015-03-03 16:10:12 -06:00
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)