def _getActivityByActId(cls, actId): """ 获取活动实例 """ from dizhu.activitynew import activitysystemnew scoreActivity = activitysystemnew.findActivity(actId) return scoreActivity
def handleRequest(self, msg): userId = msg.getParam('userId') action = msg.getParam("action") clientId = msg.getParam('clientId') intClientId = pokerconf.clientIdToNumber(clientId) actId = self.getActId() if ftlog.is_debug(): ftlog.debug('ActivityChristmasHandler.handleRequest', 'userId=', userId, 'action=', action, 'clientId=', clientId, 'intClientId=', intClientId, 'actId=', actId, 'msg=', msg) if not actId: ftlog.warn() return {'code': -1, 'info': 'please ensure act_ddz_christmas activity in [game/6/activity.new/0.json]'} from dizhu.activitynew import activitysystemnew actChristmas = activitysystemnew.findActivity(actId) if actChristmas: errInfo = u"" if self.ACTION_EXCHANGE == action: errInfo = actChristmas.exchange(userId) collectList = actChristmas.getUserCollectList(userId) socks = [] for collectItem in collectList: # [itemId, balance, itemCount, todotask] total = collectItem[1] done = collectItem[2] todotask = collectItem[3] d = {'total': total, 'done': done, 'todotask': todotask} socks.append(d) collectTimes = actChristmas.getCollectTimes(userId) rewardsInBag = actChristmas.getRewardCountInBag(userId) retInfo = { "errInfo": errInfo, "action": action, "isExchanged": collectTimes, "isInBag" : rewardsInBag, "socks" : socks, "tip" : actChristmas.tips } if ftlog.is_debug(): ftlog.debug('ActivityChristmasHandler.handleRequest userId=', userId, 'retInfo=', retInfo) return retInfo return {'code': -1, 'info': 'dizhu.ActivityChristmasHandler not inited'}
def getTaskContext(cls, userId, backendActivityNewActId): ''' 获得趣味任务上下文 ''' actobj = activitysystemnew.findActivity(backendActivityNewActId) if ftlog.is_debug(): ftlog.debug('QuweiTaskProxy.getTaskContext', 'userId=', userId, 'backendActivityNewActId=', backendActivityNewActId, 'actobj=', actobj) taskStatus = actobj.loadStatus(userId, pktimestamp.getCurrentTimestamp()) return taskStatus
def check(self, gameId, userId, clientId, timestamp, **kwargs): act = actsys.findActivity(self.actId) if ftlog.is_debug(): ftlog.debug('UserConditionFTTableFinish.check', 'userId=', userId, 'actId=', self.actId, 'finishCount=', self.finishCount) if not act: if ftlog.is_debug(): ftlog.debug('UserConditionFTTableFinish.check ActNotFound', 'userId=', userId, 'actId=', self.actId, 'finishCount=', self.finishCount) return False model = act.loadModel(userId, timestamp) return model.finishCount >= self.finishCount
def check(self, gameId, userId, clientId, timestamp, **kwargs): act = actsys.findActivity(self.tableShareRecorderActId) if ftlog.is_debug(): ftlog.debug('UserConditionDizhuTableShareToday.check:', 'userId=', userId, 'tableShareRecorderActId=', self.tableShareRecorderActId, 'tableShareCount=', self.tableShareCount) if not act: if ftlog.is_debug(): ftlog.debug( 'UserConditionDizhuTableShareToday.check:act not found!', userId) return False return act.getTodaySharedCount(userId) >= self.tableShareCount
def resetTaskListProgress(cls, userId, backendActivityNewActId): ''' 重置任务 ''' actobj = activitysystemnew.findActivity(backendActivityNewActId) if ftlog.is_debug(): ftlog.debug('QuweiTaskProxy.getTaskContext', 'userId=', userId, 'backendActivityNewActId=', backendActivityNewActId, 'actobj=', actobj) taskStatus = actobj.loadStatus(userId, pktimestamp.getCurrentTimestamp()) try: actobj.refresh(taskStatus, pktimestamp.getCurrentTimestamp()) except TYBizException, ex: return ex.errorCode
def gainTaskPrize(cls, userId, backendActivityNewActId, allOpenflag): ''' 领取任务奖励 ''' actobj = activitysystemnew.findActivity(backendActivityNewActId) if ftlog.is_debug(): ftlog.debug('QuweiTaskProxy.getTaskContext', 'userId=', userId, 'backendActivityNewActId=', backendActivityNewActId, 'actobj=', actobj) taskStatus = actobj.loadStatus(userId, pktimestamp.getCurrentTimestamp()) try: curtask = cls.getCompletedTask( taskStatus) if allOpenflag else cls.getCurrentTask(taskStatus) actobj.gainReward(taskStatus, curtask.kindId, pktimestamp.getCurrentTimestamp()) except TYBizException, ex: cls.sendPopTip(userId, ex.message)
def testEvent(self): # winlose = Winlose(winuserid, topValidCard, isWin, isDizhu, seat_delta, findChips, # windoubles, bomb, chuntian > 1, winslam) timestamp = int(time.time()) cardRule = CardDiZhuLaizi3Player() winCard = cardRule.validateCards([0]) event = UserTableWinloseEvent( self.gameId, self.userId, 6001, 600101, Winlose(self.userId, winCard, 1, 1, 100, 100, 1, 1, 2, 1)) TGDizhu.getEventBus().publishEvent(event) act = activitysystemnew.findActivity('act1') status = act.loadStatus(self.userId, int(time.time())) act.gainReward(status, 5001, timestamp) self.assertRaises(TYBizException, act.refresh, status, timestamp) userAssets = hallitem.itemSystem.loadUserAssets(self.userId) userAssets.addAsset(self.gameId, 'user:chip', 1000, timestamp, 'TEST', 0) act.refresh(status, timestamp)
def handleRequest(self, msg): userId = msg.getParam('userId') action = msg.getParam("action") clientId = msg.getParam('clientId') activityType = msg.getParam('type') intClientId = pokerconf.clientIdToNumber(clientId) actIdList = getActIdList() actId = '' for actConf in actIdList: intClientIdList = actConf.get('clientIds') if intClientId in intClientIdList: actId = actConf.get('actId') break if ftlog.is_debug(): ftlog.debug('ActivityScoreRankingHandler.handleRequest', 'userId=', userId, 'action=', action, 'clientId=', clientId, 'intClientId=', intClientId, 'activityType=', activityType, 'actId=', actId, 'msg=', msg) if actId: from dizhu.activitynew import activitysystemnew scoreActivity = activitysystemnew.findActivity(actId) if scoreActivity: if self.ACTION_GET_REWARD_INFO == action: return self.getRewardInfo(userId, scoreActivity) elif self.ACTION_GAIN_REWARD == action: return self.gainReward(userId, scoreActivity) elif self.ACTION_GET_USER_ITEM_INFO == action: return self.getUserItemInfo(userId, scoreActivity) or { 'code': -1, 'info': 'activity not inited' } clientId = clientId or sessiondata.getClientId(userId) return self.getRankInfo(userId, clientId, scoreActivity, activityType) return {'code': -1, 'info': 'activity not inited'}
def _conform(self, gameId, userAssets, item, timestamp, params): act = actsys.findActivity(self.chargeRmbRecorderActId) if not act: if ftlog.is_debug(): ftlog.debug( 'ItemActionConditionDizhuChargedRMB._conform:act not found!', 'userId=', userAssets.userId, 'chargeRmbRecorderActId=', self.chargeRmbRecorderActId) return False model = act.loadModel(userAssets.userId) if ftlog.is_debug(): ftlog.debug('ItemActionConditionDizhuChargedRMB._conform:', 'userId=', userAssets.userId, 'maxChargedMoney=', model.maxChargedMoney, 'rmbLimit=', self.rmbLimit, 'autoReset=', self.autoReset, 'return=', model.maxChargedMoney >= self.rmbLimit) # 若满足了充值数额,则将充值数额重置 if model.maxChargedMoney >= self.rmbLimit: if self.autoReset: model.maxChargedMoney = 0 act.saveModel(model) return True return False
def check(self, gameId, userId, clientId, timestamp, **kwargs): act = activitysystemnew.findActivity(self.activityId) if not act or not isinstance(act, BuySendPrize): return False return act.canSendPrize(userId, timestamp)
TodoTaskHelper.sendTodoTask(DIZHU_GAMEID, event.userId, reward_task) ftlog.info('gainChristmasFinalReward.todotask userId=', event.userId, 'items=', [(atp[0].kindId, atp[1]) for atp in assetList]) if ftlog.is_debug(): ftlog.debug('act.christmas._onGameRoundFinish.todotask userId=', event.userId, 'bigRoomId=', bigRoomId, 'winLose=', event.winlose.isWin, 'dropRate=', dropRate, 'itemId=', itemId) ActivityChristmas._onGameRoundFinish = _onGameRoundFinish from dizhu.activitynew import activitysystemnew actChristmas = activitysystemnew.findActivity('act171213') if not actChristmas: ftlog.warn('act.christmas.hotfix.error actChristmas not exist') #actChristmas.cleanup() from dizhu.activitynew.christmas import ActivityChristmas eventBus = TGDizhu.getEventBus() handlers = eventBus._handlersMap.get(UserTableWinloseEvent) for h in handlers: ftlog.info('UserTableWinloseEvent Listener __module__=', h.__module__) if h.__module__ == 'dizhu.activitynew.christmas': handlers.remove(h) ftlog.info('dizhu.activities.christmas removed. 20171221') break