def canDisplaySessionRoom(gameId, userId, clientId, roomId, displayCondDict): if displayCondDict: try: displayCond = UserConditionRegister.decodeFromDict(displayCondDict) ret = displayCond.check(gameId, userId, clientId, pktimestamp.getCurrentTimestamp()) if not ret: if ftlog.is_debug(): ftlog.debug('dizhuhallinfo.canDisplaySessionRoom', 'gameId=', gameId, 'userId=', userId, 'clientId=', clientId, 'roomId=', roomId, 'displayCond=', displayCondDict, 'ret=', ret) return ret except: ftlog.error('dizhuhallinfo.canDisplaySessionRoom', 'gameId=', gameId, 'userId=', userId, 'clientId=', clientId, 'roomId=', roomId, 'displayCond=', displayCondDict) return False return True
def getSimpleInviteBigReward(userId): ''' 获取大奖 ''' conf = getSimpleInviteConf() if conf.get('switch'): conditon = conf.get('condition') cond = UserConditionRegister.decodeFromDict(conditon) retCheck = cond.check(DIZHU_GAMEID, userId, None, None) ftlog.debug('dizhu_invite.getSimpleInviteBigReward userId=', userId, 'retCheck=', retCheck, 'isInterventionUser='******'firstBigRewards') if not firstBigRewards: return conf.get('firstBigRewards') if conf.get('firstBigRewards') else {} if isInterventionUser(userId): return conf.get('interventionBigRewards') if conf.get('interventionBigRewards') else {} return dizhu_util.getItemByWeight(conf.get('bigRewards')) if conf.get('bigRewards') else {}
def _getConfigForClient(self, actName, gameId, userId, clientId, activities, curstate): if ftlog.is_debug(): ftlog.debug('TYActivitySystemImpl._getConfigForClient actName:', actName, ' gameId:', gameId, ' userId:', userId, ' clientId:', clientId, ' curstate:', curstate) actObj = self.getActivityObj(actName) if not actObj or not actObj.checkOperative(): return condition = actObj._serverConf.get('condition') if condition is not None: condition = UserConditionRegister.decodeFromDict(condition) if not condition.check(HALL_GAMEID, userId, clientId, pktimestamp.getCurrentTimestamp()): return configForClient = actObj.getConfigForClient(gameId, userId, clientId) if configForClient: configForClient['state'] = curstate activities.append(configForClient)
def _reloadConf(): global _conf newConf = RPMainConf() conf = configure.getGameJson(HALL_GAMEID, 'red_packet_main', {}) startDT = conf.get('startTime') if startDT is not None: newConf.startDT = datetime.strptime(startDT, '%Y-%m-%d %H:%M:%S') stopDT = conf.get('stopTime') if stopDT is not None: newConf.stopDT = datetime.strptime(stopDT, '%Y-%m-%d %H:%M:%S') inviteTodotaskD = conf.get('inviteTodotask') if inviteTodotaskD is not None: newConf.inviteTodotaskFac = TodoTaskRegister.decodeFromDict(inviteTodotaskD) oldInviteTodotaskD = conf.get('oldInviteTodotask') if oldInviteTodotaskD: newConf.oldInviteTodotaskFac = TodoTaskRegister.decodeFromDict(oldInviteTodotaskD) newConf.rewards = [] for reward in conf.get('rewards', []): cond = None content = None condD = reward.get('condition') if condD: cond = UserConditionRegister.decodeFromDict(condD) content = TYContentRegister.decodeFromDict(reward.get('content')) newConf.rewards.append((cond, content)) _conf = newConf ftlog.info('hall_red_packet_main._reloadConf ok', 'startDT=', newConf.startDT, 'stopDT=', newConf.stopDT, 'inviteTodotaskFac=', newConf.inviteTodotaskFac, 'oldInviteTodotaskFac=', newConf.oldInviteTodotaskFac)
def _withdrawConf(cls, userId, gameId, clientId): from hall.entity.hallusercond import UserConditionRegister withdrawAmount = 5 condList = getWithdrawConf().get('withdrawAmount') for conditon in condList: conD = conditon.get('conditions') cond = UserConditionRegister.decodeFromDict(conD) retCheck = cond.check(DIZHU_GAMEID, userId, clientId, pktimestamp.getCurrentTimestamp()) if retCheck: withdrawAmount = conditon.get('amount') break openTimeList = getWithdrawConf().get('openTimeList', []) openTimeDesc = getWithdrawConf().get('openTimeDesc', '') msg = MsgPack() msg.setCmd('dizhu') msg.setResult('openTimeList', openTimeList) msg.setResult('openTimeDesc', openTimeDesc) msg.setResult('action', 'coupon_withdraw') msg.setResult('withdrawAmount', withdrawAmount) if ftlog.is_debug(): ftlog.debug('SegmentMatchHandler._withdrawConf', 'userId=', userId, 'withdrawAmount=', withdrawAmount) return msg
def _canQuickEnterRoom(cls, userId, roomId, innerTable=0, mixId=''): try: clientId = sessiondata.getClientId(userId) ret = comm_table_remote.checkUserQuitLoc(DIZHU_GAMEID, userId, roomId, clientId) if ret == -1: return ENTER_ROOM_REASON_TYPE_NORMAL, ENTER_ROOM_REASON_INNER_ERROR elif ret == 1: return ENTER_ROOM_REASON_TYPE_NORMAL, ENTER_ROOM_REASON_QUIT_ROOM_ERROR else: pass chip = userchip.getChip(userId) if ftlog.is_debug(): ftlog.debug(gdata.roomIdDefineMap()[roomId].configure) roomConfig = gdata.roomIdDefineMap()[roomId].configure if roomConfig.get('isMix', 0): mixConf = cls.getMixConf(roomConfig, mixId) or roomConfig.get('mixConf')[0] minCoin = cls.getMixConf(roomConfig, mixId).get('minCoin', 0) kickOutCoin = cls.getMixConf(roomConfig, mixId).get('kickOutCoin', 0) roomConfig = mixConf elif roomConfig.get( 'typeName') == 'dizhu_arena_match' and roomConfig.get( 'matchConf', {}).get('feeRewardList', []): mixConf = cls.getArenaMixConf(roomConfig, mixId) or roomConfig.get( 'matchConf', {}).get('feeRewardList', [])[0] mixConfDisplayCond = mixConf.get('displayCond', {}) if mixConfDisplayCond: displayCond = UserConditionRegister.decodeFromDict( mixConfDisplayCond) ret = displayCond.check(DIZHU_GAMEID, userId, clientId, pktimestamp.getCurrentTimestamp()) if not ret: return ENTER_ROOM_REASON_TYPE_NORMAL, ENTER_ROOM_REASON_NOT_OPEN # 准入时间判断 if not cls._checkOpenTime(mixConf, datetime.now().time()): return ENTER_ROOM_REASON_TYPE_NORMAL, ENTER_ROOM_REASON_NOT_OPEN minCoin = cls.getArenaMixConf(roomConfig, mixId).get('minCoin', 0) kickOutCoin = cls.getArenaMixConf(roomConfig, mixId).get('kickOutCoin', 0) minQuickStartChip = cls.getArenaMixConf(roomConfig, mixId).get( 'minQuickStartChip', 0) userChip = userchip.getChip(userId) if userChip < minQuickStartChip: return ENTER_ROOM_REASON_TYPE_NORMAL, ENTER_ROOM_REASON_LESS_MIN else: minCoin = roomConfig['minCoin'] kickOutCoin = roomConfig.get('kickOutCoin', 0) if ftlog.is_debug(): ftlog.debug('DizhuQuickStart._canEnterRoom roomId =', roomId, 'minCoin =', minCoin, 'chip =', chip, caller=cls) if innerTable == 0: if minCoin > 0 and chip < minCoin: return ENTER_ROOM_REASON_TYPE_NORMAL, ENTER_ROOM_REASON_LESS_MIN else: if kickOutCoin > 0 and chip < kickOutCoin: return ENTER_ROOM_REASON_TYPE_NORMAL, ENTER_ROOM_REASON_LESS_MIN # 房间开放判断 if not dizhuhallinfo.canDisplayRoom(DIZHU_GAMEID, userId, clientId, roomId, roomConfig): if ftlog.is_debug(): ftlog.debug('DizhuQuickStart._canEnterRoom NotCanDisplayRoom', 'gameId=', DIZHU_GAMEID, 'userId=', userId, 'clientId=', clientId, 'roomId=', roomId) return ENTER_ROOM_REASON_TYPE_NORMAL, ENTER_ROOM_REASON_NOT_OPEN # 准入时间判断 if not cls._checkOpenTime(roomConfig, datetime.now().time()): return ENTER_ROOM_REASON_TYPE_NORMAL, ENTER_ROOM_REASON_NOT_OPEN # 其他条件判断,比如VIP, 大师分等 result, msg = cls._validEnterRoomConditions(DIZHU_GAMEID, userId, clientId, roomId, roomConfig) if not result: return ENTER_ROOM_REASON_TYPE_CONDITION, msg return ENTER_ROOM_REASON_TYPE_NORMAL, ENTER_ROOM_REASON_OK except Exception as e: ftlog.error(e) return ENTER_ROOM_REASON_TYPE_NORMAL, ENTER_ROOM_REASON_INNER_ERROR
def _decodeFromDictImpl(self, d): from hall.entity.hallusercond import UserConditionRegister cond = d.get('condition') self.condition = UserConditionRegister.decodeFromDict(cond) return self